0

I'm running glassfish v3 on a ubuntu linux box. I've been having some problems with the server. There are times when the server will stop accepting requests and just hang. Nothing in the log has given me any help. While trying to track down this issue, I've noticed an oddity... the following is what I see when i type ps aux | grep java:

155 % ps aux | grep java
my-company  24242 90.0 17.3 3656228 690024 ?      Sl   18:39   1:17 /usr/home/my-company/local/jdk1.6.0_45/bin/java -cp /usr/home/my-company/glassfish3/glassfish/modules/glassfish.jar -XX:+UnlockDiagnosticVMOptions -XX:MaxPermSize=256m -XX:NewRatio=2 -Xmx1024m -client -javaagent:/usr/home/my-company/glassfish3/glassfish/lib/monitor/flashlight-agent.jar -Dfelix.fileinstall.disableConfigSave=false -Djavax.net.ssl.keyStore=/usr/home/my-company/glassfish3/glassfish/domains/domain1/config/keystore.jks -Djava.awt.headless=true -Dfelix.fileinstall.poll=5000 -Djava.endorsed.dirs=/usr/home/my-company/glassfish3/glassfish/modules/endorsed:/usr/home/my-company/glassfish3/glassfish/lib/endorsed -Dfelix.fileinstall.bundles.startTransient=true -Djavax.net.ssl.trustStore=/usr/home/my-company/glassfish3/glassfish/domains/domain1/config/cacerts.jks -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as -Djava.security.auth.login.config=/usr/home/my-company/glassfish3/glassfish/domains/domain1/config/login.conf -DANTLR_USE_DIRECT_CLASS_LOADING=true -Dgosh.args=--nointeractive -Dosgi.shell.telnet.maxconn=1 -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver -Dfelix.fileinstall.dir=/usr/home/my-company/glassfish3/glassfish/modules/autostart/ -Dosgi.shell.telnet.port=6666 -Djava.security.policy=/usr/home/my-company/glassfish3/glassfish/domains/domain1/config/server.policy -Dfelix.fileinstall.log.level=2 -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory -Dosgi.shell.telnet.ip=127.0.0.1 -Dcom.sun.aas.instanceRoot=/usr/home/my-company/glassfish3/glassfish/domains/domain1 -Dcom.sun.aas.installRoot=/usr/home/my-company/glassfish3/glassfish -Djava.ext.dirs=/usr/home/my-company/local/jdk1.6.0_45/lib/ext:/usr/home/my-company/local/jdk1.6.0_45/jre/lib/ext:/usr/home/my-company/glassfish3/glassfish/domains/domain1/lib/ext -Dfelix.fileinstall.bundles.new.start=true -Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.fileinstall -Djava.library.path=/usr/home/my-company/glassfish3/glassfish/lib:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk-amd64/lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib com.sun.enterprise.glassfish.bootstrap.ASMain -domainname domain1 -asadmin-args --host,,,localhost,,,--port,,,4848,,,--secure=false,,,--terse=false,,,--echo=false,,,--interactive=false,,,start-domain,,,--verbose=false,,,--debug=false,,,--domaindir,,,/usr/home/my-company/glassfish3/glassfish/domains,,,domain1 -instancename server -verbose false -debug false -asadmin-classpath /usr/home/my-company/glassfish3/glassfish/modules/admin-cli.jar -asadmin-classname com.sun.enterprise.admin.cli.AsadminMain -upgrade false -type DAS -domaindir /usr/home/my-company/glassfish3/glassfish/domains/domain1 -read-stdin true
my-company  24427  0.0  0.0   6512   620 pts/0    S+   18:40   0:00 grep java

There is something rather odd... it appears that the jvm used to start glassfish (via the asadmin command tool) is the JVM located at /usr/home/my-company/local/jdk1.6.0_45, but further in the glob of text, you can see the java.library.path set and it only includes libraries in the /usr/lib/jvm/java-6-openjdk-amd64/ !

The hosting company i'm using installs openJDK by default. I've installed the official oracle version of java /usr/home/my-company/local/jdk1.6.0_45 -- that's the version i want to use and I have set JAVA_HOME and JDK_HOME to point to reflect this. How do I set java.library.path? should it be set via an environment variable, or is this something I have to set inside glassfish itself?

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
cotfessi
  • 167
  • 2
  • 12

2 Answers2

1

You can set the JDK you want to use in the file <GLASSFISH_HOME>/glassfish/config/asenv.conf.

Set the entry AS_JAVA to point to the desired JDK, or if it doesn exist, add an entry like this at the end of the file:

AS_JAVA=/usr/home/my-company/local/jdk1.6.0_45

Here is a part of a blog entry about How Does GlassFish Pick the JVM to Run In?:

In order of precedence from high to low:

  1. The jdk location specified in domain.xml in the java-config ("java-home")
  2. The contents of AS_JAVA in the asenv property file (in glassfish/config)
  3. Whatever the env. variable, JAVA_HOME, is pointing at.
  4. The java.home system property is used like so:
    1. Parent directory of java.home -- this is because sometimes the JRE's java is asadmin's JVM and the JDK may be in the directory above.
    2. Contents of java.home

See also:

Community
  • 1
  • 1
unwichtich
  • 13,712
  • 4
  • 53
  • 66
0

java.library.path in glassfish points to the lib folder of glassfish. Generally it is set as AS_NSS key in asenv.conf file in glassfish installation dir. During any operation if a shared library is mising then you will see below error.

no <lib> in java.library.path
GP Singh
  • 706
  • 5
  • 12