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:
- spring-ws calls getEndpointAdapter() from org.springframework.ws.server.MessageDispatcher
- 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:
<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
- Enable remote debugging on JBoss startup parameters (
set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n")
- From eclipse: Window -> open perspective -> Debug, Run -> Debug configurations, Remote Java Application -> New, set the port as 8787 and accept
- Since the problem I had was due to IllegalStateException, Use Run -> Add Java Exception Breakpoint on that exception
- Start the server, activate debugging
- Fire the request and follow through the call stack
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.