Announcement Announcement Module
Collapse
No announcement yet.
Migrating from glassfish to tomcat6 (jdbc jndi connection issues also) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    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.BeanCreationExce ption: 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:
    Code:
        
    <GlobalNamingResources>
        <!-- Editable user database that can also be used by
             UserDatabaseRealm to authenticate users
        -->
        <Resource name="UserDatabase" auth="Container"
    
                  type="org.apache.catalina.UserDatabase"
    
                  description="User database that can be updated and saved"
    
                  factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
    
                  pathname="conf/tomcat-users.xml" />
        <Resource 
           name="jdbc/qsdb" 
           type="net.sourceforge.jtds.jdbcx.JtdsDataSource"
           auth="Container" 
           max-pool-size="50"
           steady-pool-size="5"
           description="***"
           is-connection-validation-required="true"
           username="***"
           password="***"
           serverName="***"
           driverClassName="net.sourceforge.jtds.jdbcx.JtdsDataSource"/> 
    </GlobalNamingResources>
    applicationContext.xml (excerpt):
    Code:
       
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:p="http://www.springframework.org/schema/p"
    	xmlns:aop="http://www.springframework.org/schema/aop"	
    	xmlns:jee="http://www.springframework.org/schema/jee"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
    	<context:component-scan base-package="com.pivetal.qspeeq.rest" />
    	<context:mbean-export/>
    	<context:annotation-config/>
    	<context:load-time-weaver aspectj-weaving="on"/>
    	<context:property-placeholder location="classpath:META-INF/jpa.properties" />
    	<tx:annotation-driven mode="aspectj"/>
    	<aop:aspectj-autoproxy/>
    
    	<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>	
    		
    	<!-- The following beans define the interface with the QSQ database -->
    	<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
    	
    	<bean id="dataSourceQSQ" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="java:comp/env/jdbc/qsdb"/>
    	</bean>
    context.xml:
    Code:
    <Context path="" debug="5" reloadable="true" crossContext="true">
    
        <!-- Default set of monitored resources -->
        <WatchedResource>WEB-INF/web.xml</WatchedResource>
    	
        <!-- Uncomment this to disable session persistence across Tomcat restarts -->
        <!--
        <Manager pathname="" />
        -->
    
        <!-- Uncomment this to enable Comet connection tacking (provides events
             on session expiration as well as webapp lifecycle) -->
        <!--
        <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
        -->
    <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"
    useSystemClassLoaderAsParent="false"/>
    
    </Context>
    Please tell me if I am missing anything and I look forward to any feedback. Thank you people!
Working...
X