Will it be possible to use Java 8 on Glassfish 3? - java

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?

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:
JDK-8020071 Unable to start Glassfish 3.1.1. with JDK 8
GLASSFISH-19363 GF fails to start on jdk8

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}

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.

Related

Which Eclipse version is compatible with Tomcat 10, or do I go back to Tomcat 9?

I'm starting a web development project with a new install of Eclipse for Web developers; I installed Eclipse 2020-06 and Tomcat 10. But evidently those are not compatible; the first example JSP I entered has an error saying that HTTPServlet is not on the path.
On looking further, I discovered that the servlet library pathnames have changed; used to be javax... and are now jakarta... I'm assuming that's the problem, though I don't have definite confirmation of that.
Should I be using a newer version of eclipse, or an older version of Tomcat? Or is there something else I should be using?
EDIT: also using Java 11.0
EDIT: version of eclipse was a typo -- 2022-06 is the actual version.
So, you are assuming right...
There is a change in package name for tomcat 9 to tomcat 10 from javax.* to jakarta.* respectively....
for your project to work,
Either you downgrade to tomcat 9 and keep using the same package (javax)
Or you change change the package name to use jakarta and keep using tomcat 10...
Update to Eclipse 2022-06. It works with both versions, largely automatically.

Not able to add web project to tomcat server "There are no resources that can be added or removed from the server" - Java 17

After migrating the Eclipse (2021-9) workspace to Java 17, it is not possible any longer to add the Web project to the tomcat server.
Tomcat version is 9.0.54. All projects have Project Facet 17 and the related java 17 JRE.
Also the plugin 'Java 17 Support for Eclipse 2021-09 (4.21)' has been installed.
But adding the web project to the tomcat server is not working any longer. I get the message "There are no resources that can be added or removed from the server".
It only works when I set the project facet of this Web project back to Java 11 again. But that is not what we want.
So far I didn't find a solution for this problem. Do you know how to solve this issue?
Bug
This appears to be a known bug in Eclipse:
Bug 576466 - Can't add Java 17 WebApplication to Tomcat9
Workaround
As for a workaround, the author of the bug report mentions Eclipse does work properly if you switch to using Tomcat version 10.
FYI, versions of 9.x and 10.0 of Tomcat are special in that they are virtually identical, developed in parallel, the main difference being the switch in package names from javax.* to jakarta.* as part of compliance with Jakarta 9.0. See Transition from Java EE to Jakarta EE by Arjan Tijms.
Furthermore, Tomcat 10.1 is built to support Java 11, as part of compliance with Jakarta 9.1. Since you are using Java 17, I would suggest using Tomcat 10.1.x in your situation.

Tomcat 8.5 hot code replace failed - delete method not implemented

I have a problem when using Tomcat 8.5 with Eclipse. If I comment a java method, I get the error below, and also if I restart the server I cannot get synchronized. The only way to get synchronized is to restart Server.
I am using:
- tomcat 8.5.x
- Eclipse mars 2
- Java 8
- Tomcat manager plugin for eclipse, i cannot add tomcat server as usual because of the architecture of the project.
Any suggestion to solve de problem?
I am responding because I have found the solution.
First of all, the best practice is to created a Dynamic Web Project as suggested, but due to economic reasons (current architecture is installed and configured on a large number of servers and mantained by different prsons) we cannot change it.
The problem was in a class using a native Sun package and the use of the class JPEGImageEncoder that was deprecated after Java 6. Removing the use of that class and configuring ant to use java 7 and downgrading the jdk configured in Tomcat Manager Plugin from JDK 8 to JDK 7, after the deploy, the problem disappeared.

Add Tomcat 9 to eclipse

I have downloaded and installed tomcat 9 to my machine, but on Eclipse > Window > Preferences > Server > Runtime Environment, after clicking on Add, I see only Tomcat 7 and Tomcat 8, but not Tomcat 9.
What I have done:
1) installed tomcat 9 to local server;
2) updated eclipse to Mars (latest as of 2015-11-25);
3) installed eclipse "JST Server Adapters" and "JST Server Adapters Extensions"
Note:
My purpose of using tomcat 9 is it seems to be the only version that explicitly support java 8 and later, and my web app is using java 8. (http://tomcat.apache.org/whichversion.html)
I also have tomcat 7 exist in project but I also want to keep it in the machine, not to delete it.
Please see screenshot.
Please let me know about any config that I missed!
There are two things to note here:
Tomcat 9 is not released yet. Not a final version that is. If you check the official website, you will see that the only available version is an M1 version. Hence there is no support from Eclipse WTP for this early version. It will come soon, but not yet.
Tomcat 9 is not the only version that explicitly supports Java 8. If you check this page, you will see that "Supports Java version: 8 and later", which in this context means, that it officially support only Java 8 and above. It does not mean however this is the only one supporting Java 8. Theoretically you should be able to use any Tomcat version, in practice a Tomcat 8 will work perfectly well, since it support Java 7 and above. The majority of people with a Java8 + Tomcat combination are using Tomcat 8. Tomcat 8 also has Eclipse WTP support.
I was able to get the adapters for Apache 9 by installing Eclipse Java EE Developer Tools 3.9.4
Use a later version of eclipse e.g. Eclipse Neon.
It should work.
I tried all the above methods but still was unable to find solution for the problem then I did the following and that helped me to add Apache tomcat to my Eclipse IDE:
After following Help>Eclipse Marketplace and installing Eclipse Java EE Developer Tools 3.10 still tomcat was not available so I went to Help>Eclipse Marketplace>Installed>Eclipse Java EE Developer Tools 3.10>Change I put tick on the following and then I got the Apache Tomcat finally in my Eclipse IDE:
JST Server Adapters
JST Server Adapters Extensions
JSF Tools-Tag Library Metadata(Apache Trindad)
Git Integration for Eclipse
Use later EE version of Eclipse! Contains Tomcat adapters 8.5 and 9.0
I had same problem, but not now.
On my side, eclipse marketplace was stucked on previous WST server adapters.
I've used old update feature Windows > Install New Software
In main update site, I found Web, XML, Java EE and OSGi Enterprise Development part, where WST Adapters where ready to update ...
Eclipse MarketPlace often embed too much features & plugins.
On my own point view, easier to keep a light eclipse ;-)
Tested on eclipse 2020-09

FakeHttpServer breaks when upgrading to Jetty 9

I am migrating an application that used Jetty 7.4.5.v20110725 to Jetty 9.3.0.M2, using Maven. I already had upgraded the javax.servlet-api to 3.1.0.
But I am using the FakeHttpServer version 0.3.0 for tests, and at this time there is no newer version. It uses the org.eclipse.jetty.server.nio.SelectChannelConnector class that used to exist up to Jetty 8.x, but does not exists anymore in Jetty 9.
Currently my projects breaks at runtime with a NoClassDefFoundError due to the removed class in Jetty that FakeHttpServer tries to use, holding me back from upgrading Jetty. What can I do to fix that?
Note, this was also cross-posted in the Portuguese StackOverflow version: https://pt.stackoverflow.com/q/64548/132
Upgrade the code that uses Jetty on FakeHttpServer for Jetty 9.
That is your only choice if you want to use Jetty 9 with FakeHttpServer.
Looking at the project page for FakeHttpServer, it seems that there have been no updates (commits) to the project tree since Dec 2012.
You'll either have to convince the project leads to update it, or do it yourself.
Note that Jetty contains several ways of testing webapps. Look at the unit tests in the jetty source code and I'm sure you will find the equivalent of FakeHttpServer.
ServletTester comes to mind as one example. Or just create a Server using the LocalConnector is another way.

Categories