为什么从WebSphere中抛出Java EE错误的不兼容版本?

问题描述:

我在部署我的应用程序时使用WebSphere Allication Server版本7.0.0.13。这场战争是使用Ant 1.8.2版建立的战争和耳朵文件。当我通过WebSphere安装我的应用程序时,出现以下错误:为什么从WebSphere中抛出Java EE错误的不兼容版本?

The EAR file could be corrupt and/or incomplete. Make sure that the application is at a compatible Java(TM) Platform, Enterprise Edition (Java EE) level for the current version of WebSphere(R) Application Server.

com.ibm.websphere.management.application.client.AppDeploymentException [Root exception is org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException: dd_in_ear_load_EXC_]

我可以知道是什么原因导致问题?或者我错过了在Ant脚本中配置的东西?下面是编译WAR和EAR的ANT脚本。

<target name="compilewar" description="generating war"> 
     <war destfile="${dist.path}/WebApp.war" webxml="${source.path}/mywebapp/src/main/webapp/WEB-INF/web.xml"> 
      <webinf dir="${source.path}/mywebapp/src/main/webapp/WEB-INF/" includes="**/*"/> 
      <lib dir="${dist.path}/" includes="*.jar"/> 
      <classes dir="${source.path}/mywebapp/src/main/resources/" includes="**/*"/> 
      <fileset dir="${source.path}/mywebapp/src/main/webapp/"> 
       <include name="**/*.jsp"/> 
      </fileset> 
      <fileset dir="${source.path}/mywebapp/src/main/webapp/"> 
       <include name="main/**/*"/> 
      </fileset> 
     </war> 
    </target> 

<target name="compileear" description="Compile Ear file"> 
     <ear destfile="${source.path}/myear/src/main/application/WebApp.ear" appxml="${svn.working.project.path}application.xml"> 
      <metainf dir="${source.path}/mywebapp/src/main/webapp/META-INF"/> 
      <fileset dir="${dist.path}/" includes="*.war"/> 
     </ear> 
    </target> 

THanks @!

我解决了问题。这是由于javac ant任务中缺少属性。由于ANT文档中提及的属性:

Note that the default value depends on the JVM that is running Ant. We highly recommend to always specify this attribute.

建议指定要用于编译Java版本。以下是源属性的示例用法:

<javac source="1.6"/> 

THanks @!

好像您正试图在支持Java EE 5的WAS 7中部署j2ee 1.3/1.4兼容的WAR/EAR。检查您的application.xml和web.xml以查看您是否使用了正确的模式版本。还要检查IBM特定的部署描述符。我在WAS支持网站上提供了found this link

+0

你提到的模式版本的东西,这可能是对我来说,移动搜索的线索。我可以知道如何检查我当前在web.xml和application.xml中使用的j2ee版本吗? – huahsin68

+0

@ huahsin68检查servlet规范 –

+1

不,如果您在WAS 7上部署J2EE 1.3/1.4,则不会出现该错误;它支持这些级别。见http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rovr_specs.html – dbreaux

@ huahsin68:确保您使用WAS JDK来编译要作为war文件一部分打包的类。如果您也使用ant进行编译,请确保ANT使用WAS JDK作为Java环境运行。

服务器的systemout.log和startServer.log必须给出更多日志。检查一下。

如果您使用的是像eclipse这样的IDE,请将项目合规性级别设置为J2EE1.5并清理并重新构建。

+0

非常感谢您的咨询。我会研究这一点。顺便说一句,我使用纯ANT脚本来编译。 – huahsin68

当我在whesphere中安装一个简单的EAR时,我有同样的异常:[根异常是org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException:dd_in_ear_load_EXC_]并且原因是WAR中的WAR EAR被解压缩。所以,我在内部构建了一个带有WAR的新EAR,并且工作正常。在我的情况下,我使用Maven和插件(注意标签解压值)

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-ear-plugin</artifactId> 
      <version>2.10</version> 
      <configuration> 
       <modules> 
        <webModule> 
        <groupId>com.javaen</groupId> 
        <artifactId>myApp</artifactId> 
        <uri>myWar.war</uri> 
        <bundleFileName>myWar.war</bundleFileName> 
        <contextRoot>/myWar</contextRoot> 
        <unpack>false</unpack> 
        </webModule> 
       </modules> 
      </configuration> 
     </plugin> 

我希望这可以帮助您,对于