Eclipse生成的war文件在JBoss中无效

时间:2013-01-02 18:32:39

标签: eclipse jboss

在部署到JBoss时,我遇到了Eclipse生成的war文件的问题。我在Eclipse中配置了一个JBoss 5.1.0实例,并将Eclipse部署到JBoss。启动时,JBosss抱怨它无法读取zip文件(我认为它是war文件,因为它没有告诉我任何其他内容)。错误是这样的:

13:27:08,824 ERROR [ProfileDeployAction] Failed to add deployment: test.war
org.jboss.deployers.spi.DeploymentException: Error determining structure: test.war
    at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
    at org.jboss.web.deployers.WARStructure.determineStructure(WARStructure.java:248)
    at org.jboss.deployers.vfs.plugins.structure.StructureDeployerWrapper.determineStructure(StructureDeployerWrapper.java:73)
    at org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl.doDetermineStructure(VFSStructuralDeployersImpl.java:196)
    at org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl.determineStructure(VFSStructuralDeployersImpl.java:221)
    at org.jboss.deployers.structure.spi.helpers.AbstractStructuralDeployers.determineStructure(AbstractStructuralDeployers.java:77)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.determineStructure(MainDeployerImpl.java:1004)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.determineDeploymentContext(MainDeployerImpl.java:440)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.addDeployment(MainDeployerImpl.java:390)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.addDeployment(MainDeployerImpl.java:300)
    at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.addDeployment(MainDeployerAdapter.java:86)
    at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:61)
    at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
    at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
    at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
    at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
    at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
    at org.jboss.Main.boot(Main.java:221)
    at org.jboss.Main$1.run(Main.java:556)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file
    at org.jboss.virtual.plugins.context.AbstractExceptionHandler.handleZipEntriesInitException(AbstractExceptionHandler.java:39)
    at org.jboss.virtual.plugins.context.helpers.NamesExceptionHandler.handleZipEntriesInitException(NamesExceptionHandler.java:63)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:626)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.checkIfModified(ZipEntryContext.java:773)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getChild(ZipEntryContext.java:817)
    at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.createChildHandler(ZipEntryHandler.java:191)
    at org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.structuredFindChild(AbstractVirtualFileHandler.java:684)
    at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChild(ZipEntryHandler.java:165)
    at org.jboss.virtual.plugins.context.DelegatingHandler.getChild(DelegatingHandler.java:107)
    at org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.structuredFindChild(AbstractVirtualFileHandler.java:689)
    at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChild(ZipEntryHandler.java:165)
    at org.jboss.virtual.plugins.context.DelegatingHandler.getChild(DelegatingHandler.java:107)
    at org.jboss.virtual.VirtualFile.getChild(VirtualFile.java:481)
    at org.jboss.deployers.vfs.spi.structure.helpers.AbstractStructureDeployer.applyMetadataPaths(AbstractStructureDeployer.java:481)
    at org.jboss.deployers.vfs.spi.structure.helpers.AbstractStructureDeployer.createContext(AbstractStructureDeployer.java:455)
    at org.jboss.web.deployers.WARStructure.determineStructure(WARStructure.java:204)
    ... 25 more
Caused by: java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.(ZipFile.java:127)
    at java.util.zip.ZipFile.(ZipFile.java:143)
    at org.jboss.virtual.plugins.context.zip.ZipFileWrapper.ensureZipFile(ZipFileWrapper.java:175)
    at org.jboss.virtual.plugins.context.zip.ZipFileWrapper.acquire(ZipFileWrapper.java:245)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.initEntries(ZipEntryContext.java:484)
    at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:619)
    ... 38 more

我已经检查了war文件,它看起来还不错,令人惊讶的是如果我提取war文件并用7zip压缩其内容,JBoss就可以了。我很困惑Eclipse如何创建一个JBoss无法读取的war文件。相同的war文件可以与Tomcat一起使用。

有没有人见过这个?我怎样才能解决这个问题?

3 个答案:

答案 0 :(得分:1)

所以在调试之后我发现其中一个库jar文件的大小为零。 jar为零大小的项目是空的,eclipse为它生成了一个零大小的jar文件(无论出于何种原因)。我不确定我之前可以将war文件部署到jboss,但这绝对是主要问题。

答案 1 :(得分:0)

正如另一个SO article所指出的,一个可能的问题是JVM正在尝试解压缩到无法写入的临时目录。尝试确定它试图解压缩的位置。

答案 2 :(得分:0)

可能是你的web.xml文件问题,我也面临同样的问题,经过很多不同的尝试后,我即将开始讨论另一篇关于web.xml和web-app的文章3.0。这让我思考,我检查了我的web.xml。果然,下面的一行恰好位于顶部。

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">

我改为2.5网络应用规范。 WAR和EAR都不会部署。

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">