I have an application running on jdk7 and jboss and i would like to extract all the batch code from it to make it cleaner.
I want to create executable spring boot 2 jars and run them separately or at least upgrade to spring boot and the jdk version to 8.
Is it possible to run a spring boot 2 application that requires jdk 8 on a machine that also runs a jboss application on jdk 7 ? how can I specify the jdk version at runtime for an executable jar or war ?
I would like to use a container to solve this but our production team doesn't want that right now. I know there is "setenv" in a tomcat or weblogic servers but i would like to know if there is a spring boot solution for that (I didn't find any)
Thank you in advance.
You can have as many JVMs as you like on your machine. you just need to have the settings for the java version you need to be loaded.
ie if your java 8 is in c:\programs\java\jdk8\bin and your java 7 is in c:\programs\java\jdk7\bin, then you need to specify the java.exe absolutely as in c:\programs\java\jdk8\bin\java.exe you also need to set the environment variables for that session, like set JAVA_HOME=c:\programs\java\jdk8\bin\.
My example is using a windows machine as a base. You will need a startup script, or similar for the environment that you are using.
Note that if you just use java.exe in your startup script, then the JVM will be started with the first JVM found in your %PATH%, so you may want to remove Java from the path to be sure that you are getting the exact version you require.
Related
we are using one java application in wildfly server which uses java 1.8.0_202, now we want to migrate the java from oracle jdk to adoptopenjdk. I changed the path of new openjdk in management console of wildfly server.
Now the question is do we need again rebuild the application using adoptopenjdk or can i use the old war which is deployed.
Thanks in advance!..
As I cannot comment because of lack of reputation as an answer:
Normally you can run a Java Application without knowledge of the Java it was built with if the versions match. Second: Why don't you just try it? If you have these strong concerns you should try it in a test environment.
You should not need to do anything to migrate from an Oracle JDK to OpenJDK. Just change the path to the JAVA_HOME and that's it. The only possible issues would be if you use Oracle specific API's which one should not be doing anyway :)
I am struggling for a few days to write a docker-compose file for a simple jakartaEE/JavaEE restful JPA web application. DB is PostgreSQL and the application server is payara. This application inserts few entries to the DB and returns the collection in each rest call response. When I deploy the same application in the locally installed payara and Postgres, it is working fine. But it is failing with docker-compose with the error:
An error occurred during deployment: Class
com.docker.java.petstore.service.PetstoreService has unsupported major or
minor version numbers, which are greater than those found in the Java
Runtime Environment version 1.8.0_222. Please see the server.log for more details.
https://imgur.com/a/zVvVaGP
I tried deploying the war file from the payara admin console but failed with the same error.
The relevant code is shown here in the gist:
https://gist.github.com/JohnyzHub/cf8e9560b8640dbfd27dc4bb98d5991c
The environment used:
java 11
JakartaEE 8
Payara appserver
postgresql
Using glassfish-resource.xml file for dynamically creating the connection pool and data source.
The error looks strange, I am using java 11 but the error is about a specific java 8 version. I am not getting any clue what could be wrong here.
When I deployed the similar java 11 web application without JPA layer with a same docker file, it is working fine on docker.
Let me know if additional details are needed.
Any help is appreciated.
The official Payara Docker images on Dockerhub are using Java 8 inside. This clashes with your Java 11 compiled source code and does not work.
There is an open issue for this on GitHub, but unfortunately, now answer for months.
As a work-around either pick another application server (e.g. Open Liberty Universal Base Docker images have tags for the latest Java versions) or build your own Docker image from e.g. an OpenJDK 11 base image.
To figure out how to create your own Docker image, I would suggest to have a look at Adam Bien's Docklands repository, which contains multiple examples.
The error of your server says you compiled the classes in a higher version (JDK11) than its currently using (JDK8) in the docker image.
Check the used Java Runtime on the Application Server Docker image.
Then either compile the petstore using that JDK8 version of the server, or upgrade the docker container image to use a higher JDK than the one used to compile.
I have to compile a Java EE project with JBoss 7. When I run with JBoss 7, Netbeans creates a .war file. Due to problems with my environnment, I have to deploy this .war file with Tomcat6 on a virtual machine.
The problem is that the .war created is not compatible with tomcat6.
I tried to install tomcat7 on the virtual machine, but I have other problems like "NoClassDefFoundError".
So I'm looking for a way to convert the .war in the right version. How should I do please ?
There is no standard way to achieve this goal ("convert a .war file"), as Tomcat6 (out of the box) isn't a JEE certified application server - just a web container:
Apache Tomcat, a Servlet and Java Server Pages container
Thus, certain libraries that are part of a true JEE-application server are not bundled and present in the /lib folder of a plain Tomcat installation, for instance implementations for JTA, JPA, CDI, JAX-RS, JAX-WS...
However, you could try and download an enhanced Tomcat, namely TomEE, as it is - in it's latest release - JEE6 certified (and has several variants):
Apache TomEE, pronounced "Tommy", is an all-Apache Java EE 6 Web Profile certified stack where Apache Tomcat is top dog.
This might be a good solution to your migration approach as JBoss7 is also compliant to JEE6 level.
After you have downloaded TomEE you could then try to deploy your application in there. Nevertheless, you should have provided the full stacktrace or at least the Class (incl. fully qualified package) that is not found, as there might be certain third-party libraries in JBoss 7 that are not present in TomEE or other application servers.
Hope it helps.
War Files itself don't have a Version.
The Java Classes them selfs have a Java-Version (e.g. if they using Java 7 or Java 8).
If your Tomcat runs on Java 6 and you compiled with Java 7 you'd get a UnsupportedClassVersionError. If thats the case, you have to either update the Java-Version of Tomcat or compile your Code with Java 6 (and remove Java7 Features).
Other than that, it might be possible, that you're using Features from JBoss 7 that aren't available in Tomcat 6 (e.g you referring to Servlet 3.0 in your App, but Tomcat doesn't support that version). To make it work in this case, you'd have to remove all the Features, that Tomcat doesn't support.
I have 2 separate Java installations on my machine. I have 5.0 to support an older Enterprise app I develop on, and I have the latest JVM installed for other things. I need to keep the old version on my machine, but I am now trying to use Play! 2.0 for some of my own projects.
When I try to run it from the Play! directory I get a "UnsupportedClassVersionError" since the 5.0 version is getting picked up. What is the best way to point play to my 7.0 jdk installation? It is important that JDK5 remain the default.
The play executable you run is a launch script that starts sbt with the Java version that is on the path. You can either change the path when you start it, like so:
PATH="/my/jdk7/path:$PATH" play
This assumes you are using some kind of unix shell. If you aren't, you can modify the launch script itself.
If you mean in production as in play start, you can run once you have compiled your application using play dist :
java -jar yourappname.jar
And thus specify the java version, you want to use;
Currently my server is running of the Tomcat 5.5.26 and JDK 1.5.15.
Now I want to change to tomcat 6.0.29 and JDK 1.6.29.
There was many application running of the current environment so if I can change to new environment the required to compile all the application again and upload on the new environment or existing war file is working with new environment?
The applications should just work. However, you should do thorough testing of each one before inflicting them on your users, just to make sure. Your apps may be unintentionally relying on Tomcat 5-specific behaviour.
Furthermore, there should be no need to recompile under java 6 to make them work. However, you should check that the apps do still compile under Java 6. Again, they should, but it's worth checking.
Incidentally, why Tomcat 6? Tomcat 7 is current stable version of Tomcat; if you're going to migrate, you should migrate to that.