简体   繁体   中英

Convert a .war file into a right version

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 (eg 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 (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM