26

We currently use Glassfish 3 and I really want to use Java 8. I tried upgrading to Glassfish 4, but I experienced two bugs in the Glassfish 4 code so I had to revert back to Glassfish 3. Will Glassfish 3 work with Java 8 or will I have to upgrade my application container?

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356

3 Answers3

42

No, it won't be possible (at the moment, maybe a workaround will occur later).

I tried Glassfish 3.1.1 and Glassfish 3.1.2.2 with the final Java 8 JDK which was released today. It doesn't even start the server, some OSGI exceptions are thrown.

As the comment to your question showed, it doesn't even work with earlier builds of Glassfish 4.0.

Update 2015:

It looks like there is a way to make it work with Glassfish 3.1.2.2.

Open the file /glassfish/domains/domain1/config/osgi.properties of your Glassfish installation and add the following line at the end of the file: jre-1.8=${jre-1.7}

This should make the server start with JDK 8. It still doesn't work for Glassfish 3.1 or 3.1.1.

See also:

unwichtich
  • 13,712
  • 4
  • 53
  • 66
  • I got Glassfish 4 to work with Java 8 but you need to update glassfish with the update-tool and then start glassfish with a Java 8 vm. There seem to be some problems so don't use it in production environments! – mw88 Mar 20 '14 at 11:35
  • Looks like the bugs you listed got resolved. Anybody knows if it's working now? – botchniaque Sep 24 '14 at 10:25
  • 10
    Actually, I've found osgi.properties in `/[GF-3.1.2HOME]/glassfish/config`. – Jaumzera Sep 16 '16 at 19:54
  • I've modified `/[GF-3.1.2HOME]/glassfish/osgi/felix/conf/config.properties` file – Silence Oct 05 '16 at 13:51
39

Stopped by an error after upgrading my Java 7 to Java 8. Glassfish 3.1.2.2 just won't start.

Found a solution:

edit osgi.properties file in the glassfish/config folder and add this line at the end:

jre-1.8=${jre-1.7}
Pavel
  • 7,436
  • 2
  • 29
  • 42
max
  • 391
  • 3
  • 2
  • So glassfish starts up and your app works correctly after this minor change? – Daniel Kaplan Jun 08 '14 at 21:15
  • This change does allow GF3 to start. Does anyone have any experience beyond this to say if this is the only change needed? – Steve Kehlet Feb 11 '15 at 19:54
  • 1
    just had a quick test with some sample apps, got on deployment gf is logging Exception while visiting xxxx.class of size 11939 java.lang.ArrayIndexOutOfBoundsException: 28954 on of the apps (ear) while one other war file seems ok... might be some config or import conflict... dunno if anyone has tried with more detailed tests? – denizdurmus Mar 11 '15 at 08:28
  • Yup, this hack worked for me. (Win 7, GF Open Source Edition 3.1.2.2, JRE: Java HotSpot(TM) 64-Bit Server VM, version 25.40-b25). Thanks! (My webapp is still built with Java 6, though). – Per Lindberg Apr 17 '15 at 08:56
  • This solution indeed makes glassfish start.... BUT: when I deploy a java 8 war, the app is deployed, but any classes that contain java 8 references are not loaded with a "Exception while visiting xxxx.class of size..." error – Vova Feb 03 '16 at 19:10
  • @Vova For the application to point to jdk 8, the path has to be changed in the admin config page of glassfish server. ``` Configuration-> Server config - > JVM Settings-> JAVA_HOME ```` – Krishna Srinidhi Nov 11 '21 at 09:11
0

After fixing the osgi.properties as mentioned in the other answer, the HTTPS listeners will not work anymore until a patch is applied as mentioned here.