In this release of JBoss EAP 6, an Asynchronous EJB call via the EJB's Remote Interface from a client to an EJB running in the same JVM fails with a ClassCastException.
This is because the request/response are not being marshalled as they should and the client and EJB are not using the same classloader.
This is expected to be resolved in a future release and the request/response will be marshalled as it should since it is a Remote interface call, allowing the client and EJB to use different classloaders and not fail with a ClassCastException.
DescriptionWilliam Antônio
2015-02-02 20:29:48 UTC
Description of problem:
When invoking EJB asynchronous in different deployments and returning a POJO object, which will be retrieved using future.get, we have ClassCastException error.
Version-Release number of selected component (if applicable):
6.2
How reproducible:
Always.
Steps to Reproduce:
1. Deploy an EJB in an EAR that uses Asynchronous methods;
2. Deploy a Servlet in a WAR which will use this EJB;
3. Inject the EJB in a servlet and try to invoke it, then try to retrieve the result. Here's an example:
@EJB(lookup="java:global/testejb/testejb-ejb/AsyncService!rh.test.AsyncEJB")
private AsyncEJB asyncEJB;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Future<ReturnObject> futro = asyncEJB.testAsync();
ReturnObject ro;
try {
// this line below should throw the CCE
ro = futro.get();
}
catch (InterruptedException e) {
printResponse(resp, e.getMessage());
return;
}
catch (ExecutionException e) {
printResponse(resp, e.getMessage());
return;
}
printResponse(resp, String.format("Servlet response: %s", ro.getMessage()));
}
Actual results:
Error:
JBWEB000236: Servlet.service() for servlet rh.test.AsyncServlet threw exception: java.lang.ClassCastException: rh.test.ReturnObject cannot be cast to rh.test.ReturnObject
Expected results:
Invocation without error
Additional info:
It will work if we create a custom module with the model objects and make both deployments dependents of this module.
The configuration to force EAP to always use pass by value will not help in this issue.
Comment 7JBoss JIRA Server
2015-03-03 03:45:55 UTC
Brad Maxwell <bmaxwell> updated the status of jira WFLY-4331 to Reopened
Comment 9JBoss JIRA Server
2015-03-09 05:15:46 UTC
Brad Maxwell <bmaxwell> updated the status of jira WFLY-4331 to Resolved
Comment 15Rostislav Svoboda
2015-04-23 11:10:37 UTC
Re-acking after "qa_ack flag reset for and jboss-eap-6.4.0 and jboss-eap-6.4.z items" cleanup.
Description of problem: When invoking EJB asynchronous in different deployments and returning a POJO object, which will be retrieved using future.get, we have ClassCastException error. Version-Release number of selected component (if applicable): 6.2 How reproducible: Always. Steps to Reproduce: 1. Deploy an EJB in an EAR that uses Asynchronous methods; 2. Deploy a Servlet in a WAR which will use this EJB; 3. Inject the EJB in a servlet and try to invoke it, then try to retrieve the result. Here's an example: @EJB(lookup="java:global/testejb/testejb-ejb/AsyncService!rh.test.AsyncEJB") private AsyncEJB asyncEJB; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Future<ReturnObject> futro = asyncEJB.testAsync(); ReturnObject ro; try { // this line below should throw the CCE ro = futro.get(); } catch (InterruptedException e) { printResponse(resp, e.getMessage()); return; } catch (ExecutionException e) { printResponse(resp, e.getMessage()); return; } printResponse(resp, String.format("Servlet response: %s", ro.getMessage())); } Actual results: Error: JBWEB000236: Servlet.service() for servlet rh.test.AsyncServlet threw exception: java.lang.ClassCastException: rh.test.ReturnObject cannot be cast to rh.test.ReturnObject Expected results: Invocation without error Additional info: It will work if we create a custom module with the model objects and make both deployments dependents of this module. The configuration to force EAP to always use pass by value will not help in this issue.