I am doing a project with distributed architectures, but I am having trouble returning java.util.Collection
to the client application.
I invoke an EJB in a managed Bean to fetch a collection of persistent objects.
I am using Java7 and JBoss7.1.1.
ManagedBean Method:
public Collection<Cliente> getClientes() { clientes=new ArrayList<Cliente>(); try { Context ctx = new InitialContext(); facade = (ClienteFacadeRemote) ctx.lookup(ClienteFacadeBean.NOME_EJB); } catch (NamingException e) { e.printStackTrace(); } clientes = facade.getCarteira(); return clientes; }
EJB Method:
public Collection<Cliente> getCarteira() { carteira = clienteDao.read(Cliente.QUERY_ALL); return carteira; }
The clienteDao.read(Cliente.QUERY_ALL)
method, finds entities and populates the collection. However, returning to a managed Bean, we have a stack trace:
javax.faces.el.EvaluationException: java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) javax.faces.component.UICommand.broadcast(UICommand.java:315) javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) root cause java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:229) org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:216) org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:188) org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179) org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43) org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128) org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) $Proxy31.getCarteira(Unknown Source) br.tcc.faetec.managedbean.ClienteMB.getTeste(ClienteMB.java:316) br.tcc.faetec.managedbean.ClienteMB.teste(ClienteMB.java:410) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:601) org.apache.el.parser.AstValue.invoke(AstValue.java:262) org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) javax.faces.component.UICommand.broadcast(UICommand.java:315) javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) root cause java.lang.ClassNotFoundException: org.hibernate.collection.internal.PersistentBag from [Module "deployment.external./home/marcos/tccmodel.jar:main" from Service Module Loader] org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) java.lang.Class.forName0(Native Method) java.lang.Class.forName(Class.java:264) org.jboss.marshalling.cloner.ClassLoaderClassCloner.clone(ClassLoaderClassCloner.java:46) org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:158) org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135) org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:187) org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135) org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:348) org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:309) org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:286) org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:254) org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135) org.jboss.marshalling.cloner.SerializingCloner$StepObjectInput.doReadObject(SerializingCloner.java:738) org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37) org.jboss.marshalling.MarshallerObjectInputStream.readObjectOverride(MarshallerObjectInputStream.java:57) java.io.ObjectInputStream.readObject(ObjectInputStream.java:363) java.util.ArrayList.readObject(ArrayList.java:733) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:601) org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:213) org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:302) org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:254) org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135) org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:225) org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:216) org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:188) org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179) org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43) org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128) org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) $Proxy31.getCarteira(Unknown Source) br.tcc.faetec.managedbean.ClienteMB.getTeste(ClienteMB.java:316) br.tcc.faetec.managedbean.ClienteMB.teste(ClienteMB.java:410) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:601) org.apache.el.parser.AstValue.invoke(AstValue.java:262) org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) javax.faces.component.UICommand.broadcast(UICommand.java:315) javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
source share