spring-ws: No adapter for endpoint

Today I was greeted with

java.lang.IllegalStateException: No adapter for endpoint […]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?

And even after confirming that I do have endpoint annotated with @Endpoint, and similar endpoint working fine in another app, the problem insisted.

Turns out the message is misleading, and there are other issues that can cause this problem. The logic, which you can follow up with a debugger, goes as follows:

  1. spring-ws calls getEndpointAdapter() from org.springframework.ws.server.MessageDispatcher
  2. getEndpointAdapter() iterates all found EndpointAdapters, and if any of them supports the endpoint parameter given, that is used

As can be seen from the code, by “support” we mean that both request type and response type are supported. For both of these, a class file matching the request must exist. Also, as can be seen from the source code, there are additional checks.

For me, the successful processing relied on XmlRootElementPayloadMethodProcessor. The check for that checks for isAnnotationPresent(XmlRootElement.class); in the correct class. When I checked the generated class I had, it was missing this annotation! The missing annotation was due to missing this in the bindings file:

<jaxb:bindings node=”xsd:complexType[@name=’MyRequestMessage’]”>
<annox:annotate annox:class=”javax.xml.bind.annotation.XmlRootElement” name=”MyRequest” />

and that caused for it to not be detected. Adding that everything worked.

Now, the way I discovered this, was

  1. Enable remote debugging on JBoss startup parameters (set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n")
  2. From eclipse: Window -> open perspective -> Debug, Run -> Debug configurations, Remote Java Application -> New, set the port as 8787 and accept
  3. Since the problem I had was due to IllegalStateException, Use Run -> Add Java Exception Breakpoint on that exception
  4. Start the server, activate debugging
  5. Fire the request and follow through the call stack

That’s it.

Ps. seems that another reason for getting the same exception is that some/one of the classes it tries to autodetect is not in the class path. Watch out for that one, too. It might bite even if the namespace is different.

This entry was posted in jboss, spring. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s