5 Replies Latest reply on Sep 22, 2014 1:22 PM by Juan Burgos

    Inconvenience in the migration of REST services jboss 7.1.2 Wildfly 8.1.0

    Juan Burgos Newbie

      We are migrating an application from jboss 7.1.2 to wildfly 8.1.0 which uses a rest service extended from an abstract class. In Jboss works without incident but WildFly generates the following error message:


      Caused by: java.lang.IllegalArgumentException: javax.ws.rs.core.GenericEntity<T> does not specify the type parameter T of GenericType<T>
          at javax.ws.rs.core.GenericType.getTypeArgument(GenericType.java:246) [jaxrs-api-3.0.8.Final.jar:]
          at javax.ws.rs.core.GenericEntity.<init>(GenericEntity.java:128) [jaxrs-api-3.0.8.Final.jar:]
      
      

       

      What we do is define a session bean which extend the abstract class and implement an interface that contains annotations:


      Abstract Class:


      public abstract class ResourceAdapter<T extends Object> implements ResourceAdapterInterface<T> {
      }
      

       

      Interface Class:

       

      @Local
      @Produces({MediaType.APPLICATION_JSON})
      public interface ResourceAdapterInterface<T extends Object> {
      
         @Path("")
         @GET
         Response listarTodos();
      
         @Path("/{id}")
         @GET
         Response buscarPorId(@PathParam("id") String id);
      
         @Path("/listarPor")
         @GET
         Response listarPor(@Context UriInfo info);
      
         @Path("/buscarPor")
         @GET
         Response buscarPor(@Context UriInfo info);
      
         @Path("/listarPorNamedQuery")
         @GET
         Response listarPorNamedQuery(@Context UriInfo info);
      
         @Path("")
         @POST
         @Consumes({"application/json"})
         public Response adicionar(T t);
      
         @Path("/{id}")
         @DELETE
         public Response eliminar(@PathParam("id") String id);
      
         @Path("")
         @PUT
         @Consumes({"application/json"})
         public Response actualizar(T t);
      
      }
      

       

      Session Bean:

       

      @Stateless
      @Path("/Proveedor")
      public class ProveedorResource extends ResourceAdapter<Proveedor> implements ResourceAdapterInterface<Proveedor>{
      }
      

       

      The ResourceAdapterInterface ResourceAdapter and classes are packaged into a jar which is recorded as module WildFly and Session Bean ProveedorResource is packaged in a war in invoking the module dependency in META-INF

       

      Any idea what may be failing

       

        • 1. Re: Inconvenience in the migration of REST services jboss 7.1.2 Wildfly 8.1.0
          Tomaz Cerar Master

          WildFly implements newer JAX-RS 2.0 standard.

           

          Are you using newer jax-rs api jars for compiling?

          • 2. Re: Inconvenience in the migration of REST services jboss 7.1.2 Wildfly 8.1.0
            Juan Burgos Newbie

            The module was compiled with the 3.0.6 version RestEasy, change it to the same version of WildFly which is 3.0.8, Using java 1.7.0_51 OpenJDK to compile, but server using Java SE Runtime  Environment 1.7.0_55-b13 Oracle Corporation

            • 3. Re: Inconvenience in the migration of REST services jboss 7.1.2 Wildfly 8.1.0
              Tomaz Cerar Master

              That is not what I asked but anyhow.

               

              if you are using maven can you post your pom.xml or list of jars in lib used for compiling if you are using some archaic tool like ant.

              • 4. Re: Re: Inconvenience in the migration of REST services jboss 7.1.2 Wildfly 8.1.0
                Juan Burgos Newbie

                Module POM

                 

                <?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>
                
                   <groupId>selsa.arqos</groupId>
                   <artifactId>selsa.arqos.gr.servicios.api</artifactId>
                   <version>1.0</version>
                   <packaging>ejb</packaging>
                
                   <name>selsa.arqos.gr.servicios.api</name>
                
                   <properties>
                      <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
                      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                   </properties>
                
                   <dependencies>
                      <dependency>
                         <groupId>org.jboss.resteasy</groupId>
                         <artifactId>resteasy-jaxrs</artifactId>
                         <version>3.0.8.Final</version>
                         <scope>provided</scope>
                      </dependency>
                      <dependency>
                         <groupId>${project.groupId}</groupId>
                         <artifactId>selsa.arqos.gr.datos.api</artifactId>
                         <version>${project.version}</version>
                         <scope>provided</scope>
                      </dependency>
                      <dependency>
                         <groupId>${project.groupId}</groupId>
                         <artifactId>selsa.arqos.gr.utilidades</artifactId>
                         <version>${project.version}</version>
                         <scope>provided</scope>
                      </dependency>
                      <dependency>
                         <groupId>javax</groupId>
                         <artifactId>javaee-api</artifactId>
                         <version>7.0</version>
                         <scope>provided</scope>
                      </dependency>
                   </dependencies>
                
                   <build>
                      <finalName>${project.artifactId}</finalName>
                      <plugins>
                         <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-compiler-plugin</artifactId>
                            <version>3.1</version>
                            <configuration>
                               <source>1.7</source>
                               <target>1.7</target>
                               <compilerArguments>
                                  <endorseddirs>${endorsed.dir}</endorseddirs>
                               </compilerArguments>
                            </configuration>
                         </plugin>
                         <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-ejb-plugin</artifactId>
                            <version>2.3</version>
                            <configuration>
                               <ejbVersion>3.1</ejbVersion>
                            </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>
                      </plugins>
                   </build>
                
                </project>
                
                • 5. Re: Re: Re: Inconvenience in the migration of REST services jboss 7.1.2 Wildfly 8.1.0
                  Juan Burgos Newbie

                  Reviewing more thoroughly I find the error because it is not layered generic type recover, so in my class ResourceAdapter implements a method getType() I recover the object type of the superclass and this solves the drawback


                   

                  public abstract class ResourceAdapter<T> implements ResourceAdapterInterface<T> {
                  
                     public Type getType() {
                        Type type = ((ParameterizedType) getClass().getGenericSuperclass())
                                .getActualTypeArguments()[0];
                        return type;
                     }
                  
                   @Override
                     public Response buscarPor(UriInfo info) {
                        try {
                           List<T> list = getGestionDatos().listarPor(ParametrosUtil.MutlimapToMap(info.getQueryParameters()));
                  
                           if (list == null || list.isEmpty()) {
                              return Response.noContent().build();
                           }
                  
                           return Response.ok(new GenericEntity<T>(list.get(0), getType())).build();
                  
                        } catch (FechaUtilExcepcion ex) {
                           logger.error("buscarPor", ex);
                           return Response.status(500).entity(generarRespuesta("96", ex)).build();
                        }
                     }
                  

                   

                  Thank you for your help