java - Passing objects via EJB RMI - NullPointerException -
i haven't been able find useful in days of searching. maybe i'm not looking right place.
here's idea - simple: i want pass object 1 ejb in-built rmi in j2ee.
as far can tell it's possible, real thing i've found people saying make object serializable, have (i serialized crap out of in fact), still no dice. here's test case , results in nullpointerexception when critical code uncommented.
i should mention in trying make work i've had many many errors haven't been able past. error simple example. i'm hoping can me specific 1 , can adapt it.
so, working in netbeans glassfish server updated of post, have enterprise application includes 2 other projects: ejb project , web project.
there following shared interfaces:
ejbmodule.interfaces.abeaninterface
package ejbmodule.interfaces; import javax.ejb.remote; @remote public interface abeaninterface { public srzedobjinterface getobject(); public string getstring(); // show simple string object can passed }
ejbmodule.interfaces.srzedobjinterface
package ejbmodule.interfaces; import java.io.serializable; public interface srzedobjinterface extends serializable { public string getthestring(); }
the ejb project has following classes:
ejbmodule.ejb.abean:
package ejbmodule.ejb; import ejbmodule.interfaces.abeaninterface; import ejbmodule.obj.srzedobj; import ejbmodule.interfaces.srzedobjinterface; import javax.ejb.stateless; @stateless public class abean implements abeaninterface { @override public srzedobjinterface getobject() { return new srzedobj(); } @override public string getstring() { return "this not string want"; } }
ejbmodule.obj
package ejbmodule.obj; import ejbmodule.interfaces.srzedobjinterface; import java.io.serializable; public class srzedobj implements srzedobjinterface, serializable { protected string thestring = "this string want"; @override public string getthestring() { return thestring; } }
and web project includes jsf libraries , has following classes , test web page, standard beans.xml file (not shown) , web.xml file (not shown):
webmodule.webbean
package webmodule; import ejbmodule.interfaces.abeaninterface; import ejbmodule.interfaces.srzedobjinterface; import javax.ejb.ejb; import javax.enterprise.context.requestscoped; import javax.inject.named; @named @requestscoped public class webbean { @ejb private abeaninterface abeaninstance; // string want public string getstringviaobject() { // code produces error // ---------------------------- //srzedobjinterface srzedobject = abeaninstance.getobject(); // throws nullpointerexception //return srzedobject.getastring(); // ---------------------------- return ""; } // string don't want public string getstring() { return abeaninstance.getstring(); } // not string want, here show possible public string getlocalstring() { return "the local string"; } }
index.xhtml
<?xml version='1.0' encoding='utf-8' ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core"> <h:head> </h:head> <h:body> <h1>the strings</h1> <p>the local string: <h:outputtext value="#{webbean.localstring}"/></p> <p>the string: <h:outputtext value="#{webbean.string}"/></p> <p>the string object: <h:outputtext value="#{webbean.stringviaobject}"/></p> </h:body> </html>
apart standard files netbeans includes me, that's there is.
the stack trace produced (with problem code introduced) is:
severe: error rendering view[/index.xhtml] javax.el.elexception: /index.xhtml @18,90 value="#{webbean.stringviaobject}": java.lang.nullpointerexception @ com.sun.faces.facelets.el.tagvalueexpression.getvalue(tagvalueexpression.java:114) @ javax.faces.component.componentstatehelper.eval(componentstatehelper.java:194) @ javax.faces.component.componentstatehelper.eval(componentstatehelper.java:182) @ javax.faces.component.uioutput.getvalue(uioutput.java:169) @ com.sun.faces.renderkit.html_basic.htmlbasicinputrenderer.getvalue(htmlbasicinputrenderer.java:205) @ com.sun.faces.renderkit.html_basic.htmlbasicrenderer.getcurrentvalue(htmlbasicrenderer.java:355) @ com.sun.faces.renderkit.html_basic.htmlbasicrenderer.encodeend(htmlbasicrenderer.java:164) @ javax.faces.component.uicomponentbase.encodeend(uicomponentbase.java:875) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1764) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1760) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1760) @ com.sun.faces.application.view.faceletviewhandlingstrategy.renderview(faceletviewhandlingstrategy.java:402) @ com.sun.faces.application.view.multiviewhandler.renderview(multiviewhandler.java:131) @ javax.faces.application.viewhandlerwrapper.renderview(viewhandlerwrapper.java:288) @ com.sun.faces.lifecycle.renderresponsephase.execute(renderresponsephase.java:121) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.render(lifecycleimpl.java:139) @ javax.faces.webapp.facesservlet.service(facesservlet.java:594) @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1550) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:281) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:175) @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:655) @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:595) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:161) @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:331) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:231) @ com.sun.enterprise.v3.services.impl.containermapper$adaptercallable.call(containermapper.java:317) @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:195) @ com.sun.grizzly.http.processortask.invokeadapter(processortask.java:860) @ com.sun.grizzly.http.processortask.doprocess(processortask.java:757) @ com.sun.grizzly.http.processortask.process(processortask.java:1056) @ com.sun.grizzly.http.defaultprotocolfilter.execute(defaultprotocolfilter.java:229) @ com.sun.grizzly.defaultprotocolchain.executeprotocolfilter(defaultprotocolchain.java:137) @ com.sun.grizzly.defaultprotocolchain.execute(defaultprotocolchain.java:104) @ com.sun.grizzly.defaultprotocolchain.execute(defaultprotocolchain.java:90) @ com.sun.grizzly.http.httpprotocolchain.execute(httpprotocolchain.java:79) @ com.sun.grizzly.protocolchaincontexttask.docall(protocolchaincontexttask.java:54) @ com.sun.grizzly.selectionkeycontexttask.call(selectionkeycontexttask.java:59) @ com.sun.grizzly.contexttask.run(contexttask.java:71) @ com.sun.grizzly.util.abstractthreadpool$worker.dowork(abstractthreadpool.java:532) @ com.sun.grizzly.util.abstractthreadpool$worker.run(abstractthreadpool.java:513) @ java.lang.thread.run(thread.java:722) caused by: java.lang.nullpointerexception @ com.sun.corba.ee.impl.orbutil.classinfocache$classinfo.<init>(classinfocache.java:156) @ com.sun.corba.ee.impl.orbutil.classinfocache.get(classinfocache.java:281) @ com.sun.corba.ee.impl.encoding.cdrinputstream_1_0.read_value(cdrinputstream_1_0.java:1097) @ com.sun.corba.ee.impl.encoding.cdrinputobject.read_value(cdrinputobject.java:531) @ com.sun.corba.ee.impl.presentation.rmi.dynamicmethodmarshallerimpl$14.read(dynamicmethodmarshallerimpl.java:384) @ com.sun.corba.ee.impl.presentation.rmi.dynamicmethodmarshallerimpl.readresult(dynamicmethodmarshallerimpl.java:483) @ com.sun.corba.ee.impl.presentation.rmi.stubinvocationhandlerimpl.privateinvoke(stubinvocationhandlerimpl.java:203) @ com.sun.corba.ee.impl.presentation.rmi.stubinvocationhandlerimpl.invoke(stubinvocationhandlerimpl.java:152) @ com.sun.corba.ee.impl.presentation.rmi.codegen.codegenstubbase.invoke(codegenstubbase.java:227) @ ejbmodule.interfaces.__abeaninterface_remote_dynamicstub.getobject(ejbmodule/interfaces/__abeaninterface_remote_dynamicstub.java) @ ejbmodule.interfaces._abeaninterface_wrapper.getobject(ejbmodule/interfaces/_abeaninterface_wrapper.java) @ webmodule.webbean.getstringviaobject(webbean.java:18) @ webmodule.webbean$proxy$_$$_weldclientproxy.getstringviaobject(webbean$proxy$_$$_weldclientproxy.java) @ 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) @ javax.el.beanelresolver.getvalue(beanelresolver.java:363) @ com.sun.faces.el.demuxcompositeelresolver._getvalue(demuxcompositeelresolver.java:176) @ com.sun.faces.el.demuxcompositeelresolver.getvalue(demuxcompositeelresolver.java:203) @ com.sun.el.parser.astvalue.getvalue(astvalue.java:138) @ com.sun.el.parser.astvalue.getvalue(astvalue.java:183) @ com.sun.el.valueexpressionimpl.getvalue(valueexpressionimpl.java:224) @ org.jboss.weld.el.weldvalueexpression.getvalue(weldvalueexpression.java:50) @ com.sun.faces.facelets.el.tagvalueexpression.getvalue(tagvalueexpression.java:109) ... 41 more
thank patient enough read through that! appreciate help.
don't need share srzedobj
well? web tier can not deserialize concrete class not availalbe... npe in classinfocache.java:156
seems same error in this question.
Comments
Post a Comment