简体   繁体   English

将.war文件转换为正确的版本

[英]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. 我必须使用JBoss 7编译Java EE项目。当我使用JBoss 7运行时,Netbeans将创建一个.war文件。 Due to problems with my environnment, I have to deploy this .war file with Tomcat6 on a virtual machine. 由于我的环境问题,我必须在Tomcat6上将此.war文件部署在虚拟机上。

The problem is that the .war created is not compatible with tomcat6. 问题是创建的.war与tomcat6不兼容。

I tried to install tomcat7 on the virtual machine, but I have other problems like "NoClassDefFoundError". 我试图在虚拟机上安装tomcat7,但是还有其他问题,例如“ NoClassDefFoundError”。

So I'm looking for a way to convert the .war in the right version. 因此,我正在寻找一种将.war转换为正确版本的方法。 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 : 没有任何标准方法可以实现此目标(“转换.war文件”),因为Tomcat6(开箱即用)不是经过JEE认证的应用服务器-仅仅是一个Web容器

Apache Tomcat, a Servlet and Java Server Pages container Apache Tomcat,一个Servlet和Java Server Pages容器

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... 因此,作为真正的JEE应用程序服务器一部分的某些库不会被捆绑并存在于普通Tomcat安装的/lib文件夹中,例如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 ): 但是,您可以尝试下载增强的Tomcat,即TomEE ,因为它是最新版本-已通过JEE6认证(并且具有多个变体 ):

Apache TomEE, pronounced "Tommy", is an all-Apache Java EE 6 Web Profile certified stack where Apache Tomcat is top dog. Apache TomEE,发音为“ Tommy”,是经过全Apache Java EE 6 Web Profile认证的堆栈,其中Apache Tomcat是头等大事。

This might be a good solution to your migration approach as JBoss7 is also compliant to JEE6 level. 这可能是您的迁移方法的一个很好的解决方案,因为JBoss7也符合JEE6级别。

After you have downloaded TomEE you could then try to deploy your application in there. 下载TomEE之后,您可以尝试在其中部署应用程序。 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. 但是,您应该提供未找到的完整堆栈跟踪信息或至少提供Class(包括完全合格的程序包),因为JBoss 7中可能存在某些第三方库,这些库在TomEE或其他应用程序服务器中不存在。

Hope it helps. 希望能帮助到你。

War Files itself don't have a Version. War Files本身没有版本。

The Java Classes them selfs have a Java-Version (eg if they using Java 7 or Java 8). 它们自身的Java类具有Java版本(例如,如果它们使用Java 7或Java 8)。 If your Tomcat runs on Java 6 and you compiled with Java 7 you'd get a UnsupportedClassVersionError . 如果您的Tomcat在Java 6上运行并且使用Java 7编译,则会收到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). 在这种情况下,您必须更新Tomcat的Java版本或使用Java 6编译代码(并删除Java7功能)。

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). 除此之外,您还可能使用的是JBoss 7的功能,而这些功能在Tomcat 6中不可用(例如,您在App中引用Servlet 3.0,但Tomcat不支持该版本)。 To make it work in this case, you'd have to remove all the Features, that Tomcat doesn't support. 要使其在这种情况下起作用,您必须删除Tomcat不支持的所有功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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