WildFLy 8上的部署失败

时间:2014-05-22 16:48:28

标签: maven deployment wildfly wildfly-8

我正在尝试在Wildfly 8上部署我的Web应用程序但是出错了。该错误表明The deployment scanner found a directory named META-INF that was not inside a directory whose name ends with .ear, .jar, .rar, .sar or .war.。这是一个奇怪的问题,因为我的web.xml位于src/main/webapp/WEB-INF/目录中,而构建的包以.war结尾。

我还尝试部署Maven生成的简单webapp。它是maven-archetype-webapp它在部署时也会失败,并显示相同的错误消息。见下文:

ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015010: The deployment scanner found a directory named META-INF that was not inside a directory whose name ends with .ear, .jar, .rar, .sar or .war. This is likely the result of unzipping an archive directly inside the /opt/wildfly8/standalone/deployments directory, which is a user error. The META-INF directory will not be scanned for deployments, but it is possible that the scanner may find other files from the unzipped archive and attempt to deploy them, leading to errors.
09:40:43,353 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "WebApp" (runtime-name: "WebApp")
09:40:43,354 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "pom.xml" (runtime-name: "pom.xml")
09:40:43,843 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "WebApp" (runtime-name : "WebApp")
09:40:43,844 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "pom.xml" (runtime-name : "pom.xml")

这是WildFly中的错误还是什么?由于生成的Maven项目也失败了,它让我觉得它可能是一个bug。



修改

我现在尝试了WildFly快速入门项目,他们的helloworld应用程序(https://github.com/wildfly/quickstart/tree/master/helloworld)在我的WildFly实例上运行良好。但是当我将web.xml添加到helloworld项目并将servlet代码更改为我自己的servlet代码和pom.xml以使其与我的设置相对应时,我就会出错。

04:50:28,073 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "MyService.war" (runtime-name: "MyService.war")
04:50:28,236 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016002: Processing weld deployment MyService.war
04:50:28,278 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016005: Starting Services for CDI deployment: MyService.war
04:50:28,285 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016008: Starting weld service for deployment MyService.war
04:50:28,318 WARN  [org.jboss.weld.Event] (MSC service thread 1-2) WELD-000411: Observer method [BackedAnnotatedMethod] com.sun.jersey.server.impl.cdi.CDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
04:50:28,622 INFO  [com.sun.jersey.api.core.PackagesResourceConfig] (MSC service thread 1-2) Scanning for root resource and provider classes in the packages:
  org.rox.webservice
04:50:28,641 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./MyService: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./MyService: Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_05]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_05]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_05]
Caused by: com.sun.jersey.core.spi.scanning.ScannerException: The URI scheme vfs of the URI vfs:/content/MyService.war/WEB-INF/classes/org/rox/webservice is not supported. Package scanning deployment is not supported for such URIs.
Try using a different deployment mechanism such as explicitly declaring root resource and provider classes using an extension of javax.ws.rs.core.Application
    at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:225)
    at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:139)

web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    <servlet>
        <servlet-name>MyWebService</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>org.rox.webservice</param-value>
       </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>MyWebService</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
    <display-name>MyWebService</display-name>
</web-app>

pom.xml

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>MyWebService</groupId>
    <artifactId>MyWebService</artifactId>
    <version>8.0.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>MyWebService</name>
    <description>MyWebService</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.wildfly.maven.plugin>1.0.1.Final</version.wildfly.maven.plugin>
        <version.compiler.plugin>3.1</version.compiler.plugin>
        <version.war.plugin>2.1.1</version.war.plugin>

        <!-- maven-compiler-plugin -->
        <maven.compiler.target>1.7</maven.compiler.target>
        <maven.compiler.source>1.7</maven.compiler.source>
    </properties>

    <dependencies>
        <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.8.2</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-server</artifactId>
                <version>1.8</version>
            </dependency> 
    </dependencies>

    <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>true</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>
</project>

5 个答案:

答案 0 :(得分:1)

您似乎没有部署WAR文件或WAR目录,而是整个项目。请注意服务器日志上的pom.xml,它不应该存在。我检查standalone/deployments以检查那里复制了什么。

此外,尝试运行mvn package并手动将文件复制到standalone/deployments/

答案 1 :(得分:1)

尝试使用wildfly maven插件来部署您的应用,而不是手动将应用程序复制到deployments文件夹。 但是,如果您希望或需要将应用程序复制到部署文件夹,请仅复制目标文件夹中的存档,而不是整个maven项目。

一般来说,您应该更喜欢&#34;基于cli的&#34;部署文件夹上的部署方法。 wildfly maven插件将在部署期间为您完成所有这些工作。

答案 2 :(得分:1)

我在你的pom.xml中发现了这个依赖:

<dependency>
  <groupId>com.sun.jersey</groupId>
  <artifactId>jersey-server</artifactId>
  <version>1.8</version>
</dependency>

我认为你不能使用Jersey,因为Wildfly自带了JAX-RS实现(Resteasy)。你为什么要包含这种依赖?尝试删除它,我认为应该没问题。

答案 3 :(得分:1)

<your project name>.war删除\standalone\deployments个文件,然后重试。

答案 4 :(得分:0)

修改 在进行了一些挖掘之后,这在Jersey 2.13版本https://jersey.java.net/release-notes/2.13.html中得到了修复。如果您遇到Jersey 1.x,请参阅下面的解决方法。

在JBoss 7和Wildfly的Jersey 1.x中使用包扫描存在问题。为此对泽西岛队开了一张罚单,但它已被关闭为“不重要,不会修复”:https://java.net/jira/browse/JERSEY-763

这似乎非常无用,因为我找到的唯一解决方法是在该故障单中列出,并涉及在扩展Resource的自定义类中手动指定所有javax.ws.rs.core.Application,并作为传递给Jersey servlet一个初始参数。

我建议我们对故障单进行评论,并询问为什么不值得修复,因为打包扫描比为大多数人手动指定资源更受欢迎。

以下是根据该票证中的详细信息为我工作的示例:

的web.xml:

<servlet>
    <servlet-name>com.sun.jersey.samples.helloworld.resources.MyApplication</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>com.sun.jersey.samples.helloworld.resources.MyApplication</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>resteasy.scan.providers</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>resteasy.scan.resources</param-name>
    <param-value>false</param-value>
</context-param>

com.sun.jersey.samples.helloworld.resources.MyApplication

package com.sun.jersey.samples.helloworld.resources;

import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.core.Application;

public class MyApplication extends Application {
    @Override
    public Set<Class<?>> getClasses() {
        final Set<Class<?>> classes = new HashSet<Class<?>>();
        // Add your class resources here like below
        classes.add(HelloWorldResource.class);
        return classes;
    }
}