2017-05-02 23 views
0

JAX-RSアノテーションを使用していますが、@BeanParamに問題があります。私はWildfly-SwarmとMavenを使用しています。次の行は、私のエラーの一部です:@BeanParamアノテーションを使用する際に問題が発生しました

2017-05-02 09:57:39,513 INFO [org.wildfly.swarm.runtime.deployer] (main) deploying e15735ec-96f3-42f3-be84-4dbd08e05e0d.war 2017-05-02 09:57:39,543 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0027: Starting deployment of "e15735ec-96f3-42f3-be84-4dbd08e05e0d.war" (runtime-name: "e15735ec-96f3-42f3-be84-4dbd08e05e0d.war") 2017-05-02 09:57:40,419 WARN [org.jboss.as.dependency.private] (MSC service thread 1-4) WFLYSRV0018: Deployment "deployment.e15735ec-96f3-42f3-be84-4dbd08e05e0d.war" is using a private module ("org.jboss.jts:main") which may be changed or removed in future versions without notice. 2017-05-02 09:57:40,488 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0003: Processing weld deployment e15735ec-96f3-42f3-be84-4dbd08e05e0d.war 2017-05-02 09:57:40,561 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 5.2.3.Final 2017-05-02 09:57:40,861 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."e15735ec-96f3-42f3-be84-4dbd08e05e0d.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."e15735ec-96f3-42f3-be84-4dbd08e05e0d.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "e15735ec-96f3-42f3-be84-4dbd08e05e0d.war" at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154) at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NoClassDefFoundError: com/test/example/models/User at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.privateGetPublicMethods(Class.java:2902) at java.lang.Class.getMethods(Class.java:1615) at io.swagger.jaxrs.Reader.read(Reader.java:255) at io.swagger.jaxrs.Reader.read(Reader.java:147) at io.swagger.jaxrs.config.BeanConfig.setScan(BeanConfig.java:172) at org.wildfly.swarm.swagger.deployment.SwaggerServiceActivator.activate(SwaggerServiceActivator.java:73) at org.jboss.as.server.deployment.service.ServiceActivatorProcessor.deploy(ServiceActivatorProcessor.java:74) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147) ... 5 more Caused by: java.lang.ClassNotFoundException: com.test.example.models.User from [Module "deployment.e15735ec-96f3-42f3-be84-4dbd08e05e0d.war:main" from Service Module Loader] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93) ... 15 more

私のpom.xml:

<modelVersion>4.0.0</modelVersion> 
<groupId>com.test.example</groupId> 
<artifactId>ws-be-example1</artifactId> 
<name>ws-be-example1</name> 
<version>1.0.0-SNAPSHOT</version> 
<packaging>jar</packaging> 
<properties> 
    <version.wildfly.swarm>2016.8.1</version.wildfly.swarm> 
    <maven.compiler.source>1.8</maven.compiler.source> 
    <maven.compiler.target>1.8</maven.compiler.target> 
    <failOnMissingWebXml>false</failOnMissingWebXml> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <groupId>org.wildfly.swarm</groupId> 
      <artifactId>bom-all</artifactId> 
      <version>${version.wildfly.swarm}</version> 

      <scope>import</scope> 
      <type>pom</type> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 


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

    <!-- Wildfly Swarm Fractions --> 
    <dependency> 
     <groupId>org.wildfly.swarm</groupId> 
     <artifactId>logging</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.wildfly.swarm</groupId> 
     <artifactId>jaxrs-cdi</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.wildfly.swarm</groupId> 
     <artifactId>swagger</artifactId> 
    </dependency> 


    <dependency> 
     <groupId>org.mongodb</groupId> 
     <artifactId>mongo-java-driver</artifactId> 
     <version>3.4.2</version> 
    </dependency> 

    <dependency> 
     <groupId>com.googlecode.json-simple</groupId> 
     <artifactId>json-simple</artifactId> 
     <version>1.1</version> 
    </dependency> 
</dependencies> 

<build> 
    <finalName>ws-be-example1</finalName> 

    <plugins> 

     <plugin> 
      <groupId>org.wildfly.swarm</groupId> 
      <artifactId>wildfly-swarm-plugin</artifactId> 
      <version>${version.wildfly.swarm}</version> 

      <configuration> 
       <mainClass>com.test.example.Main</mainClass> 
       <properties> 
        <swarm.http.port>3001</swarm.http.port> 
        <swarm.debug.port>5005</swarm.debug.port> 
       </properties> 

       <environment> 
        <EXAMPLE2_HOST>localhost</EXAMPLE2_HOST> 
        <EXAMPLE2_PORT>8082</EXAMPLE2_PORT> 
        <EXAMPLE2_CONTEXT>/example2/frame</EXAMPLE2_CONTEXT> 
       </environment> 
      </configuration> 

      <executions> 
       <execution> 
        <goals> 
         <goal>package</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

マイ豆:

package com.test.example.models; 
import javax.ws.rs.FormParam; 

public class User { 


    @FormParam("nombre") 
    private String nombre; 

    @FormParam("apellido1") 
    private String apellido1; 

    @FormParam("apellido2") 
    private String apellido2; 

    @FormParam("direccion") 
    private String direccion; 

public User(String nombre, String apellido1, String apellido2, String direccion) { 
    this.nombre = nombre; 
    this.apellido1 = apellido1; 
    this.apellido2 = apellido2; 
    this.direccion = direccion; 
} 

public String getNombre() { 
    return nombre; 
} 

public String getApellido1() { 
    return apellido1; 
} 

public String getApellido2() { 
    return apellido2; 
} 

public String getDireccion() { 
    return direccion; 
} 
} 

私はクラスの前に注入しています私のエンドポイントは次のようになります:

@Path("/test") 
@POST 
@Produces(MediaType.APPLICATION_JSON) 
public Response prueba(@BeanParam User user){ 
    return Response.ok().build(); 
} 

すべてお寄せいただきありがとうございます。

+0

スガッガーの統合に関する問題のように見えます。 WF Swarmの 'swagger'依存関係を削除し、エラーが修正されているかどうか確認できますか? – Ken

+0

と複製するサンプルプロジェクトを含むhttps://issues.jboss.org/browse/SWARMの問題を提起してください。Beanクラスにデフォルトのコンストラクタが必要です。これはサポートされている唯一のコンストラクターです。だから、セッターも必要です –

答えて

0

問題が解決しました。あなたの助けの人たちのために私はJAXRSArchiveで私のクラスのパッケージを追加するのを忘れ ...

JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class); 

    deployment.setContextRoot("example1"); 
    deployment.addPackage("com.test.example.rest"); 
    deployment.addPackage("com.test.example.services"); 

    //I forgot to add this line 
    deployment.addPackage("com.test.example.models"); 

ありがとう! :)

関連する問題