ClassCastException trying to invoke EJB from Undertow Handler in JBoss EAP 7

Solution Unverified - Updated -

Issue

  • We have an Undertow Handler which tries to invoke an EJB when the handler is handling a web request.
 java.lang.ClassCastException: com.sun.proxy.$Proxy49 cannot be cast to com.jboss.examples.ejb.Hello
    at com.jboss.examples.client.HelloClient.callEJB(HelloClient.java:52)
    at com.redhat.eap7.undertow.ExampleHandler.handleRequest(ExampleHandler.java:25)
    at io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)
    at io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)

The Handler looks like:

public class ExampleHandler implements HttpHandler {
...
   @Override
    public void handleRequest(final HttpServerExchange exchange) throws Exception {
        log.info("requestPath: " + exchange.getRequestPath());
        try {
           log.info("Using HelloClient to lookup and invoke an EJB");
           HelloClient helloClient = new HelloClient();
           String response = helloClient.callEJB();
           log.info("helloClient ejb response: " + response);
        } catch(Throwable t) {
           t.printStackTrace();
        }
        next.handleRequest(exchange);
    }   
...

Environment

Red Hat JBoss Enterprise Application Platform (EAP) 7.0.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content