title: Returning an entity via remote EJB results in - java.lang.NullPointerException at com.sun.corba.ee.impl.orbutil.ClassInfoCache$ClassInfo.<init>
body: <p>I'm trying to create an enterprise web application in the following environment.</p>
  
  <ul>
  <li>NetBeans 7.2.1</li>
  <li>Glassfish Server 3.1.2 (containing the Servlet 3.0 API)</li>
  <li>EJB 3.1</li>
  <li>JPA 2.0</li>
  <li>JSF 2.1</li>
  <li>jdk 1.7</li>
  <li>Oracle 10g</li>
  </ul>
  
  <p>I have created a Class Library (New Project -> Java -> Java Class Library) to place remote (<code>javax.ejb.Remote</code>) 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). </p>
  
  <p>I have placed the <strong>remote interface</strong> and all the entity classes in the Class Library (I don't know this is the way).</p>
  
  <p>This works fine with interfaces annotated with <code>@Local</code>. It even works with <code>@Remote</code> but fails with the following exception when JPA involves, when I try to return a list of objects of an entity.</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>The full stacktrace.</p>
  
  <pre><code>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.&lt;init&gt;(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
  </code></pre>
  
  <hr>
  
  <p>The remote interface:</p>
  
  <pre><code>@Remote
  public interface AdminRemoteSessionBeanRemote {
      public List&lt;Zone&gt;getZones();
      public int sum(int a, int b);
  }
  </code></pre>
  
  <p>The stateless session bean implementing the above interface:</p>
  
  <pre><code>@Stateless
  public class AdminRemoteSessionBean implements AdminRemoteSessionBeanRemote {
      @PersistenceContext(unitName="unit-name")
      private EntityManager entityManager;
  
      @Override
      public List&lt;Zone&gt; getZones() {
          return entityManager.createNamedQuery("Zone.findAll").getResultList();
      }
  
      @Override
      public int sum(int a, int b) {
          return a + b;
      }
  }
  </code></pre>
  
  <p>The JSF managed bean:</p>
  
  <pre><code>@ManagedBean
  @RequestScoped
  public class ZoneBean {
      @EJB//(mappedName="remote.admin.sessionbeans.AdminRemoteSessionBeanRemote")
      private AdminRemoteSessionBeanRemote adminRemoteSessionBeanRemote;
      private List&lt;Zone&gt;zones;
      private int sum;
  
      public ZoneBean(){}
  
      public List&lt;Zone&gt; getZones() {
          zones=adminRemoteSessionBeanRemote.getZones();
          return zones;
      }
  
      public void setZones(List&lt;Zone&gt; zones) {
          this.zones = zones;
      }
  
      public int getSum() {
          sum=adminRemoteSessionBeanRemote.sum(10, 15);
          return sum;
      }
  
      public void setSum(int sum) {
          this.sum = sum;
      }
  }
  </code></pre>
  
  <p>The <code>sum()</code> method which just returns an <code>int</code> is just for demonstration. It works as it is.</p>
  
  <p>The problem occurs when an entity is involved as can be seen in the <code>public List&lt;Zone&gt; getZones()</code> method in the EJB that causes the exception as mentioned above.</p>
  
  <p><a href="https://i.stack.imgur.com/cMNK3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cMNK3.png" alt="enter image description here"></a></p>
  
  <p><code>AdminClassLibrary</code> (the highlighted node in the <a href="https://i.stack.imgur.com/qbgpi.png" rel="nofollow noreferrer">snapshot</a>) is the Class Library containing the remote interface and entity classes.</p>
  
  <p>How to return <code>java.util.List&lt;entities.Zone&gt;</code> via the <code>getZones()</code> method in the EJB session bean?</p>
  
  <p>I have clicked all the links shown by Google about this exception but couldn't come across the solution.</p>
  
  <hr>
  
  <p>The <code>Zone</code> entity.</p>
  
  <pre><code>@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&lt;Country&gt; countryList;
      @OneToMany(cascade = CascadeType.ALL, mappedBy = "zone", fetch = FetchType.LAZY)
      private List&lt;ZoneCharge&gt; zoneChargeList;
      @JoinColumn(name = "TRANSPORTER_ID", referencedColumnName = "TRANSPORTER_ID")
      @ManyToOne(fetch = FetchType.LAZY)
      private Transporter transporterId;
  
      //Getters and setters + constructor(s) + equals() + hashcode()
  }
  </code></pre>