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

          Hide
          marina vatkina added a comment -

          If we would have a proper EJB validation during deployment, your application won't deploy. If you need to access your bean through a local and a remote view, you need to have 2 interfaces defined. Adam's example has a bean with a local view.

          Show
          marina vatkina added a comment - If we would have a proper EJB validation during deployment, your application won't deploy. If you need to access your bean through a local and a remote view, you need to have 2 interfaces defined. Adam's example has a bean with a local view.
          Hide
          rherschke added a comment - - edited

          @marina vatkina:

          You did not get the point:

          (1) I did not give the example, attached to this issue
          (2) I'm facing same problems with NO(!!!) Annotations (neither @Local nor @Remote) tagging the business interface
          (3) I cannot tag the business interface due to it is in a third party dependency (well, could do this with aspectj but...)
          (4) I know, that Adam's example use an @LocalBean annotation which will not fit in my scenario (as described before) with the requirement to have a Remote SLSB implementing the business interface and thats why the error occurs

          I don't like to discuss about other's view of the specification nor about the correctness of others example.

          I've written, that this issue is still reproducible in gf 3.1.2 esp. if there is no Annotation attached to the SLSB implementation nor the business interface.

          So i'm very fine with Jakub's answer (which also leads to reopen this issue until another jersey version is available for gf 3.1.2).

          Show
          rherschke added a comment - - edited @marina vatkina: You did not get the point: (1) I did not give the example, attached to this issue (2) I'm facing same problems with NO(!!!) Annotations (neither @Local nor @Remote) tagging the business interface (3) I cannot tag the business interface due to it is in a third party dependency (well, could do this with aspectj but...) (4) I know, that Adam's example use an @LocalBean annotation which will not fit in my scenario (as described before) with the requirement to have a Remote SLSB implementing the business interface and thats why the error occurs I don't like to discuss about other's view of the specification nor about the correctness of others example. I've written, that this issue is still reproducible in gf 3.1.2 esp. if there is no Annotation attached to the SLSB implementation nor the business interface. So i'm very fine with Jakub's answer (which also leads to reopen this issue until another jersey version is available for gf 3.1.2).
          Hide
          Jakub Podlesak added a comment -

          The regression should already be fixed in Jersey 1.13. Not sure yet, when this would get into GF. Most likely it will be included in GF 3.1.3.

          Show
          Jakub Podlesak added a comment - The regression should already be fixed in Jersey 1.13. Not sure yet, when this would get into GF. Most likely it will be included in GF 3.1.3.
          Hide
          Jakub Podlesak added a comment -

          This has been fixed in Jersey 2.0-rc1, that has been integrated into the GF main trunk earlier today.

          Show
          Jakub Podlesak added a comment - This has been fixed in Jersey 2.0-rc1, that has been integrated into the GF main trunk earlier today.
          Hide
          Jakub Podlesak added a comment -

          The use case seems no longer supported by GF v4. The following error occurs when deploying the test web app:

          + asadmin deploy target/ejb-test-webapp.war
          remote failure: Error occurred during deployment: Exception while deploying the app [ejb-test-webapp] : The interface org.glassfish.jersey.tests.ejb.resources.Echo cannot be both a local and a remote business interface. Please see server.log for more details.
          Command deploy failed.
          
          Show
          Jakub Podlesak added a comment - The use case seems no longer supported by GF v4. The following error occurs when deploying the test web app: + asadmin deploy target/ejb-test-webapp.war remote failure: Error occurred during deployment: Exception while deploying the app [ejb-test-webapp] : The interface org.glassfish.jersey.tests.ejb.resources.Echo cannot be both a local and a remote business interface . Please see server.log for more details. Command deploy failed.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: