Session replication not working in glassfish on multi node cluster - glassfish-3

Session replication not working in glassfish on multi node cluster
1) application contains distributable tag in web.xml
2) application when deployed in cluster c1, which contains 2 instances present on same node, session replication works.
3) Same application when deployed in cluster c2, which contains 2 instances present on two CentOS machines, session replication does not works.
Following are content of glassfish-web.xml (if required for reference) :
<glassfish-web-app error-url="">
<session-config>
<session-manager persistence-type="replicated">
<manager-properties>
<property name="persistenceFrequency" value="web-method" />
<property name="relaxCacheVersionSemantics" value="true"/>
</manager-properties>
<store-properties>
<property name="persistenceScope" value="session" />
</store-properties>
</session-manager>
<!--<cookie-properties>
<property name="cookieDomain" value="node2"/>
<property name="cookieDomain" value="node4"/>
</cookie-properties> -->
<cache max-entries="4096" timeout-in-seconds="30" enabled="false">
<default-helper/>
</cache>
</session-config>
<context-root>/contextNaam</context-root>
<class-loader delegate="true"/>
<resource-ref>
<res-ref-name>jdbc/safe</res-ref-name>
<jndi-name>jdbc/safe</jndi-name>
</resource-ref>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>
Edit : 1) Does not seems to be a UDP communication issue between 2 centos machines.
2) Tried to create tcp-cluster as mentioned in HA-administration-guide also, but still same effect, session not replicated on tcpcluster.

There was a bug in Shoal and incompatibility with Grizzly. I have fixed it in Payara and the fix is now in Glassfish too.
Current state is that it seems it works (Payara 4.1.1.154).

Under CentOS, you might run into trouble with SELinux and firewall rules. I suggest you disable them and try again.
I had a similar issue, though using JBoss, not Glassfish.
E.

Related

Tomcat 7: BeanInitializazionException with Spring MVC and external property file

I have a web application bulit in Spring MVC that has an external property file.
The external file is defined in application-config.xml as follows:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<!-- file di properties -->
<value>file:/myfolder/myfilename.properties</value>
<value>classpath:environment.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
The file is in /myfolder and is under my C:\ folder, but I need to deploy it (in production environment) on a Linux machine in which the property file path is /myfolder.
This web application runs well in Netbeans IDE (8.2) with local Tomcat 7 instance.
I am trying to run it in Eclipse with same local Tomcat 7 instance but I obtain the following exception:
ERROR ContextLoader:319 - Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: \myfolder\myfilename.properties (Impossible to find the path specified)
I've tried to change the server configuration in Eclipse, but nothing happens. How can I solve this issue?

Could not start GlassFish SERVERE: CORE10012 Application previously deployed is not at its original location any more

When i deleted the projects that i deployed once in the past,
i could not start the server because of this error:
Launching GlassFish on Felix platform
INFO: Running GlassFish Version: GlassFish Server Open Source Edition
3.1.2.2 (build 5)
INFO: Registered
org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for
persistence-type = replicated in BackingStoreFactoryRegistry
INFO: Grizzly Framework 1.9.50 started in: 125ms - bound to
[0.0.0.0:8181]
INFO: Grizzly Framework 1.9.50 started in: 109ms - bound to
[0.0.0.0:4848]
INFO: Grizzly Framework 1.9.50 started in: 31ms - bound to
[0.0.0.0:7676]
INFO: Grizzly Framework 1.9.50 started in: 125ms - bound to
[0.0.0.0:3700]
INFO: The Admin Console is already installed, but not yet loaded.
SEVERE: CORE10012: Application previously deployed is not at its
original location any more:
file:/C:/Documents%20and%20Settings/2796/My%20Documents/NetBeansProjects/mavenprojectJSF/target/mavenprojectJSF-1.0-SNAPSHOT/
SEVERE: CORE10012: Application previously deployed is not at its
original location any more:
file:/C:/Documents%20and%20Settings/2796/My%20Documents/NetBeansProjects/jsf1/build/web/
SEVERE: CORE10012: Application previously deployed is not at its
original location any more:
file:/C:/Documents%20and%20Settings/2796/My%20Documents/NetBeansProjects/struts/build/web/
SEVERE: CORE10012: Application previously deployed is not at its
original location any more:
file:/D:/self%20learning%202014/struts2/Struts2-ExecAndWait-Interceptor-Example/Struts2Example/target/Struts2Example/
INFO: GlassFish Server Open Source Edition 3.1.2.2 (5) startup time :
Felix (2,078ms), startup services(1,422ms), total(3,500ms)
SEVERE: Shutting down v3 due to startup exception : No free port
within range:
8080=com.sun.enterprise.v3.services.impl.monitor.MonitorableSelectorHandler#14fccd
INFO: Server shutdown initiated
INFO: Already stopped, so just returning
I modified the file
domain.xml
In
C:\Program Files\glassfish-3.1.2.2\glassfish\domains\domain1
And removed the application tags of xml and application-ref tags too for those projects mentioned above.
And i deleted the projects folder when i searched inside the glassfish folder
in
--> domains folder --> applications folder
To make it as i never deployed any personal project with it.
This way you are undeploying the applications on server without starting it that what was causing the error
I have encountered the same problem under Glassfish 4.1 after having migrated from Netbeans 8.2 to IntelliJ Idea.
To solve this problem I have only deleted application tags in domain.xml file.
I have deleted lines commented in following code
<applications>
<!-- TO-DELETE
<application context-root="/tlga" object-type="user" name="web" directory-deployed="true" location="file:/C:/GIT_SOURCES/TLGA-Web/web/target/tlga-1.18-SNAPSHOT/">
<property name="archiveType" value="war"></property>
<property name="appLocation" value="file:/C:/GIT_SOURCES/TLGA-Web/web/target/tlga-1.18-SNAPSHOT/"></property>
<property name="org.glassfish.ejb.container.application_unique_id" value="100406159636627456"></property>
<property name="org.glassfish.persistence.app_name_property" value="web"></property>
<property name="defaultAppName" value="tlga-1.18-SNAPSHOT"></property>
<module name="web">
<engine sniffer="ejb"></engine>
<engine sniffer="security"></engine>
<engine sniffer="webservices"></engine>
<engine sniffer="weld"></engine>
<engine sniffer="jpa"></engine>
<engine sniffer="web"></engine>
</module>
</application>
<application context-root="/tlga" object-type="user" directory-deployed="true" name="tlga-1.17.3" location="file:/C:/GIT_SOURCES/TLGA-WEB/web/target/tlga-1.17.3/">
<property name="archiveType" value="war"></property>
<property name="appLocation" value="file:/C:/GIT_SOURCES/TLGA-WEB/web/target/tlga-1.17.3/"></property>
<property name="org.glassfish.ejb.container.application_unique_id" value="100519021875888128"></property>
<property name="org.glassfish.persistence.app_name_property" value="tlga-1.17.3"></property>
<property name="defaultAppName" value="tlga-1.17.3"></property>
<module name="tlga-1.17.3">
<engine sniffer="ejb"></engine>
<engine sniffer="security"></engine>
<engine sniffer="webservices"></engine>
<engine sniffer="weld"></engine>
<engine sniffer="jpa"></engine>
<engine sniffer="web"></engine>
</module>
</application>
-->
</applications>
For me, DOMAIN.XML file is located in another location. To find it, I have searched to DOMAIN.XML files in c:\Glassfish.4.1\glassfish\domains folder.
I have deleted the 2 existing "/tlga" domains. Removing only one doesn't resolve my issue.
Explanation of how this error occurs:
These 2 <application> tags has been automatically generated by IntelliJ IDEA ULTIMATE 2018.2 !!! The first time I have deployed tlga-1.17.3, I don't have encountered any problem.
But this version was PRODUCTION version!
I have then switched GIT environment from PRODUCTION to DEVELOPMENT. I have build new release and started application again.
I suppose that IntelliJ has added a second <application> tag in domain.xml file and started again Glassfish that has refused to start !

Invalid Oracle URL specified: OracleDataSource.makeURL in Arquillian ITest

I persist with every error I get thrown and mostly always work out the solution. I find a good walk helps. But this one has me stumped, I've been staring at this same error all day. Like Ticcie in Invalid Oracle URL specified: OracleDataSource.makeURL suggests, the error message does nothing to help understand what is wrong.
SEVERE: Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Invalid Oracle URL specified: OracleDataSource.makeURL
Error Code: 0
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:762)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
I am doing Arquillian Integration Testing for a Java EE 7 EAR application. Its been going well using JPA and the DerbyDb but I now need to test Native Oracle DB (11g) SQL. So I've setup a new testing project to connect to an OracleDB using EclipseLink.
I CAN connect to the database through the Eclipse IDE DataSource explorer and ping it no problems.
I DO connect to a sister Oracle database in Glassfish standalone and ping it no problems.
But the Arquillian Test cannot connect to it with the above ambiguous error. It would be nice if the error said what exactly is the problem.
I use exactly the same URL as I have with the Eclipse IDE DataSource explorer:
jdbc:oracle:thin:#marina.work.com:1521:orcl
The Arquillian setup is the same as I did for DerbyDb (pretty-much same as http://arquillian.org/guides/testing_java_persistence/) with these variations for OracleDB:
src/main/resources-glassfish-embedded/sun-resources.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-resource pool-name="ArquillianOraclePool" jndi-name="jdbc/arquillian" />
<jdbc-connection-pool name="ArquillianOraclePool" res-type="javax.sql.DataSource" datasource-classname="oracle.jdbc.pool.OracleDataSource"
is-isolation-level-guaranteed="false" >
</jdbc-connection-pool>
</resources>
src/main/resources-glassfish-embedded/test-persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="esaarch01-pu" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/arquillian</jta-data-source>
<jar-file>test.jar</jar-file>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.Url" value="jdbc:oracle:thin:#marina.work.com:1521:orcl" />
<property name="javax.persistence.jdbc.Password" value="demo" />
<property name="javax.persistence.jdbc.User" value="test" />
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" /> <!-- driver. -->
<property name="javax.persistence.jdbc.platform" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.logging.level.sql" value="FINE" />
</properties>
</persistence-unit>
</persistence>
I've introduced XML well-formedness errors such as text in the properties element and receive the following error. This shows that this file is being picked up for the correct purposes:
java.io.IOException: org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 16; Deployment descriptor file META-INF/persistence.xml in archive [test.jar]. cvc-complex-type.2.3: Element 'properties' cannot have character [children], because the ...
I've tried different property names but none change the error message. Which makes me think that the URL property isn't being picked up at all.
I've tried different variations of the URL (with matching mods for name and password):
javax.persistence.jdbc.url URL Url (three variations)
eclipselink.jdbc.url URL Url (three variations)
No variation works. Same error.
It would be really nice if the exception can be more specific about what it can and cannot find.
My question is, can anyone tell me the solution or suggest what's wrong or something I can try and work out what is going wrong?
UPDATE
I've posted this question on the Oracle forums and included the entire stack trace and the sample minimal code plus some instructions. If anyone is keen to look at it I'd be grateful.
https://forums.oracle.com/message/11152777#11152777
driver type is not provided, for my case, I used "thin" xaProperties.driverType="thin", please find similar config for your case.

Adding a directory to tomcat classpath and read the property file in spring

I am trying to read the test1.properties file which is located at an external folder.
here is my spring config file:
<bean id="propertyConfigurer3" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath:test.properties</value>
<value>classpath:test1.properties</value>
</list>
</property>
</bean>
if I place the test1.properties in the tomcat7/lib folder, I am able to read it.
However, I want to place it in a different directory as tomcat7/env/test1.properties
I have added the path to the the conf/catalina.properties:
common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/env
This its not working, please help
solution:
Ok.. finally fixed it.. I had been doing it correctly this whole time.. it was my IDE which caused the problem.
The IDE was not picking up the changes in the catalina.properties file. I had to delete the server config in my IDE and re configure it.
these links were helpful in general:
Adding a directory to tomcat classpath
http://www.mulesoft.com/tomcat-classpath#solutions
Ok.. finally fixed it.. I had been doing it correctly this whole time.. it was my IDE which caused the problem. The IDE was not picking up the changes in the catalina.properties file. I had to delete the server config in my IDE and re configure it.
these links were helpful in general:
Adding a directory to tomcat classpath
http://www.mulesoft.com/tomcat-classpath#solutions
Use setenv.sh in the bin directory. If the file doesn't exist, create it.
To add something to the classpath use the following syntax:
CLASSPATH=/yourdir/
For windows: setenv.bat
Solution: creating the setenv.bat file under tomcat bin folder helped me in WINDOWS.
If your intention to keep file outside the war or ear , so that you can update it without compling and creating war again. just editing the file and restarting the server. Keep it in any external folder , even outside server and give absolute path in spring.
<bean id="propertyConfigurer3" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath:test.properties</value>
<value>**file:/someexteranal/dir/test1.properties**</value>
</list>
</property>
Best thing , you can give this / path with root in Unix/linux and same will work in windows, just need to keep file in directory where your server is installed.
Like your tomcat in D drive , then keep it in D:\someexternal\dir and above code will work fine there too

Where does one place share beans in the extension path in alfresco?

I am trying to figure out where to place a share bean in the extension path. I have tried placing it in the following directories:
1) tomcat/shared/classes/
2) tomcat/shared/classes/alfresco/
3) tomcat/shared/classes/alfresco/web-extension
The bean has been declared in the custom-slingshot-application-context.xml along with some localized resources (the .properties files <== They get picked up). Some additional info. It's a share side bean because I can drop the package into the src directory of the expanded war file in the IDE and run share and it'll work.
Update
This is the custom-slingshot-application-context.xml content:
<beans>
<!-- Override WebScript Messages - add slingshot application messages -->
<bean id="webscripts.resources" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
<property name="resourceBundles">
<list>
<value>webscripts.messages.webscripts</value>
<value>alfresco.web-extension.messages.common</value>
<value>alfresco.web-extension.messages.slingshot</value>
<value>alfresco.web-extension.messages.profPerson</value>
</list>
</property>
</bean>
<bean id="webframework.factory.user.profPerson" class="com.test.ext.profUserFactory" parent="webframework.factory.base" />
</beans>
It seems you're using Tomcat, but as #Gagravarr mentions unless you are using the Tomcat supplied by the Alfresco installers, then the shared/classes directory is not enabled out of the box.
In Tomcat6/7, you need to add the following line to your conf/catalina.properties file (or modify it if it is already defined)
shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar
More information is available on the Install Tomcat6 wiki page.

Resources