ClassCastException: com.sun.proxy.$Proxy4 cannot be cast to org.package.Bean

Solution Unverified - Updated -

Issue

When accessing an EJB from standalone client:

test(org.package.BeanTest)  Time elapsed: 0.239 sec  <<< ERROR!
java.lang.ClassCastException: com.sun.proxy.$Proxy4 cannot be cast to org.package.BeanTest
    at org.superbiz.async.JobProcessorTest.test(JobProcessorTest.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Client deployed:

13:44:58,635 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-5) WFLYEJB0473: JNDI bindings for session bean named 'Bean' in deployment unit 'deployment "ejb-example.jar"' are as follows:
    java:global/ejb-example/Bean!org.package.Bean
    java:app/ejb-example/Bean!org.package.Bean
    java:module/Bean!org.package.Bean
    java:jboss/exported/ejb-example/Bean!org.package.Bean
    ejb:/ejb-example/Bean!org.package.Bean
    java:global/ejb-example/Bean
    java:app/ejb-example/Bean
    java:module/Bean

Lookup:

        final Bean bean = (Bean) getInitialContext().lookup("ejb:/ejb-example/Bean!org.package.Bean");

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x

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