Wildfly 10:执行失败:javax.ws.rs.NotFoundException:RESTEASY003210

时间:2016-09-01 11:23:23

标签: maven wildfly java-ee-7 wildfly-swarm

我正在尝试将wildfly-swarm与已在index.html上运行的hello world Web项目(只有一个glassfish文件)一起使用。这是我的POM.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
    <artifactId>MongoDBDemo</artifactId>
    <groupId>com.test</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>

    <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>org.wildfly.swarm</groupId>
            <artifactId>bom</artifactId>
            <version>${version.wildfly.swarm}</version>
            <scope>import</scope>
            <type>pom</type>
          </dependency>
        </dependencies>
    </dependencyManagement>

    <groupId>com.test</groupId>
    <artifactId>MongoDBDemo-web</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>MongoDBDemo-web</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.wildfly.swarm>2016.8.1</version.wildfly.swarm>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>7.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.wildfly.swarm</groupId>
                <artifactId>wildfly-swarm-plugin</artifactId>
                <version>${version.wildfly.swarm}</version>
                <executions>
                  <execution>
                    <goals>
                      <goal>package</goal>
                    </goals>
                  </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

我有这个例外:

2016-09-01 16:37:10,543 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-1) RESTEASY002010: Failed to execute: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8080/MongoDBDemo-web/index.html
        at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:75)
        at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
        at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:445)

我正在使用:

运行它
mvn wildfly-swarm:run

我不知道为什么我的浏览器上看不到任何输出,甚至没有例外。您能否告诉我为什么它将index.html假设为JAX-RS资源而不是物理HTML文件?

index.html位于src\main\webapp文件夹

1 个答案:

答案 0 :(得分:0)

默认情况下,WildFly Swarm不会向您的应用程序添加上下文路径。

您是否尝试过访问http://localhost:8080/index.html ??