0 Replies Latest reply on Oct 3, 2007 3:53 AM by Karen Lease

    NullPointerException while deserializing response from remot

    Karen Lease Newbie

      Hi all,
      I have ejb client code which is being called via JNI from a third-party application (an xml editor). In some cases, I get the following error when I call a remote EJB (it happens on several different ones):

      Caused by: java.lang.NullPointerException
       at org.jboss.invocation.MarshalledValueInputStream.resolveClass(MarshalledValueInputStream.java:101)
       at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1538)
       at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
       at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
       at org.jboss.invocation.MarshalledValue.get(MarshalledValue.java:91)
       at org.jboss.invocation.unified.interfaces.UnifiedInvokerProxy.invoke(UnifiedInvokerProxy.java:195)
       at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
       at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
       at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
       at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
       at org.jboss.proxy.ejb.StatefulSessionInterceptor.invoke(StatefulSessionInterceptor.java:121)
       at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
       at $Proxy3.getMetaData(Unknown Source)
       at com.XXXX (my client code method)

      After doing various experiments, I figured out that the problem is that the context class loader is not set on the thread when this happens. I have filed this as a bug with xml editor provider.

      This problem occurs using jboss-4.2.1.GA (jbossall-client.jar) and the java VM used by the JNI is 1.5.0_04-b05, running on Windows XP Pro.
      I wasn't having this problem with jboss 4.0.4.GA and I haven't changed my client-side code or the xml editor version since then.

      Wouldn't it be reasonable for MarshalledValueInputStream to fall back to the parent classloader if no context classloader is set ?
      The java doc for the getContextClassLoader() method in java.lang.Thread says:
      Returns the context ClassLoader for this Thread. The context ClassLoader is provided by the creator of the thread for use by code running in this thread when loading classes and resources. If not set, the default is the ClassLoader context of the parent Thread

      I'm not sure this means that the VM should do this (in which case the bug is in my java and not jboss), or whether callers of this method should handle the case where it returns null.

      Thanks in advance for any advice,