tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian <cm...@famiru.de>
Subject Re: JNDI initialization since Tomcat 8.0.1
Date Sun, 13 Apr 2014 15:32:38 GMT
> Is hibernate initialized via a <listener> in web.xml,  or where?

I don't know exactly how it is initialized. I use spring annotation configuration with a
javax.servlet.ServletContainerInitializer but I don't know, if hibernate gets loaded immediately.
Looking at the call stack, it seems that it gets initialized by a "ContextLoaderListener"
in an event called
"contextInitialized" that gets passed a javax.servlet.ServletContextEvent.
So I would say yes, it gets initialized by a listener.


> "path" attribute cannot be used in META-INF/context.xml file.

Thanks for the hint.


> The driver jar should be in one place, not both.

They are just in $CATALINA_BASE/lib and not bundled with the webapp.


>  a) classloading for drivers was changed at some point, to allow them
> in WEB-INF/lib

This might be the cause - if resources get registered later to allow loading the driver before.


>  b) different versions of Tomcat 8 use different versions of Apache
> Commons DBCP 2 pool

Explicitly using
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
in context.xml to use tomcat dbcp doesn't change the behavior.


> The visible part of JNDI depends on
> Thread.currentThread().getContextClassLoader() (aka TCCL). Any reason
> why TCCL may be wrong? (You aren't providing the full stacktrace)

The full stacktrace gets truncated by my IDE, because it is very long (the exception causes
3 other exceptions that get
printed with complete stacktrace).
I copied the thread dump at the statement directly after the exception got thrown:

"RMI TCP Connection(4)-127.0.0.1@1847" daemon prio=5 tid=0x42 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
	  at org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:117)
	  at
org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:115)
	  at
org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
	  at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
	  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
	  at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
	  at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
	  at
org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
	  at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
	  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
	  at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
	  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
	  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
	  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843)
	  at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:397)
	  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842)
	  at
org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
	  at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:67)
	  at
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:290)
	  at
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
	  at config.PersistenceConfig.entityManagerFactory(PersistenceConfig.java:35)
	  at config.PersistenceConfig$$EnhancerByCGLIB$$57464d4c.CGLIB$entityManagerFactory$0(<generated>:-1)
	  at config.PersistenceConfig$$EnhancerByCGLIB$$57464d4c$$FastClassByCGLIB$$58f7e9b4.invoke(<generated>:-1)
	  at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	  at
org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:326)
	  at config.PersistenceConfig$$EnhancerByCGLIB$$57464d4c.entityManagerFactory(<generated>:-1)
	  at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
	  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	  at java.lang.reflect.Method.invoke(Method.java:483)
	  at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
	  at
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
	  at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094)
	  at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989)
	  at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
	  at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
	  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
	  at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
	  - locked <0xec7> (a java.util.concurrent.ConcurrentHashMap)
	  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
	  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
	  at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)
	  at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
	  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
	  - locked <0xec8> (a java.lang.Object)
	  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
	  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
	  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
	  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4737)
	  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5159)
	  - locked <0xe8d> (a org.apache.catalina.core.StandardContext)
	  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
	  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
	  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:697)
	  at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1646)
	  at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
	  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	  at java.lang.reflect.Method.invoke(Method.java:483)
	  at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	  at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	  at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)
	  at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
	  at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
	  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	  at java.lang.reflect.Method.invoke(Method.java:483)
	  at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	  at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	  at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)
	  at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
	  at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
	  at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)
	  at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828)
	  at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
	  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	  at java.lang.reflect.Method.invoke(Method.java:483)
	  at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
	  at sun.rmi.transport.Transport$1.run(Transport.java:178)
	  at sun.rmi.transport.Transport$1.run(Transport.java:175)
	  at java.security.AccessController.doPrivileged(AccessController.java:-1)
	  at sun.rmi.transport.Transport.serviceCall(Transport.java:174)
	  at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:557)
	  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:812)
	  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:671)
	  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	  at java.lang.Thread.run(Thread.java:744)




> Maybe you can try debugging, with a breakpoint in org.apache.naming.* classes?

I don't know where I should look. I started looking at the failing lookup() statement.
org.apache.naming.java.javaURLContextFactory#getObjectInstance() calls ContextBindings.isThreadBound()
and
ContextBindings.isClassLoaderBound() - both return false.
In tomcat 8.0.0-RC10 ContextBindings.isThreadBound() returns true and the name resolution
succeeds.

Maybe this directs to the cause of the problem.

Regards,
Christian

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


Mime
View raw message