user2125853
user2125853

Reputation: 1315

Glassfish 4.0 Exception while loading the app, java.lang.IllegalStateException

I am new to web services and glassfish. Here is my code

package ws.mypkg;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

@WebService
@SOAPBinding(style=Style.RPC)
public class TestRPC {

    // This seems to cause the problem when a List is returned.
    public List<String> testRPC () {
        List<String> l = new ArrayList<String>();
        l.add("Hello");
        return l;
    }

    // This method work fine
    public String testRPC1 () {
        return "Testing RPC";
    }
}

If I have

@SOAPBinding(style=Style.RPC)

I get the following error when I try to deploy the web service.

cannot Deploy TestGF deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: Servlet web service endpoint '' failure. Please see server.log for more details.

Server log does not have anything more.

It deploys fine when I comment out @SOAPBinding(style=Style.RPC)

The problem appears to be with the first method. If I exclude the first method, the second method deploys fine. It seems like I am having this problem when I return a list from the method and I have @SOAPBinding(style=Style.RPC)

I am using Glassfish 4.0, jdk 1.7 and Eclipse (bundled in with Spring 3.4)

Upvotes: 2

Views: 10828

Answers (1)

unwichtich
unwichtich

Reputation: 13857

The problem is that your method return type is an interface and JAXB cannot work with interfaces because it doesn't know which List implementation to use.

To fix it just change the return type of method to ArrayList like this:

public ArrayList<String> testRPC () {
    ArrayList<String> l = new ArrayList<String>();
    l.add("Hello");
    return l;
}

As the error message suggests, more info can be found in the server.log. There should be something like:

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.util.List is an interface, and JAXB can't handle interfaces
    this problem is related to the following location:
        at java.util.List

This should point you in the right direction if similar errors occur.

See also:

Upvotes: 5

Related Questions