• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Migrating from glassfish to tomcat6 (jdbc jndi connection issues also)

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

Just to prefix this a little - I still don't have a complete understanding of all this tech so please bear with me!

The current setup is that we deploy a non-dynamic web project (which uses Terracotta and ehcache with RESTful web services) to a glassfish web container. The application is governed by spring and everything is weaved in accordingly as and when required. The database that is being written too is ms sql server 2005
The process to build, deploy and remote debug takes an age at around ~8mins (260seconds to deploy alone) and I have had it! My last project was a dynamic web project and not being able to develop on the fly and deploy (almost) instantly is a right nightmare.

So the first question before I go down the tomcat6 route, is there any reason why the project is not a dynamic web project with full hot-deployment facilities? If not, is it a simple case of re-importing everything into a new dynamic web project?

I would still like to use tomcat as well - it seems far lighter and faster than glassfish and we are not using EJB or anything complicated (other than above which may inturn use something like this however I am unaware of that at this stage).
So as I understand it I can set tomcat to recognise new complied files using this guide. Therefore I have to successfully deploy the app first then I can set my eclipse ide to save the compiled class files to the tomcat location.

On deployment I get the following error:
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceQSQ' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

I think I may have confused setup's between tomcat versions, so I have attached my setup as guided by the web.

Files not changed:
web.xml

Files Changed:
server.xml:


applicationContext.xml (excerpt):


context.xml:


Full stack trace:


11:46:55,544 INFO DefaultContextLoadTimeWeaver:72 - Found Spring's JVM agent for instrumentation
11:47:03,758 INFO DefaultListableBeanFactory:421 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@57ae58: defining beans lots of beans....]; root of factory hierarchy
11:47:03,759 INFO DefaultContextLoadTimeWeaver:117 - Removing all registered transformers for class loader: org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader
11:47:03,762 ERROR ContextLoader:215 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'QSQTerminationConverter': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.***.rest.db.CFGTerminationInstancesDao com.***.rest.qsqdb.QSQTerminationConverter.cfgTerminationInstancesDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CFGTerminationInstancesDao': Injection of persistence methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactoryQSQ' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'dataSourceQSQ' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceQSQ' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceQSQ' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceQSQ' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:947)
at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:701)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:377)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:593)
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:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)



Please tell me if I am missing anything and I look forward to any feedback. Thank you people!

EDIT: changed title in the hope of some response!
 
samuel smith
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry to bump - this task is very annoying and I would like to get some feedback in motion!

Is there anything I am missing or any forum rules I have objected? I guess it's fairly specialist but I would like to know if no replies is down to my own ignorance! Cheers!
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't used Spring, so don't have any internal details of the bean configs. Looks like you are running into a NameNotFoundException. Your bean configuration looks like:



Try changing the jndi name to use non ENC namespace:

 
samuel smith
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply.

I tried as you suggested to no effect.
class JndiObjectFactoryBean (in version 2.5.6 of spring that I am using) has a nice little thing which check's if it is prefixed, if not it prefixes.

I am wondering if something is wrong with the factory bean and tomcat not using it (and using something else by default?)
It just seems like it is completely ignoring the "jndiName" setting defined in the app context...

I have tried with the following setup (and yay! the same error ):

web.xml


server.xml


Please let me know if you need any further information you need from me - Cheers
 
Saloon Keeper
Posts: 28706
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't reply yesterday because your display name seemed to be a little close to the limit of what we prefer here.

I looked at my projects and superficially, you're doing everything right.

My best guess is that your resource definition in server.xml isn't being honored for some reason. Since JNDI will choke at the highest undefined level, failure to register java:comp/env/jdbc/qspeeqdb would fail finding "jdbc" if there were no other entries successfully defined under jdbc.

The most likely causes for the resource definition to fail is if it's defined in the wrong place in server.xml or if there's a comment definition that's masking it.

Unfortunately, server.xml is not validated, so a misplaced definition wouldn't be considered as an error, it would simply be silently ignored.
 
samuel smith
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok apologies for my screen name, I like my anonymity however if that is not suitable for this forum then please inform me what to correct and I will.

I have completely cut back server.xml to the following with the same issue:


Any further thoughts? Could it be anything to do with the factory class? I have seen issues with jar files being missing however I have checked (and copied too) the following locations all spring jar files and also the jtds database connection jar:

${CATALINA_BASE}/webapps/qsrest/WEB-INF/lib/
${CATALINA_HOME}/usr/share/tomcat6/lib

I have not included the files within the .war file however the application is already deployed (I believe) and therefore I think placing in that directory for the webapp is sufficient. Let me know if not!

Thanks for your time everyone.
 
Tim Holloway
Saloon Keeper
Posts: 28706
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm pretty paranoid myself, although privacy is a lost cause these days. However, we find that having people use real names keeps things more professional.

We are professional here. Can't you tell by our mascot?

I can't spare the time to do a line-by-line analysis of your server.xml right now, but as far as the drivers go, the rules are as following:

1. The connection pool class must be in the TOMCAT_HOME/lib directory.

2. The JDBC driver must also be in the TOMCAT_HOME/lib directory.

These strictures are because you're defining resources that are server-wide, and therefore must be in the base classpath for the server. Each webapp has its own additional classpath components, and these are not visible outside of that webapp.

Additionally, the pool and driver classes must NOT be included in your WAR. If you have them in both places, you'll get conflicts because parts of the system will be using one copy of the classes and other parts will be using the other.

If the resource failed to be constructed, there should be some sort of message in the TOMCAT logfiles. Usually you can find these messages in catalina.out, but sometimes stuff like this goes to the Tomcat localhost logfile.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

b land wrote:Ok apologies for my screen name, I like my anonymity however if that is not suitable for this forum then please inform me what to correct and I will.



Our naming policy page explains the display name policy in detail. Please take some time to read that and fix your display name accordingly. Thank you.

 
samuel smith
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that feedback, very much appreciated.

Ok after a bit of fiddling I have not made any progress, other than a bit of elimination.

I have tried removing all the spring jar files from the webapp lib dir and placing in the tomcat dir with no change to the status.
I also tried clearing out the tomcat dir and adding required jar's one by one resulting in the same issue.



Is there any other suggestions to this problem?
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

samuel smith wrote:
Ok after a bit of fiddling I have not made any progress, other than a bit of elimination.



Have you tried removing the net.sourceforge.jtds.jdbcx.JndiObjectFactoryBean factory and instead using something like this https://coderanch.com/t/489828/Tomcat/JDBC-Exception-JNDI-lookup#2205520
 
samuel smith
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:

samuel smith wrote:
Ok after a bit of fiddling I have not made any progress, other than a bit of elimination.



Have you tried removing the net.sourceforge.jtds.jdbcx.JndiObjectFactoryBean factory and instead using something like this https://coderanch.com/t/489828/Tomcat/JDBC-Exception-JNDI-lookup#2205520



Interesting option but I was trying to keep the application exactly the same (to limit potential differences with different web containers - we currently don't have good full intergration tests as of yet).

Regardless, I gave it a go just to get something going - however I am now getting ClassNotFound error, which is probably a lack of a jar file. Can you please direct me to this jar file or correct me if I read the wrong part of the thread - cheers!
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the entire ClassNotFoundException stacktrace and your latest config file contents.
 
samuel smith
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure and sorry for the school boy error of not adding ;)

Stack trace


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'QSQTerminationConverter': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pivetal.qspeeq.rest.db.CFGTerminationInstancesDao com.pivetal.qspeeq.rest.qsqdb.QSQTerminationConverter.cfgTerminationInstancesDao; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory] for bean with name 'dataSourceQSQ' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:308)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:947)
at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:701)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:377)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:593)
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:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)



However I have realised this is a silly error -simply because I only changed the applicationContext and not the correctly suggested Resource factory.

Trying with everything as above except the the resource factory within server.xml results in the same no jdbc error.
 
samuel smith
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry to bump and seem pushy - does anyone have any further information regarding this issue? Thanks!
 
samuel smith
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry guys, just wondering if this got lost. Any further input?
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't looked further into this yet. But I would suggest that you take a step back and try to narrow it down. For example, I would first try to get a simple datasource deployed without any Spring related things. Once that works, I would then try to introduce Spring into picture (if at all that's required) and see if that creates an issue.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic