我正在尝试在 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 项目也失败了,这让我觉得它可能是一个错误。
编辑
我现在已经尝试了 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>