0

I am trying to create a basic Hello world app using this link.

I have created everything as asked but I am getting below error:

Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoSuchMethodError: com.sun.research.ws.wadl.Response.getRepresentationOrFault()Ljava/util/Lis

My web.xml

<web-app id="WebApp_ID" version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Restful Web Application</display-name>

    <servlet>
        <servlet-name>jersey-serlvet</servlet-name>
        <servlet-class>
            com.sun.jersey.spi.container.servlet.ServletContainer
        </servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>com</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>jersey-serlvet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

</web-app>

my dir structure

Ravi
  • 30,829
  • 42
  • 119
  • 173
Samuel
  • 1,128
  • 4
  • 14
  • 34

1 Answers1

2

java.lang.NoSuchMethodError an error can only occur at run time, if the definition of a class has incompatibly changed.

I can see, you have compiled your code with Jersey 1.8 and deployed your webapp on Glassfish 4.1.1.

And, as per one of the oracle official blog, Glassfish 4.1.1 has Jersey 2.2.

So, that conclude mismatch of jersey version (compiled with Jersey 1.8, but Glassfish is using Jersey 2.2). So, you are getting this exception at runtime.

The possible solution is to change your code to support jersey 2.2 (of course replace libraries as well)

Ravi
  • 30,829
  • 42
  • 119
  • 173