【问题标题】:Wrong war file name in deployment directory部署目录中的war文件名错误
【发布时间】:2016-03-18 04:37:11
【问题描述】:

我在访问时收到“404 Not found”错误消息: http://localhost:8080/bword 在 Eclipse 中。

此应用程序在 Wildfly 中提供。在 POM.xml 中,它定义了:

<artifactId>bword</artifactId>
<packaging>war</packaging>
<name>bword</name>

然而,奇怪的是,当我在 Eclipse 中运行应用程序并将 Wildfly 9.0 配置为服务器时,部署到 wildfly/standone/deployments/ 中的是 bbword.war,如下所示:

[abigail@localhost wildfly-9.0.2.Final]$ ls standalone/deployments/
bbword.war/          bbword.war.deployed 

哪个不对,应该是“bword.war/”和“bword.war.deployed”。

在Eclipse之外,如果我在项目“bword”下“mvn clean package”,可以得到target/目录下的“bword.war”。

请参阅附件截图以供参考。我怀疑在我的 pom、eclipse 或任何地方的某个地方,“bbword”而不是“bword”的配置错误,但我真的找不到它。我找不到任何“bbword”的痕迹。什么决定了部署下部署的战争文件的名称?

见附件。

已编辑(POM.xml 的一部分):

<build>
            <!-- Set the name of the war, used as the context root when the app 
                is deployed -->
            <finalName>${project.artifactId}</finalName>
            <plugins>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${version.war.plugin}</version>
                    <configuration>
                        <!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! -->
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
                <!-- WildFly plugin to deploy war -->
                <plugin>
                    <groupId>org.wildfly.plugins</groupId>
                    <artifactId>wildfly-maven-plugin</artifactId>
                    <version>${version.wildfly.maven.plugin}</version>
                </plugin>
                <!-- Compiler plugin enforces Java 1.6 compatibility and activates 
                    annotation processors -->
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${version.compiler.plugin}</version>
                    <configuration>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>

还有一个补充:

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
17:32:35,508 INFO  [org.jboss.modules] (main) JBoss Modules version 1.4.3.Final
17:32:35,702 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
17:32:35,761 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) starting
17:32:36,573 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 22) WFLYCTL0028: Attribute 'job-repository-type' in the resource at address '/subsystem=batch' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
17:32:36,594 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found bbword.war in deployment directory. To trigger deployment create a file called bbword.war.dodeploy
17:32:36,625 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
17:32:36,647 INFO  [org.xnio] (MSC service thread 1-5) XNIO version 3.3.1.Final

......

这是我在 Wildfly 上单击“作为服务器运行”后控制台消息的初始部分。它似乎显示“在部署目录中找到 bbword.war”。在我运行它之前,我删除了standalone/deployments/*中的所有内容。它从一个空目录开始。每当我运行服务器时,似乎“bbword.war”都会复制到该目录中。我想不通。我在计算机上使用“find / -name bbword.war”,但找不到该文件。真的很困惑。

更新:

最终发现问题:在'bword'项目下,有一个“.setting”目录,里面有这个文件: bword/.settings/org.eclipse.wst.common.component

其中有一行: ,其中“bbword”是我之前使用的部署名称。删除此目录并在 Maven 中运行“更新”似乎可以解决此问题。特别是我需要两者都做,首先删除这个目录,.setting,然后更新maven。

为此浪费了几天时间,但很高兴知道这一点。

【问题讨论】:

标签: eclipse maven deployment jboss wildfly


【解决方案1】:

有同样的问题并通过更正这两个文件来解决它:

.settings/org.eclipse.wst.common.component =>部署名称等

.project =>名字

【讨论】:

    【解决方案2】:

    首先,尝试在您的服务器上部署 maven 构建的工件 (bword.war)(不要忘记先完全清理任何 Eclipse 部署的工件)。
    您只需将bword.war 从您的/target 文件夹移动到您的path_to_wildfly/standalone/deployments 文件夹即可。
    检查服务器日志文件中的消息:Registered web context: &lt;web_context_name&gt;,一旦您的战争部署完毕,该消息就会出现。 如果它显示 /bbword - 这不是您所期望的,请检查您在 src/main/webapp/WEB-INF 中是否有一个 jboss-web.xml 文件,该文件将其指定为 web-context 值。

    如果 maven 工件生成正确的 webcontext - /bword,那么它一定是 Eclipse 配置问题。您是否尝试过从 Maven 更新 Eclipse 项目? :

    1. 右键单击您的项目
    2. 选择Maven
    3. 选择更新项目
    4. 从 Wildfly 服务器中删除您的项目,然后重新添加。如果这没有帮助,请尝试添加一个新的服务器运行时并在那里添加您的项目。最后的手段是创建一个新的 Eclipse 工作区。

    祝你好运。

    【讨论】:

    • 尝试了所有可能,但还没有成功。问题是这样的消息:“DeploymentScanner-threads - 1) WFLYDS0004: Found bbword.war in deployment directory...”,当 Wildfly 服务器在 Eclipse 中运行时,它出现在控制台输出的第三行。
    • 我的另一台电脑还没有出现这个问题,同样的项目。
    【解决方案3】:

    列出的解决方案对我不起作用。 我不得不在 Eclipse 中创建一个全新的项目:

    文件->新建->项目

    正确命名,然后从旧项目中复制粘贴必要的代码。 现在服务器名称是正确的。

    【讨论】:

      【解决方案4】:

      如果您从 intellij idea config 运行,则检查项目结构中的工件名称。在 pom.xml 中修复 finalname 标记后,我不得不手动重命名它。最好避免工件名称中的任何时间戳。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-03-23
        • 1970-01-01
        • 1970-01-01
        • 2013-06-01
        • 1970-01-01
        相关资源
        最近更新 更多