Returning an entity via remote EJB results in - java.lang.NullPointerException at com.sun.corba.ee.impl.orbutil.ClassInfoCache$ClassInfo.<init>

11,712

Solution 1

The problem is with the de-serialization of the Zone class instance. It should be Serializable and should be present at both the client and server (local and remote). This will impose a dependency to add persistence libraries to remote server as well. Hence its better not to send a persistence entity.

Solution 2

I just had an instance of this problem. The remote method I was calling threw an exception (a PSQLException, actually). I think the PSQLException was wrapped and ultimately serialised and sent to my client. My client doesn't have PSQLException in its classpath which seems to not be handled nicely in the guts of CORBA.

I diagnosed this by hooking a debugger in to the client application and putting break points on the constructors to NullPointerException. I was then able to see which class was being deserialised at the time the exception was thrown.

Good luck!

Share:
11,712
Tiny
Author by

Tiny

Just an orphan kid and have no more to say. Three things in general, cannot be avoided (at least I can never) Mother Mother-tongue Mother-land. They are always unique. I'm a family-less boy. My family was hunted leaving me all alone when my house targeted and deliberately set on a fire by a mob during a nonsense communal riot but I was survived by a rescue team with the help of firemen. As a survival, I didn't know whether it was my fortune or misfortune but when I recovered, the rescue team came to my home, one day. One of the members gave me a piece of paper in my hand in which the following text was written. lifeisnowhere. He asked me to read it carefully and I could hardly interpret the text as Life is now here, instead of Life is nowhere. All of them gave me a cute smile and went away and I decided to live peacefully and hopefully on their saying from then onwards and very soon. Because of this tragedy, I'm alone couldn't join a school but a curiosity to learn something made me a self-learner. I'm indeed a self-learner, so I'm likely not able to answer any questions on this site right now. In the field of computer science, my self-study mainly includes, QBASIC, C, C++, C#, VB, Java, JavaScript, PHP and a little about ASP.NET. Oracle, MySQL and MSSQL-Server with DBMS. and other theoretical subjects. I'm currently dealing with - Android and Java EE including Servlet, JSP-JSTL/EL (with Spring and Struts with ORM models JPA/Hibernate) and JSF.

Updated on July 25, 2022

Comments

  • Tiny
    Tiny almost 2 years

    I'm trying to create an enterprise web application in the following environment.

    • NetBeans 7.2.1
    • Glassfish Server 3.1.2 (containing the Servlet 3.0 API)
    • EJB 3.1
    • JPA 2.0
    • JSF 2.1
    • jdk 1.7
    • Oracle 10g

    I have created a Class Library (New Project -> Java -> Java Class Library) to place remote (javax.ejb.Remote) interface(s) which is to be implemented by a stateless session bean. The Class Library has been added to the class path of both of the modules (EJB and WAR).

    I have placed the remote interface and all the entity classes in the Class Library (I don't know this is the way).

    This works fine with interfaces annotated with @Local. It even works with @Remote but fails with the following exception when JPA involves, when I try to return a list of objects of an entity.

    java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is: org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe

    The full stacktrace.

    javax.ejb.EJBException: java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is: 
        org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream  vmcid: OMG  minor code: 11 completed: Maybe
        at remote.admin.sessionbeans._AdminRemoteSessionBeanRemote_Wrapper.getZones(remote/admin/sessionbeans/_AdminRemoteSessionBeanRemote_Wrapper.java)
        at managedbeans.ZoneBean.getZones(ZoneBean.java:27)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at javax.el.BeanELResolver.getValue(BeanELResolver.java:363)
        at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
        at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
        at com.sun.el.parser.AstValue.getValue(AstValue.java:138)
        at com.sun.el.parser.AstValue.getValue(AstValue.java:183)
        at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224)
        at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
        at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
        at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
        at javax.faces.component.UIData.getValue(UIData.java:731)
        at javax.faces.component.UIData.getDataModel(UIData.java:1798)
        at javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIData.java:484)
        at javax.faces.component.UIData.setRowIndex(UIData.java:473)
        at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:81)
        at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820)
        at javax.faces.component.UIData.encodeBegin(UIData.java:1118)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1755)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:722)
    Caused by: java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is: 
        org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream  vmcid: OMG  minor code: 11 completed: Maybe
        at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:267)
        at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.wrapException(Util.java:696)
        at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:259)
        at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
        at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:227)
        at remote.admin.sessionbeans.__AdminRemoteSessionBeanRemote_Remote_DynamicStub.getZones(remote/admin/sessionbeans/__AdminRemoteSessionBeanRemote_Remote_DynamicStub.java)
        ... 55 more
    Caused by: org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream  vmcid: OMG  minor code: 11 completed: Maybe
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:248)
        at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:95)
        at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.handleFullLogging(WrapperGenerator.java:387)
        at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.access$400(WrapperGenerator.java:107)
        at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator$2.invoke(WrapperGenerator.java:511)
        at com.sun.corba.ee.spi.orbutil.proxy.CompositeInvocationHandlerImpl.invoke(CompositeInvocationHandlerImpl.java:99)
        at $Proxy193.valuehandlerReadException(Unknown Source)
        at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:1022)
        at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1123)
        at com.sun.corba.ee.impl.encoding.CDRInputObject.read_value(CDRInputObject.java:531)
        at com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:2162)
        at com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2404)
        at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1224)
        at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:425)
        at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:308)
        at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:274)
        at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:1015)
        at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1123)
        at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:935)
        at com.sun.corba.ee.impl.encoding.CDRInputObject.read_value(CDRInputObject.java:525)
        at com.sun.corba.ee.impl.copyobject.ORBStreamObjectCopierImpl.copy(ORBStreamObjectCopierImpl.java:78)
        at com.sun.corba.ee.impl.copyobject.ORBStreamObjectCopierImpl.copy(ORBStreamObjectCopierImpl.java:65)
        at com.sun.corba.ee.impl.orbutil.copyobject.FallbackObjectCopierImpl.copy(FallbackObjectCopierImpl.java:69)
        at com.sun.corba.ee.impl.orbutil.copyobject.FallbackObjectCopierImpl.copy(FallbackObjectCopierImpl.java:59)
        at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.copyObject(Util.java:771)
        at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.copyResult(DynamicMethodMarshallerImpl.java:473)
        at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:243)
        ... 58 more
    Caused by: java.lang.NullPointerException
        at com.sun.corba.ee.impl.orbutil.ClassInfoCache$ClassInfo.<init>(ClassInfoCache.java:156)
        at com.sun.corba.ee.impl.orbutil.ClassInfoCache.get(ClassInfoCache.java:281)
        at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1097)
        at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:935)
        at com.sun.corba.ee.impl.encoding.CDRInputObject.read_value(CDRInputObject.java:525)
        at com.sun.corba.ee.impl.corba.TCUtility.unmarshalIn(TCUtility.java:289)
        at com.sun.corba.ee.impl.corba.AnyImpl.read_value(AnyImpl.java:605)
        at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:775)
        at com.sun.corba.ee.impl.encoding.CDRInputObject.read_any(CDRInputObject.java:482)
        at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.readAny(Util.java:452)
        at com.sun.corba.ee.impl.io.ValueHandlerImpl.read_Array(ValueHandlerImpl.java:639)
        at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:305)
        at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:274)
        at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:1015)
        ... 77 more
    

    The remote interface:

    @Remote
    public interface AdminRemoteSessionBeanRemote {
        public List<Zone>getZones();
        public int sum(int a, int b);
    }
    

    The stateless session bean implementing the above interface:

    @Stateless
    public class AdminRemoteSessionBean implements AdminRemoteSessionBeanRemote {
        @PersistenceContext(unitName="unit-name")
        private EntityManager entityManager;
    
        @Override
        public List<Zone> getZones() {
            return entityManager.createNamedQuery("Zone.findAll").getResultList();
        }
    
        @Override
        public int sum(int a, int b) {
            return a + b;
        }
    }
    

    The JSF managed bean:

    @ManagedBean
    @RequestScoped
    public class ZoneBean {
        @EJB//(mappedName="remote.admin.sessionbeans.AdminRemoteSessionBeanRemote")
        private AdminRemoteSessionBeanRemote adminRemoteSessionBeanRemote;
        private List<Zone>zones;
        private int sum;
    
        public ZoneBean(){}
    
        public List<Zone> getZones() {
            zones=adminRemoteSessionBeanRemote.getZones();
            return zones;
        }
    
        public void setZones(List<Zone> zones) {
            this.zones = zones;
        }
    
        public int getSum() {
            sum=adminRemoteSessionBeanRemote.sum(10, 15);
            return sum;
        }
    
        public void setSum(int sum) {
            this.sum = sum;
        }
    }
    

    The sum() method which just returns an int is just for demonstration. It works as it is.

    The problem occurs when an entity is involved as can be seen in the public List<Zone> getZones() method in the EJB that causes the exception as mentioned above.

    enter image description here

    AdminClassLibrary (the highlighted node in the snapshot) is the Class Library containing the remote interface and entity classes.

    How to return java.util.List<entities.Zone> via the getZones() method in the EJB session bean?

    I have clicked all the links shown by Google about this exception but couldn't come across the solution.


    The Zone entity.

    @Entity
    @Table(name = "ZONE", catalog = "", schema = "PROJECTDB")
    @XmlRootElement
    @NamedQueries({
        @NamedQuery(name = "Zone.findAll", query = "SELECT z FROM Zone z ORDER BY z.zoneId DESC"),
        @NamedQuery(name = "Zone.findByZoneId", query = "SELECT z FROM Zone z WHERE z.zoneId = :zoneId"),
        @NamedQuery(name = "Zone.findByZone", query = "SELECT z FROM Zone z WHERE z.zone = :zone")})
    public class Zone implements Serializable {
        private static final long serialVersionUID = 1L;
        // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
        @Id
        @Basic(optional = false)
        @NotNull
        @Column(name = "ZONE_ID")
        private BigDecimal zoneId;
        @Size(max = 50)
        @Column(name = "ZONE")
        private String zone;
        @OneToMany(mappedBy = "zoneId", fetch = FetchType.LAZY)
        private List<Country> countryList;
        @OneToMany(cascade = CascadeType.ALL, mappedBy = "zone", fetch = FetchType.LAZY)
        private List<ZoneCharge> zoneChargeList;
        @JoinColumn(name = "TRANSPORTER_ID", referencedColumnName = "TRANSPORTER_ID")
        @ManyToOne(fetch = FetchType.LAZY)
        private Transporter transporterId;
    
        //Getters and setters + constructor(s) + equals() + hashcode()
    }
    
  • Tiny
    Tiny about 11 years
    Thank you. The Zone entity already implements the java.io.Serializable interface. Hence, it should be serialized, I think. In my case, the client is the web module (WAR). The remote interface is present in the WAR and the EJB modules as well as in the Class Library. Sorry I didn't get.
  • Uday Shankar
    Uday Shankar about 11 years
    What i meant to say is that the entity Zone should be present in the WAR also. And to include entity Zone in WAR you have to place all the dependent jars too in WEB-INF/lib.
  • Tiny
    Tiny about 11 years
    I have copied the package containing the Zone entity in the web - war module but I got the same exception as mentioned in the question. It works with NetBeans 6.9.1, I have tried that doesn't mandate to place the remote interface(s) in a separate Class Library. I don't know how to build such applications with NetBeans 7.x. Thanks.
  • Uday Shankar
    Uday Shankar about 11 years
    Also check for the WAR if it contains the dependencies for Zone class such as ejb persistence jar.
  • Tiny
    Tiny about 11 years
    I'm still unable to solve the problem in question. I'm awarding the bounty to your answer but leaving it to unaccepted right now so that it is available in the unanswered question list and I might have better luck later to solve the problem, if someone could still expose something that I might be missing. Thank you very much for your effort.
  • Tiny
    Tiny over 10 years
    The question itself makes no sense at all. It already works fine. The problem was that I was deploying the EJB and the WAR modules alternatively. I was accustomed to doing this prior to NetBeans 7.x. Later on, I came to know the fact that only the application (denoted by a triangle) needs to be deployed. In which case it works fine with no modification to the application at all. Please clarify me once more though. We only need to deploy the application and not the EJB and the WAR modules (unless both the EJB and the client are separate). Is it correct?