users@glassfish.java.net

Re: Controlling the VM version running the applications

From: Ludovic Champenois <Ludovic.Champenois_at_Sun.COM>
Date: Fri, 08 May 2009 13:06:33 -0700

On 5/8/09 11:50 AM, Per Steffensen wrote:
> Hi
>
> I have an application that is compiled by a java 1.6 compiler to
> compliance level 1.6.
>
> Case 1) When I run my application in a Glassfish started from the
> command line using "/Applications/Glassfish/bin/asadmin start-domain
> domain1" it works fine. It seems like the server starts on a 1.6 JVM
> and that the application is also run on a 1.6 JVM. See parts of
> server.log below (notice 1.6.0 in the first line, and 1.6.0_07 further
> down).
>
> Case 2) When I run my application in a Glassfish started from Eclipse
> (using a launcher where JRE is set up my 1.6.0 JDK) the application it
> fails. I get an UnsupportedClassVersionError. It looks like the server
> starts on a 1.6 JVM, but that the application is run by a 1.5 JVM. Se
> parts of server.log below (notice 1.6.0 in the first line, and
> 1.5.0_16 further down).
>
> What can be wrong? No matter what I do, I cant get rid of the
> UnsupportedClassVersionError when I run Glassfish from Eclipse. I cant
> fix! It insists on using 1.5.0 for the application eventhough it uses
> 1.6.0 for the server.
> How do you controll which JVM is used for the application? Can anyone
> think of a reason why Eclipse will run the server in a different way
> when I run it from the command line.
>
> Please help me. I am pretty lost!
>
I guess you might be using the GlassFish plugin version for Eclipse
which is less than v1.0.25.
See the release notes concerning v1.0.25 ((released 4/27/09) ) where
this issue has been addressed,
https://ajax.dev.java.net/eclipse/releasenotes.html

Mac is a tricky system when it comes to switching JDKs.
Ludo
> Regards, Per Steffensen
>
>
> --------------------- parts of the server.log in case 1
> -------------------------------------------
> INFO:
> /System/Library/Frameworks/JavaVM.framework/Versions/*1.6.0*/Home/bin/java
> -Dcom.sun.aas.instanceRoot=/Applications/Glassfish/domains/domain1
> -Dcom.sun.aas.ClassPathPrefix=
> -Dcom.sun.aas.ClassPathSuffix=
> -Dcom.sun.aas.ServerClassPath=
> -Dcom.sun.aas.classloader.appserverChainJars.ee=
> -Dcom.sun.aas.classloader.appserverChainJars=admin-cli.jar,admin-cli-ee.jar,j2ee-svc.jar
> -Dcom.sun.aas.classloader.excludesList=admin-cli.jar,appserv-upgrade.jar,sun-appserv-ant.jar
> -Dcom.sun.aas.classloader.optionalOverrideableChain.ee=
> -Dcom.sun.aas.classloader.optionalOverrideableChain=webservices-rt.jar,webservices-tools.jar
> -Dcom.sun.aas.classloader.serverClassPath.ee=Does not
> exist/lib/hadbjdbc4.jar,/Applications/Glassfish/lib/SUNWjdmk/5.1/lib/jdmkrt.jar,Does
> not exist/lib/dbstate.jar,Does not exist/lib/hadbm.jar,Does not
> exist/lib/hadbmgt.jar,/opt/SUNWmfwk/lib/mfwk_instrum_tk.jar
> -Dcom.sun.aas.classloader.serverClassPath=/Applications/Glassfish/lib/install/applications/jmsra/imqjmsra.jar,/Applications/Glassfish/imq/lib/jaxm-api.jar,/Applications/Glassfish/imq/lib/fscontext.jar,/Applications/Glassfish/imq/lib/imqbroker.jar,/Applications/Glassfish/imq/lib/imqjmx.jar,/Applications/Glassfish/lib/ant/lib/ant.jar,/Applications/Glassfish/lib/SUNWjdmk/5.1/lib/jdmkrt.jar
> -Dcom.sun.aas.classloader.sharedChainJars.ee=appserv-se.jar,appserv-ee.jar,jesmf-plugin.jar,Does
> not exist/lib/dbstate.jar,Does not
> exist/lib/hadbjdbc4.jar,jgroups-all.jar,/opt/SUNWmfwk/lib/mfwk_instrum_tk.jar
> -Dcom.sun.aas.classloader.sharedChainJars=javaee.jar,/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/tools.jar,install/applications/jmsra/imqjmsra.jar,com-sun-commons-launcher.jar,com-sun-commons-logging.jar,/Applications/Glassfish/imq/lib/jaxm-api.jar,/Applications/Glassfish/imq/lib/fscontext.jar,/Applications/Glassfish/imq/lib/imqbroker.jar,/Applications/Glassfish/imq/lib/imqjmx.jar,/Applications/Glassfish/imq/lib/imqxm.jar,webservices-rt.jar,webservices-tools.jar,mail.jar,appserv-jstl.jar,jmxremote_optional.jar,/Applications/Glassfish/lib/SUNWjdmk/5.1/lib/jdmkrt.jar,activation.jar,appserv-rt.jar,appserv-admin.jar,appserv-cmp.jar,/Applications/Glassfish/updatecenter/lib/updatecenter.jar,/Applications/Glassfish/jbi/lib/jbi.jar,/Applications/Glassfish/imq/lib/imqjmx.jar,/Applications/Glassfish/lib/ant/lib/ant.jar,dbschema.jar
> -Dcom.sun.aas.configName=server-config
> -Dcom.sun.aas.configRoot=/Applications/Glassfish/config
> -Dcom.sun.aas.defaultLogFile=/Applications/Glassfish/domains/domain1/logs/server.log
> -Dcom.sun.aas.domainName=domain1
> -Dcom.sun.aas.installRoot=/Applications/Glassfish
> -Dcom.sun.aas.instanceName=server
> -Dcom.sun.aas.jdwpOptions=transport=dt_socket,server=y,suspend=n,address=9009
> -Dcom.sun.aas.processLauncher=SE
> -Dcom.sun.aas.promptForIdentity=true
> -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
> -Dcom.sun.enterprise.overrideablejavaxpackages=javax.help,javax.portlet
> -Dcom.sun.enterprise.taglibs=appserv-jstl.jar,jsf-impl.jar
> -Dcom.sun.enterprise.taglisteners=jsf-impl.jar
> -Dcom.sun.updatecenter.home=/Applications/Glassfish/updatecenter
> -Ddomain.name=domain1
> -Djava.endorsed.dirs=/Applications/Glassfish/lib/endorsed
> -Djava.ext.dirs=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/jre/lib/ext:/Applications/Glassfish/domains/domain1/lib/ext:/Applications/Glassfish/javadb/lib
> -Djava.library.path=/Applications/Glassfish/lib:/Applications/Glassfish/lib:/Applications/Glassfish/lib
> -Djava.security.auth.login.config=/Applications/Glassfish/domains/domain1/config/login.conf
> -Djava.security.policy=/Applications/Glassfish/domains/domain1/config/server.policy
> -Djava.util.logging.manager=com.sun.enterprise.server.logging.ServerLogManager
> -Djavax.management.builder.initial=com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder
> -Djavax.net.ssl.keyStore=/Applications/Glassfish/domains/domain1/config/keystore.jks
> -Djavax.net.ssl.trustStore=/Applications/Glassfish/domains/domain1/config/cacerts.jks
> -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
> -Djmx.invoke.getters=true
> -Dsun.rmi.dgc.client.gcInterval=3600000
> -Dsun.rmi.dgc.server.gcInterval=3600000
> -client
> -Xdebug
> -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009
> -XX:+UnlockDiagnosticVMOptions
> -XX:MaxPermSize=192m
> -Xmx512m
> -XX:NewRatio=2
> -XX:+LogVMOutput
> -XX:LogFile=/Applications/Glassfish/domains/domain1/logs/jvm.log
> -cp
> /Applications/Glassfish/lib/jhall.jar:/Applications/Glassfish/lib/appserv-launch.jar
> com.sun.enterprise.server.PELaunch
> start
> debug
> Application server is listening at address 9009 for debugger to attach
> using transport dt_socket
> [#|2009-05-08T20:05:32.817+0200|INFO|sun-appserver2.1|javax.enterprise.system.core|_ThreadID=10;_ThreadName=main;Java
> HotSpot(TM) 64-Bit Server VM;1.6.0_07;Apple Inc.;|CORE5076: *Using
> [Java HotSpot(TM) 64-Bit Server VM, Version 1.6.0_07] from [Apple Inc.]|#]
> *----------------------------------------------------------------
>
> --------------------- parts of the server.log in case 2
> -------------------------------------------
> INFO:
> /System/Library/Frameworks/JavaVM.framework/Versions/*1.6.0*/Home/bin/java
> -Dcom.sun.aas.instanceRoot=/Applications/Glassfish/domains/domain1
> -Dcom.sun.aas.ClassPathPrefix=
> -Dcom.sun.aas.ClassPathSuffix=
> -Dcom.sun.aas.ServerClassPath=
> -Dcom.sun.aas.classloader.appserverChainJars.ee=
> -Dcom.sun.aas.classloader.appserverChainJars=admin-cli.jar,admin-cli-ee.jar,j2ee-svc.jar
> -Dcom.sun.aas.classloader.excludesList=admin-cli.jar,appserv-upgrade.jar,sun-appserv-ant.jar
> -Dcom.sun.aas.classloader.optionalOverrideableChain.ee=
> -Dcom.sun.aas.classloader.optionalOverrideableChain=webservices-rt.jar,webservices-tools.jar
> -Dcom.sun.aas.classloader.serverClassPath.ee=Does not
> exist/lib/hadbjdbc4.jar,/Applications/Glassfish/lib/SUNWjdmk/5.1/lib/jdmkrt.jar,Does
> not exist/lib/dbstate.jar,Does not exist/lib/hadbm.jar,Does not
> exist/lib/hadbmgt.jar,/opt/SUNWmfwk/lib/mfwk_instrum_tk.jar
> -Dcom.sun.aas.classloader.serverClassPath=/Applications/Glassfish/lib/install/applications/jmsra/imqjmsra.jar,/Applications/Glassfish/imq/lib/jaxm-api.jar,/Applications/Glassfish/imq/lib/fscontext.jar,/Applications/Glassfish/imq/lib/imqbroker.jar,/Applications/Glassfish/imq/lib/imqjmx.jar,/Applications/Glassfish/lib/ant/lib/ant.jar,/Applications/Glassfish/lib/SUNWjdmk/5.1/lib/jdmkrt.jar
> -Dcom.sun.aas.classloader.sharedChainJars.ee=appserv-se.jar,appserv-ee.jar,jesmf-plugin.jar,Does
> not exist/lib/dbstate.jar,Does not
> exist/lib/hadbjdbc4.jar,jgroups-all.jar,/opt/SUNWmfwk/lib/mfwk_instrum_tk.jar
> -Dcom.sun.aas.classloader.sharedChainJars=javaee.jar,/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/tools.jar,install/applications/jmsra/imqjmsra.jar,com-sun-commons-launcher.jar,com-sun-commons-logging.jar,/Applications/Glassfish/imq/lib/jaxm-api.jar,/Applications/Glassfish/imq/lib/fscontext.jar,/Applications/Glassfish/imq/lib/imqbroker.jar,/Applications/Glassfish/imq/lib/imqjmx.jar,/Applications/Glassfish/imq/lib/imqxm.jar,webservices-rt.jar,webservices-tools.jar,mail.jar,appserv-jstl.jar,jmxremote_optional.jar,/Applications/Glassfish/lib/SUNWjdmk/5.1/lib/jdmkrt.jar,activation.jar,appserv-rt.jar,appserv-admin.jar,appserv-cmp.jar,/Applications/Glassfish/updatecenter/lib/updatecenter.jar,/Applications/Glassfish/jbi/lib/jbi.jar,/Applications/Glassfish/imq/lib/imqjmx.jar,/Applications/Glassfish/lib/ant/lib/ant.jar,dbschema.jar
> -Dcom.sun.aas.configName=server-config
> -Dcom.sun.aas.configRoot=/Applications/Glassfish/config
> -Dcom.sun.aas.defaultLogFile=/Applications/Glassfish/domains/domain1/logs/server.log
> -Dcom.sun.aas.domainName=domain1
> -Dcom.sun.aas.installRoot=/Applications/Glassfish
> -Dcom.sun.aas.instanceName=server
> -Dcom.sun.aas.processLauncher=SE
> -Dcom.sun.aas.promptForIdentity=true
> -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
> -Dcom.sun.enterprise.overrideablejavaxpackages=javax.help,javax.portlet
> -Dcom.sun.enterprise.taglibs=appserv-jstl.jar,jsf-impl.jar
> -Dcom.sun.enterprise.taglisteners=jsf-impl.jar
> -Dcom.sun.updatecenter.home=/Applications/Glassfish/updatecenter
> -Ddomain.name=domain1
> -Djava.endorsed.dirs=/Applications/Glassfish/lib/endorsed
> -Djava.ext.dirs=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/ext:/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/jre/lib/ext:/Applications/Glassfish/domains/domain1/lib/ext:/Applications/Glassfish/javadb/lib
> -Djava.library.path=/Applications/Glassfish/lib:/Applications/Glassfish/lib:/Applications/Glassfish/lib
> -Djava.security.auth.login.config=/Applications/Glassfish/domains/domain1/config/login.conf
> -Djava.security.policy=/Applications/Glassfish/domains/domain1/config/server.policy
> -Djava.util.logging.manager=com.sun.enterprise.server.logging.ServerLogManager
> -Djavax.management.builder.initial=com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder
> -Djavax.net.ssl.keyStore=/Applications/Glassfish/domains/domain1/config/keystore.jks
> -Djavax.net.ssl.trustStore=/Applications/Glassfish/domains/domain1/config/cacerts.jks
> -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
> -Djmx.invoke.getters=true
> -Dsun.rmi.dgc.client.gcInterval=3600000
> -Dsun.rmi.dgc.server.gcInterval=3600000
> -client
> -XX:+UnlockDiagnosticVMOptions
> -XX:MaxPermSize=192m
> -Xmx512m
> -XX:NewRatio=2
> -XX:+LogVMOutput
> -XX:LogFile=/Applications/Glassfish/domains/domain1/logs/jvm.log
> -cp
> /Applications/Glassfish/lib/jhall.jar:/Applications/Glassfish/lib/appserv-launch.jar
> com.sun.enterprise.server.PELaunch
> start
> INFO: CORE5076: *Using [Java HotSpot(TM) 64-Bit Server VM, Version
> 1.5.0_16] from [Apple Inc.]*
> INFO: SEC1002: Security Manager is OFF.
> INFO: Using MQ RA for Broker lifecycle control
> FINE: initialized the connector registry
> FINE: returning the connector registry
> WARNING: java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at com.sun.enterprise.server.PELaunch.main(PELaunch.java:415)
> Caused by: java.lang.UnsupportedClassVersionError: Bad version number
> in .class file
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
> at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at sun.security.jca.ProviderConfig$3.run(ProviderConfig.java:234)
> at java.security.AccessController.doPrivileged(Native Method)
> at
> sun.security.jca.ProviderConfig.doLoadProvider(ProviderConfig.java:225)
> at
> sun.security.jca.ProviderConfig.getProvider(ProviderConfig.java:205)
> at sun.security.jca.ProviderList.getProvider(ProviderList.java:205)
> at
> sun.security.jca.ProviderList$ServiceList.tryGet(ProviderList.java:406)
> at
> sun.security.jca.ProviderList$ServiceList.access$200(ProviderList.java:348)
> at
> sun.security.jca.ProviderList$ServiceList$1.hasNext(ProviderList.java:458)
> at java.security.KeyFactory.nextSpi(KeyFactory.java:244)
> at java.security.KeyFactory.<init>(KeyFactory.java:107)
> at java.security.KeyFactory.getInstance(KeyFactory.java:135)
> at sun.security.x509.X509Key.buildX509Key(X509Key.java:203)
> at sun.security.x509.X509Key.parse(X509Key.java:153)
> at
> sun.security.x509.CertificateX509Key.<init>(CertificateX509Key.java:58)
> at sun.security.x509.X509CertInfo.parse(X509CertInfo.java:690)
> at sun.security.x509.X509CertInfo.<init>(X509CertInfo.java:152)
> at sun.security.x509.X509CertImpl.parse(X509CertImpl.java:1708)
> at sun.security.x509.X509CertImpl.<init>(X509CertImpl.java:179)
> at
> sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:90)
> at
> java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:271)
> at
> sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:704)
> at java.security.KeyStore.load(KeyStore.java:1150)
> at
> com.sun.enterprise.security.SecuritySupportImpl.loadKS(SecuritySupportImpl.java:152)
> at
> com.sun.enterprise.security.SecuritySupportImpl.loadStores(SecuritySupportImpl.java:105)
> at
> com.sun.enterprise.security.SecuritySupportImpl.initJKS(SecuritySupportImpl.java:82)
> at
> com.sun.enterprise.security.SecuritySupportImpl.<init>(SecuritySupportImpl.java:76)
> at
> com.sun.enterprise.security.SecuritySupportImpl.<init>(SecuritySupportImpl.java:71)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
> at java.lang.Class.newInstance0(Class.java:350)
> at java.lang.Class.newInstance(Class.java:303)
> at
> com.sun.enterprise.pluggable.PluggableFeatureFactoryBaseImpl.invoke(PluggableFeatureFactoryBaseImpl.java:84)
> at $Proxy0.getSecuritySupport(Unknown Source)
> at
> com.sun.enterprise.security.SecurityUtil.getSecuritySupport(SecurityUtil.java:364)
> at com.sun.enterprise.security.SSLUtils.<clinit>(SSLUtils.java:102)
> at
> com.sun.enterprise.security.SecurityLifecycle.onInitialization(SecurityLifecycle.java:101)
> at
> com.sun.enterprise.server.ApplicationServer.onInitialization(ApplicationServer.java:262)
> at
> com.sun.enterprise.server.ondemand.OnDemandServer.onInitialization(OnDemandServer.java:103)
> at com.sun.enterprise.server.PEMain.run(PEMain.java:399)
> at com.sun.enterprise.server.PEMain.main(PEMain.java:336)
> ... 5 more
> ----------------------------------------------------------------