tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Non-visible URLContextFactory from RMI/JMX thread
Date Fri, 17 Feb 2017 19:07:58 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

All,

I'm writing an MBean for a component in one of my applications that
I'd like to be able to "reload" through JMX. The "reload" operation
basically re-loads some stuff from a relational database accessed
through a Tomcat-provided DataSource.

The problem is that when I call my "reload" method, which ultimately
uses JNDI to get the JDBC DataSource, I get a ClassNotFoundException:

2017-02-17 13:59:41,904 [RMI TCP Connection(5)-10.0.1.28] FATAL
my.great.ReloadableClass - Could not load DiagnosisEngine.
ServiceException: Cannot obtain database connection
	at ReloadableBean.reload(ReloadableBean.java:159)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:62)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
	at sun.reflect.GeneratedMethodAccessor448.invoke(Unknown Source)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
	at
com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBean
Introspector.java:112)
	at
com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBean
Introspector.java:46)
	at
com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java
:237)
	at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
	at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
	at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBea
nServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:80
1)
	at
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionI
mpl.java:1468)
	at
javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionIm
pl.java:76)
	at
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RM
IConnectionImpl.java:1309)
	at
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIC
onnectionImpl.java:1401)
	at
javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.j
ava:829)
	at sun.reflect.GeneratedMethodAccessor483.invoke(Unknown Source)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
	at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.j
ava:826)
	at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTra
nsport.java:683)
	at java.security.AccessController.doPrivileged(Native Method)
	at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.ja
va:682)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.jav
a:1142)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.ja
va:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: javax.naming.NoInitialContextException: Cannot instantiate
class: org.apache.naming.java.javaURLContextFactory [Root exception is
java.lang.ClassNotFoundException:
org.apache.naming.java.javaURLContextFactory]
	at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:31
3)
	at javax.naming.InitialContext.init(InitialContext.java:244)
	at javax.naming.InitialContext.<init>(InitialContext.java:192)
	at
com.chadis.web.util.DiagnosisEngineHelper.getConnection(DiagnosisEngineH
elper.java:136)
	... 39 more
Caused by: java.lang.ClassNotFoundException:
org.apache.naming.java.javaURLContextFactory
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at
com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:7
2)
	at
com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:6
1)
	at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:672)
	... 43 more


I'm using Tomcat 8.0.41 on Oracle Java 8. I happen to be using
VisualVM as the client, but I don't believe the client makes any
difference.

I haven't yet checked to see if calling the reload() operation through
the JMXProxyServlet will work. I suspect it will work that way.

Can anyone think of a good way to get this to work? From my code, I
can probably set the CCL to the current class's ClassLoader and then
set it back after the operation, but that seems ugly. It also probably
won't work under a SecurityManager.

Any ideas?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYp0oOAAoJEBzwKT+lPKRYgLoP/AroGJSApQ5eql3LaiLjCyYs
rSm1CWHqvFmMAoDAPHIVGkBdCqanaN0oLfCUrz0HyKn9oQSNBartyo/B5YvCFKsx
ZIqmlMnH/1oax6UFRmUGu3U2t3qZftU7M7ORCKNP+fzjvPFkaueV7SAN7OEUDhG3
I+yl51/lmB38Qa0a+0PU7xr4ThZ52BcMHvQKCBGf7zejSJLnEt3BFZHjrqNaffga
m9JZ5BAmoFFEhWjK7Ih+CjbUMyHciAppz2oqdatiIxhcaXseBoaMU7WZ1twfDnpy
0qZf8OSf4Ub2RyAt8pRf2K+XctwG6Bvb5A3+O51Xo97VcluT+vvTfmlBTZVPx3EA
cjDz3MkApfXJuSwG1okR1hR92czAw2NaTPGnCVGhWo4QS6wHfLunofoDm5bKYTsT
0PNDZTG/432/pVDegyDlXmwwJ4ykOyTzXgmvG0UaCspcFijERVaBo4limETZTMmV
nJGI779hY8omMrOzN9PFpmVILpdqAoskuzFCcmWiKet/um3jv9IeClJ4eGS2YbQY
ZPVmAzfJnFVFEkKmIuTyPfWPKkL02XxammVSixMuj8t1kC8jW25/nj9h0xeb5wl8
zyraG9TN5H8JQw8R1rtbmTrSnkMMkBEOunEVdujWKoGxpQWMEVuY8bi64gchewGj
G7h7nn1/NPBfnK1yE7E6
=dhSA
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message