Can I call a remote EJB method with CDI bean in parameter method?
Like this:
I have a LoggedUserProducer.java thats produces a User from the database.
public class LoggedUserProducer {
@Produces
@SessionScoped
@LoggedUser
public User produceLoggedUser() throws Exception {
... //load user from database with a request token
return user;
}
}
And I have a JSF Bean thats make the EJB call:
CarController.java
@Named
@ViewScoped
public class CarController implements Serializable {
@Inject //I have a producer to create the EJB proxy
private RepairRemote repairRemote; //My remote EJB
@Inject
@LoggedUser
private User loggedUser; //my User produced by LoggedUserProducer
private Car car;
public void repairCar() throws Exception {
... //some actions...
Repair repair = new Repair(this.car)
repair.setPerformedBy(loggedUser); //setting my proxified cdi bean into a POJO
repairRemote.repair(repair); //here throws ClassNotFoundException;
}
and the Exception:
java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters
at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:229)
at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:216)
...
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
at org.jboss.weld.proxies.RepairRemote$-248248579$Proxy$_$$_WeldClientProxy.repair(RepairRemote$-248248579$Proxy$_$$_WeldClientProxy.java)
at com.mycompany.services.controller.CarController.repairCar(CarController.java:118)
at com.mycompany.services.controller.CarController$Proxy$_$$_WeldSubclass.repairCar(CarController$Proxy$_$$_WeldSubclass.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
...
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: com.mycompany.portalcarweb.client.model.User$Proxy$_$$_WeldClientProxy from [Module "deployment.portalcarweb.war:main" from Service Module Loader]
I don't know why my remote EJB can't find the class com.mycompany.portalcarweb.client.model.User$Proxy$_$$_WeldClientProxy
My User.java is deployed in a JBoss 7 module.
My EJB client and server have the jboss-deployment-structure.xml
in WEB-INF
folder and declaring the correct module to access this class.
Thanks (sorry my english).
update
My two webapps are packaged in WARs file.