glassfish
  1. glassfish
  2. GLASSFISH-16199

IllegalArgumentException: object is not an instance of declaring class - on a REST / EJB Service

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: V3, v3.0.1, 3.1
    • Fix Version/s: 3.1.1_b09
    • Component/s: jax-rs
    • Labels:
      None
    • Environment:

      MacOs

      Description

      Hello,

      I'm have the following error when deploying a JAX-RS / EJB service in a war or ear.

      The exception : "java.lang.IllegalArgumentException: object is not an instance of declaring class"

      Java code :

      @Local
      @Remote
      public interface Echo {
      
         String echo(String message);
      
      }
      
      @Stateless
      @Path("/echo")
      @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
      public class EchoImpl implements Echo {
      
         @GET
         @Path("/send")
         public String echo(@QueryParam("message") final String message) {
      	return message;
         }
      
      }
      
      public class RestResourcesApp extends Application {
      
         @Override
         public Set<Class<?>> getClasses() {
      	Set<Class<?>> s = new HashSet<Class<?>>();
      	s.add(EchoImpl.class);
      	return s;
         }
      
      }
      

      web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      	id="WebApp_ID" version="3.0">
      	<display-name>restEjb</display-name>
      	<servlet>
      		<servlet-name>RestResourcesServlet</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>test.RestResourcesApp</param-value>
      		</init-param>
      		<load-on-startup>1</load-on-startup>
      	</servlet>
      
      	<servlet-mapping>
      		<servlet-name>RestResourcesServlet</servlet-name>
      		<url-pattern>/rest/*</url-pattern>
      	</servlet-mapping>
      	<welcome-file-list>
      		<welcome-file>index.jsp</welcome-file>
      	</welcome-file-list>
      </web-app>
      

      http://localhost:8080/restEjb/rest/echo/send?message=hello

      works on tomcat 7.x, but failed on glassfish v3, V3.1

      Please find attach war test case.

      If you removed "implements Echo" in class EchoImpl , it will works

      Regards,

        Issue Links

          Activity

            People

            • Assignee:
              Jakub Podlesak
              Reporter:
              jraduget
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: