[EJB/JBoss] - NPE on SecurityActions.getContextClassLoader in Container.ja
by mskonda
Let me explain what I'm trying to do:
I have a resource adapter which does EIS specific stuff (it creates an Object, registers callbacks with a EIS written in C++ client using JNI, awaits for callbacks from the C++ EIS).
When the message arrrives, the C++ client invokes the callback on the same object. The object then submits the message to MessageEndpoint (MDB) fetched from the MessageEndpointFactory.
Currently (for testing purposes), the MDB's listener callback doesn't have any implementation except printing out that the message is received.
Now, when a message is arrived(that is, a callback is invoked from the C++ client), the enpoint is created (if not already created) and the listener message is invoked:
| endpointListener.onMessage(event);
|
I get a NullPointerException:
| 2006-09-27 12:54:23,643 TRACE [org.jboss.invocation.local.LocalInvoker] Failed to invoke on mbean: j
| boss.j2ee:jndiName=MyLocalFlowMDB,service=EJB
| java.lang.NullPointerException
| at org.jboss.ejb.Container.invoke(Container.java:825)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
| at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.run(LocalInvoker.java:144)
| at java.security.AccessController.doPrivileged(Native Method)
| at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:163)
| at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
| at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:179)
| at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:165)
| at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
| at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.delivery(MessageEndpointInterceptor.java
| :237)
| at org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor.invoke(MessageEndpointInterceptor.java:1
| 17)
| at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:59)
| at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
| at $Proxy61.onMessage(Unknown Source)
| at com.cmi2.pats.source.connector.PatsJNIWorker.patsPushEvent(PatsJNIWorker.java:303)
| at com.cmi2.pats.source.connector.PatsJNIWorker.testEvent(PatsJNIWorker.java:485)
| at com.cmi2.pats.source.connector.PatsJNIWorker.javaHandleEODEvent(PatsJNIWorker.java:412)
| 2006-09-27 12:54:23,643 TRACE [org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor] MessageEndpo
| int MyLocalFlowMDB@1 delivery error
|
When I dig the code, it seems that a method (invoke) in the org.jboss.ejb.Container.java is throwing this exception(see line decorated in blue):
| public Object invoke(Invocation mi)
| throws Exception
| {
| ClassLoader callerClassLoader = SecurityActions.getContextClassLoader();
| long start = System.currentTimeMillis();
| Method m = null;
|
| boolean setCl = false;
| Object type = null;
| String contextID = getJaccContextID();
| try
| {
| if (!callerClassLoader.equals(classLoader))
| {
| setCl = true;
| SecurityActions.setContextClassLoader(this.classLoader);
| }
|
When I debug the session, the callerClassLoader is null hence NPE when compared with the existing DelegatingClassLoader.
Interesting scenario is - when I send a test message(before the callback occurs on the Obejct from c++ client), it all works perfect (I found that the callerClassLoader is UCL3 during my debug session). However, when the message is obtained via callback, the callerClassLoader is null. (and hence falling flat over the equal block).
What is that I am doing wrong? I have tried using the java 2 securtiy manager and security.policy, but couldn't succeed.
However, when I did the following hack, it all went fine:
| // check whether the caller's cl is null to avoid NPE
| if (callerClassLoader != null)
| {
| if (!callerClassLoader.equals(classLoader))
| {
| setCl = true;
| SecurityActions.setContextClassLoader(this.classLoader);
| }
| }
| else
| {
| // caller's cl is null, hence set the delegating cl loader of this class
| setCl = true;
| SecurityActions.setContextClassLoader(this.classLoader);
| }
| ..
| }
|
|
I'll appreciate if anyone can throw somelight on this subject.
PS: I was not quite sure where to post this message to. Let me know if it's wrong forum.
Thanks
Madhu
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974793#3974793
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974793
19 years, 6 months
[Installation, Configuration & Deployment] - Re: problem installing RMISecurityManager under jboss
by haplo_3
i manage to fix the problem by adding
set JAVA_OPTS=%JAVA_OPTS% -Djava.security.manager -Djava.security.policy=Security
to run.bat
now it seems i can't find my stub class since i set the security manager
i manully copied the stub to my client directory
any suggestions of how to set the codebase to find my stub?
i've tried
set JAVA_OPTS=%JAVA_OPTS% -Djava.rmi.server.codebase
but with no seccuss mayb i'm doing something wrong
p 28, 2006 4:46:31 PM sun.rmi.server.LoaderHandler loadClass
NER: http-0.0.0.0-8080-2: class "java.rmi.server.RemoteObject" found via defaultLoader, defined by null
:46:31,970 ERROR [STDERR] java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: VlabRequest_Stub
:46:31,986 ERROR [STDERR] at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
:46:31,986 ERROR [STDERR] at java.rmi.Naming.lookup(Unknown Source)
:46:32,002 ERROR [STDERR] at com.lo.simaserver.connector.NS2Connector.getPTTable(NS2Connector.java:40)
:46:32,002 ERROR [STDERR] at com.lo.simaserver.model.PacketQueueing.newSimulation(PacketQueueing.java:179)
:46:32,002 ERROR [STDERR] at com.lo.simaserver.clientIF.Simulation.newSimulation(Simulation.java:67)
:46:32,017 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
:46:32,017 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
:46:32,017 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
:46:32,033 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
:46:32,033 ERROR [STDERR] at org.openlaszlo.data.JavaDataSource.execute(JavaDataSource.java:449)
:46:32,033 ERROR [STDERR] at org.openlaszlo.data.JavaDataSource.getData(JavaDataSource.java:230)
:46:32,048 ERROR [STDERR] at org.openlaszlo.data.DataSource.getAsSWF(DataSource.java:98)
:46:32,048 ERROR [STDERR] at org.openlaszlo.servlets.responders.ResponderCache.respondImpl(ResponderCache.java:369)
:46:32,048 ERROR [STDERR] at org.openlaszlo.servlets.responders.Responder.respond(Responder.java:217)
:46:32,064 ERROR [STDERR] at org.openlaszlo.servlets.LZServlet._doGet(LZServlet.java:324)
:46:32,064 ERROR [STDERR] at org.openlaszlo.servlets.LZServlet.doGet(LZServlet.java:259)
:46:32,064 ERROR [STDERR] at org.openlaszlo.servlets.LZServlet.doPost(LZServlet.java:392)
:46:32,080 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
:46:32,080 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
:46:32,080 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
:46:32,095 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
:46:32,095 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
:46:32,095 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
:46:32,111 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
:46:32,111 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
:46:32,111 ERROR [STDERR] at javax.security.auth.Subject.doAsPrivileged(Unknown Source)
:46:32,127 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
:46:32,127 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:161)
:46:32,173 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:245)
:46:32,173 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
:46:32,189 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
:46:32,189 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
:46:32,189 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
:46:32,205 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
:46:32,205 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
:46:32,205 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
:46:32,220 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
:46:32,220 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
:46:32,220 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
:46:32,236 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
:46:32,236 ERROR [STDERR] at javax.security.auth.Subject.doAsPrivileged(Unknown Source)
:46:32,236 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
:46:32,252 ERROR [STDERR] at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:217)
:46:32,252 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:197)
:46:32,267 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
:46:32,267 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
:46:32,267 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
:46:32,283 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
:46:32,283 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
:46:32,283 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
:46:32,298 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
:46:32,298 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
:46:32,298 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
:46:32,314 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
:46:32,314 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
:46:32,330 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
:46:32,330 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
:46:32,330 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
:46:32,345 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
:46:32,345 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
:46:32,361 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
:46:32,361 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: VlabRequest_Stub
:46:32,361 ERROR [STDERR] at java.net.URLClassLoader$1.run(Unknown Source)
:46:32,377 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
:46:32,377 ERROR [STDERR] at java.net.URLClassLoader.findClass(Unknown Source)
:46:32,377 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
:46:32,392 ERROR [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
:46:32,392 ERROR [STDERR] at java.lang.ClassLoader.loadClassInternal(Unknown Source)
:46:32,392 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
:46:32,408 ERROR [STDERR] at java.lang.Class.forName(Unknown Source)
:46:32,408 ERROR [STDERR] at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
:46:32,408 ERROR [STDERR] at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
:46:32,423 ERROR [STDERR] at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
:46:32,423 ERROR [STDERR] at org.jboss.system.JBossRMIClassLoader.loadClass(JBossRMIClassLoader.java:91)
:46:32,439 ERROR [STDERR] at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
:46:32,439 ERROR [STDERR] at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
:46:32,455 ERROR [STDERR] at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
:46:32,455 ERROR [STDERR] at java.io.ObjectInputStream.readClassDesc(Unknown Source)
:46:32,455 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
:46:32,470 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(Unknown Source)
:46:32,470 ERROR [STDERR] at java.io.ObjectInputStream.readObject(Unknown Source)
:46:32,470 ERROR [STDERR] ... 61 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974791#3974791
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974791
19 years, 6 months