2 Replies Latest reply on Feb 8, 2011 11:38 PM by rdelaplante

    GlassFish V3.1 RC2 deployment issues (JAXB/JAX-WS/JAX-RS)

    rdelaplante

      I'm trying V3.1 for the first time with a web application that runs fine on V3.0.1. 

      I have JAX-WS web service endpoint that needs some Spring beans injected, so it extends SpringBeanAutowiringSupport and uses @Autowired on some fields:

       

      @WebService(serviceName="MySOAPService")
      public class MySOAPService extends SpringBeanAutowiringSupport {

          @Autowired

          private SomeClass field1;

       

      The  class also has a setter method for one of the fields so that my unit  tests can inject an instance of the class.  The class being injected  does not have a zero arg constructor.

      When deploying this  application to GlassFish V3.1, for some reason JAX-WS tries to  instantiate this object and call the setter method even though it has  nothing to do with JAX-WS?   The exception I get is:

       

      .....

      Caused  by: java.security.PrivilegedActionException:  com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of  IllegalAnnotationExceptions
      com.company.project.SomeInterface is an interface, and JAXB can't handle interfaces.
              this problem is related to the following location:
                      at com.company.project.SomeInterface
                      at public com.company.project.SomeInterface com.company.project.service.soap.jaxws.SetField1.arg0
                      at com.company.project.service.soap.jaxws.SetField1
      com.company.project.SomeInterface does not have a no-arg default constructor.
              this problem is related to the following location:
                      at com.company.project.SomeInterface
                      at public com.company.project.SomeInterface com.company.project.service.soap.jaxws.SetField1.arg0
                      at com.company.project.service.soap.jaxws.SetField1
              at java.security.AccessController.doPrivileged(Native Method)
              at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:158)
              ... 49 more

       

      How does JAX-WS know  which implementation class to inject, and why is it trying to inject it  in the first place?   It is correct, the implementation class does not  have a zero-arg constructor.

      If I comment out the setter  method (because it is only used by the unit tests) then I am able to get  past that problem.   The next problem is:

       

      SEVERE: WebModule[/MyApp]PWC1270: Exception starting filter Jersey Web Application
      java.lang.InstantiationException
              at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:124)
              at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4625)
              at org.apache.catalina.core.StandardContext.start(StandardContext.java:5316)

      ....

      Caused by: java.lang.ClassNotFoundException: com.sun.jersey.spi.spring.container.servlet.SpringServlet
              at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1518)

       

      That is probably related to the following filer configured in web.xml:

          <filter>
              <filter-name>Jersey Web Application</filter-name>
              <filter-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</filter-class>
      ....

          </filter>

      This enables Spring bean injection in Jersey/JAX-RS resources.  Has this been removed?  Why, and how can I get it back?

       

      Eventually  I would like to replace Spring with CDI and EJB 3.1, but not today.   For now I just need to get the app running on GlassFish V3.1 as-is.

       

      Thanks,

      Ryan

       

        • 1. GlassFish V3.1 RC2 deployment
          rdelaplante

          Regarding the missing SpringServlet class in Jersey, I decided to try adding a dependency to it in Maven:

          <dependency>
              <groupId>com.sun.jersey</groupId>
              <artifactId>jersey-spring</artifactId>
              <version>1.0</version>
              <scope>compile</scope>
          </dependency>

          That results in a different error:

          SEVERE: WebModule[/WebCheckInOut]PWC1270: Exception starting filter Jersey Web Application
          java.lang.NoClassDefFoundError: com/sun/jersey/spi/service/ComponentProvider
                  at java.lang.Class.getDeclaredConstructors0(Native Method)
                  at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
                  at java.lang.Class.getConstructor0(Class.java:2699)
                  at java.lang.Class.getConstructor(Class.java:1657)
                  at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:306)

          I also tried addid the following dependency exclusion since the jersey server is provided by GlassFish, but it didn't help:

          <dependency>
              <groupId>com.sun.jersey</groupId>
              <artifactId>jersey-spring</artifactId>
              <version>1.0</version>
              <scope>compile</scope>
              <exclusions>
                  <exclusion>
                      <groupId>com.sun.jersey</groupId>
                      <artifactId>jersey-server</artifactId>
                  </exclusion>
              </exclusions>
          </dependency>

           

          Despite this error, my application is now deployed and seems to run.

          I also get a 5 mile long stack dump when shutting down GlassFish.   The same happened in GlassFish V3.0.1, but not in GlassFish V2.1

          Ryan

          • 2. GlassFish V3.1 RC2 deployment
            rdelaplante

            Regarding the missing SpringServlet class in Jersey, I decided to try adding a dependency to it in Maven:

            <dependency>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-spring</artifactId>
                <version>1.0</version>
                <scope>compile</scope>
            </dependency>

            That results in a different error:

            SEVERE: WebModule[/WebCheckInOut]PWC1270: Exception starting filter Jersey Web Application
            java.lang.NoClassDefFoundError: com/sun/jersey/spi/service/ComponentProvider
                    at java.lang.Class.getDeclaredConstructors0(Native Method)
                    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
                    at java.lang.Class.getConstructor0(Class.java:2699)
                    at java.lang.Class.getConstructor(Class.java:1657)
                    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:306)

            I also tried addid the following dependency exclusion since the jersey server is provided by GlassFish, but it didn't help:

            <dependency>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-spring</artifactId>
                <version>1.0</version>
                <scope>compile</scope>
                <exclusions>
                    <exclusion>
                        <groupId>com.sun.jersey</groupId>
                        <artifactId>jersey-server</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

             

            Despite this error, my application is now deployed and seems to run.

            I also get a 5 mile long stack dump when shutting down GlassFish.   The same happened in GlassFish V3.0.1, but not in GlassFish V2.1

            Ryan