Running Glassfish 4 on DIY cartridge with openjdk 1.7

The OpenShift forums have been retired.
You can still read and search them, but for help, please post a question on Stack Overflow.

I just can't get the server run, giving multiple exceptions. I can run glassfish 3 with no problem, it work perfect but GF4 won't work. Any idea what causes this? Thanks very much

Registered Module: [OSGiModuleImpl:: Bundle = [javax.servlet.jsp-api [68]], State = [NEW]]
Registered Module: [OSGiModuleImpl:: Bundle = [org.glassfish.main.web.weld-integration [6]], State = [NEW]]
Registered Module: [OSGiModuleImpl:: Bundle = [org.glassfish.main.deployment.admin [175]], State = [NEW]]
Registered Module: [OSGiModuleImpl:: Bundle = [org.eclipse.persistence.jpa.jpql [228]], State = [NEW]]
 
Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime@1651733 in service registry.
Completed shutdown of GlassFish runtime
We are in non-embedded mode, so org.glassfish.main.core.glassfish [107] has nothing to do.
Jun 26, 2013 8:08:18 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner createBundleProvisioner
INFO: Create bundle provisioner class = class com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.
Jun 26, 2013 8:08:18 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations
WARNING: Skipping entry  because it is not an absolute URI.
Jun 26, 2013 8:08:18 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations
WARNING: Skipping entry  because it is not an absolute URI.
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
        at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
Caused by: A MultiException has 8 exceptions.  They are:
1. java.lang.ExceptionInInitializerError
2. java.lang.IllegalStateException: Unable to perform operation: post construct on org.glassfish.server.ServerEnvironmentImpl
3. java.lang.NoClassDefFoundError: Could not initialize class com.sun.enterprise.util.net.NetUtils
4. java.lang.IllegalStateException: Unable to perform operation: post construct on org.glassfish.server.ServerEnvironmentImpl
5. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.sun.enterprise.v3.server.DomainXmlPersistence errors were found
6. java.lang.IllegalStateException: Unable to perform operation: resolve on com.sun.enterprise.v3.server.DomainXmlPersistence
7. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.sun.enterprise.v3.server.GFDomainXml errors were found
8. java.lang.IllegalStateException: Unable to perform operation: resolve on com.sun.enterprise.v3.server.GFDomainXml
 
        at org.jvnet.hk2.internal.Collector.throwIfErrors(Collector.java:84)
        at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:229)
        at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:311)
        at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:448)
        at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:118)
        at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2204)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetAllServiceHandles(ServiceLocatorImpl.java:1149)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServices(ServiceLocatorImpl.java:651)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServices(ServiceLocatorImpl.java:639)
        at org.jvnet.hk2.config.ConfigurationPopulator.populateConfig(ConfigurationPopulator.java:56)
        at org.glassfish.hk2.bootstrap.HK2Populator.populateConfig(HK2Populator.java:158)
        at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.populateConfig(AbstractModulesRegistryImpl.java:211)
        at com.sun.enterprise.module.bootstrap.Main.createServiceLocator(Main.java:273)
        at org.jvnet.hk2.osgiadapter.HK2Main.createServiceLocator(HK2Main.java:120)
        at com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime.newGlassFish(EmbeddedOSGiGlassFishRuntime.java:95)
        at com.sun.enterprise.glassfish.bootstrap.GlassFishRuntimeDecorator.newGlassFish(GlassFishRuntimeDecorator.java:68)
        at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntime.newGlassFish(OSGiGlassFishRuntime.java:91)
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:113)
        ... 6 more
Caused by: java.lang.ExceptionInInitializerError
        at com.sun.enterprise.util.net.NetUtils.<clinit>(NetUtils.java:55)
        at com.sun.enterprise.universal.glassfish.ASenvPropertyReader$ASenvMap.getHostname(ASenvPropertyReader.java:310)
        at com.sun.enterprise.universal.glassfish.ASenvPropertyReader$ASenvMap.get(ASenvPropertyReader.java:153)
        at com.sun.enterprise.universal.glassfish.ASenvPropertyReader$ASenvMap.completeMap(ASenvPropertyReader.java:191)
        at com.sun.enterprise.universal.glassfish.ASenvPropertyReader$ASenvMap.entrySet(ASenvPropertyReader.java:171)
        at org.glassfish.server.ServerEnvironmentImpl.postConstruct(ServerEnvironmentImpl.java:165)
        at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:281)
        at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:328)
        at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:448)
        at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:118)
        at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2204)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:549)
        at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:77)
        at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:191)
        at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:214)
        ... 22 more
Caused by: java.util.MissingResourceException: Can't find com.sun.enterprise.util.LogMessages bundle
        at java.util.logging.Logger.setupResourceInfo(Logger.java:1400)
        at java.util.logging.Logger.<init>(Logger.java:256)
        at java.util.logging.LogManager.demandLogger(LogManager.java:399)
        at java.util.logging.Logger.demandLogger(Logger.java:315)
        at java.util.logging.Logger.getLogger(Logger.java:408)
        at com.sun.enterprise.util.CULoggerInfo.<clinit>(CULoggerInfo.java:61)
        ... 37 more
 
Command start-domain failed.
[xxxx.rhcloud.com bin]\> timed out waiting for input: auto-logout
Connection to xxxx.rhcloud.com closed.

I ran into the exact same issue using:
rhc app create glassfish4 diy-0.1
rhc ssh glassfish4
cd $OPENSHIFT_DATA_DIR
wget http://download.java.net/glassfish/4.0/release/glassfish-4.0.zip
modify: glassfish4/glassfish/domains/domain1/config/domain.xml to looks similar to https://github.com/openshift/openshift-glassfish3-sample/blob/master/diy/glassfish3/glassfish/domains/domain1/config/domain.xml (e.g., commenting out some listeners/configs).
glassfish4/bin/asadmin start-domain

Validated that Java 7 is used. Will continue googling the issue. Might be worth reporting the issue to the Glassfish community.

Thanks so much Nam Duong, I also did the same steps and had no luck. I have been googling this issue too also had no luck. Is it possible for me to use my own JDK on diy cartridge?

Thank you Cheers Emre Simtay

Hi, I'm Yosi Pramajaya, representing JUG Joglosemar and JBUG Indonesia.

We're working together experimenting on trying JavaEE 7 in OpenShift. I have some error, but I can't know the detail. Why? I have "rhc tail -a ee7", but it said that asadmin -> Permission denied. I'm now trying to use chmod in "asadmin". But may I know, in OpenShift DIY 0.1, what JDK version is used? In GF 4.0 release notes, it said that GF 4 requiring JDK 7 update 21+.

Hi all,

I have tried and the exceptions is thrown like the above. I think this is because JDK in OpenShift environment is not supporting GF4 server. I recommend that OpenShift should use JDK 7 u 21+. Or perhaps we can include JDK on our own? Thanks

Hi Yosi I have successfully ran Glassfish 4 and OpenJDK 7 (1.7.0-u6-unofficial-b24) on my Windows 7 OS. Isn't it lower than u21? Can we include JDK on our own? Cheers

C:\glassfish4\bin>java -version openjdk version "1.7.0-u6-unofficial" OpenJDK Runtime Environment (build 1.7.0-u6-unofficial-b24) OpenJDK Client VM (build 23.2-b09, mixed mode)

C:\glassfish4\bin>asadmin start-domain Waiting for domain1 to start .............................. Successfully started the domain : domain1 domain Location: C:\glassfish4\glassfish\domains\domain1 Log File: C:\glassfish4\glassfish\domains\domain1\logs\server.log Admin Port: 4848 Command start-domain executed successfully.

Hi Emre,

I've checked OpenShift online environment through "java -version &> $OPENSHIFT_DIY_LOG_DIR/server.log" and "rhc tail -a ee7". The version is said to be JDK 7 u 25. So this is really confusing me. And the problem now is not the JDK. I thought another problem, but what? -_- Hahaha... From the stack trace, I think the problem is mis-configured domain.xml. What do you think?

My progress report: I've running with Oracle Virtual Box, and using OpenShift origin.

I've downloaded and install OpenJDK 7u25. And also download the GlassFish 4 to it. Still, return the same error as that. I will report this to GlassFish team, and hope we can get answer soon.

Thank you for reporting the issue. Please keep us up to date.

To answer some of the inline questions (although some moot points):
Version use on OpenShift - validated:
cmd> java -version
java version "1.7.0_25"

Can other java versions be installed on DIY:
Unfortunately due to user restrictions on the gear/hosts, yum/sudo are not accessible. You should be able to hand install programs into $OPENSHIFT_DATA_DIR with make/install

Could it be a misconfigured domain.xml?:
I've made modifications based on previous SMEs that got GF3 working: https://github.com/openshift/openshift-glassfish3-sample/blob/master/diy/glassfish3/glassfish/domains/domain1/config/domain.xml

Hi Nam,

I've ask this problem to members of Adopt OpenJDK and Adopt JSR program. One of them said that they can use GlassFish 4 in Fedora 18 environment (OpenShift Origin based OS). But they use Oracle JDK, they're trying as I'm trying too to use OpenJDK with GlassFish 4. I will inform you about our progress.

Hi Yosi,

Now Glassfish 4 is working with no problem. I guess the latest OpenShift Upgrades have resolved the issue we were having.

Thanks for your time and effort.

Cheers Emre

Hi Nam,

Now Glassfish 4 is working with no problem. Thanks for your time and effort.

Cheers Emre

I'm still having a problem in deploying GF4. But wait, when I'm trying to run it in my local computer, it throws the same error too (although different from the stack trace in this thread)

May I ask your domain.xml configuration? Or the source code? Thanks

Sorry I had remove my domain.xml it was so long!

Hi, I have used your domain.xml. But it only starting . . . . . . . . . . . . . . . . . . . . . and never ends. I waited for 3 mins (in my local comp it only 5 secs). Is that so long?

Here's my start action hooks:

# The logic to start up your application should be put in this
# script. The application will work only if it binds to
# $OPENSHIFT_INTERNAL_IP:8080
# nohup $OPENSHIFT_REPO_DIR/diy/testrubyserver.rb $OPENSHIFT_INTERNAL_IP $OPENSHIFT_REPO_DIR/diy &gt; $OPENSHIFT_LOG_DIR/server.log 2&gt;&amp;1 &amp;
cd $OPENSHIFT_REPO_DIR/diy/glassfish4/glassfish/domains/domain1/config/
mv domain.xml domain.xml_2
sed "s/$( grep serverName domain.xml_2 | cut -d\" -f 2 )/${OPENSHIFT_INTERNAL_IP}/g" domain.xml_2 > domain.xml
cd ../../../bin
mv asadmin asadmin.sh
chmod u+x asadmin.sh
bash asadmin.sh stop-domain &> $OPENSHIFT_DIY_LOG_DIR/server.log
bash asadmin.sh start-domain &> $OPENSHIFT_DIY_LOG_DIR/server.log

Here's my stop action hooks:

#!/bin/bash
source $OPENSHIFT_CARTRIDGE_SDK_BASH
 
# The logic to stop your application should be put in this script.
kill `ps -ef | grep glassfish4 | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1
exit 0

May I ask yours?

I don't know but how can my post become like this? Sorry, i'm just putting my source code, no any negative intentions. And please no offense.

No worries. This forum uses Markdown by default. I updated your post and added <code> tags around your source. </code>

Hello,

I was able to successfully run GlassFish 4 on OpenShift. There is no issue with running GlassFish 4 with OpenJDK version on OpenShift Online. I have written a quickstart to help you get started with GlassFish 4 on OpenShift https://github.com/shekhargulati/glassfish4-openshift-quickstart. The sample GlassFish 4 app is running here http://glassfish4-t20.rhcloud.com/hello/

Thanks Shekhar (OpenShift Developer Evangelist)

Thanks Shekhar!!