users@glassfish.java.net

Migration Apache Tomcat 6 project with context.xml to GlassFish

From: <glassfish_at_javadesktop.org>
Date: Fri, 24 Sep 2010 15:43:50 PDT

Hi. I have application originally developed for Tomcat. There is context.xml file in META-INF using for creating datasource. As was mentioned [here][1] glassfish has support of context.xml file from Tomcat. I tried to migrate this app to Glassfishv3. But I still, my app (actually Hibernate) can't find jdbc datasource resource via jndi.
There is code of context.xml from tomcat

    <?xml version="1.0" encoding="UTF-8"?>
    <Context privileged="true" antiResourceLocking="false"
    antiJARLocking="false" reloadable="true">
    <!-- JOTM -->
    
    <Transaction factory="org.objectweb.jotm.UserTransactionFactory"
        jotm.timeout="60" />
    <Resource name="jdbc/companydb" type="javax.sql.DataSource"
        driverClassName="org.hsqldb.jdbcDriver" maxIdle="2" maxWait="5000"
        url="jdbc:hsqldb:hsql://localhost:9002/companydb" username="sa"
        password="" maxActive="4" />
        
    </Context>
I redeployed app from tomcat without any changes to Glassfish.
There is exception from Glassfish

> java.lang.RuntimeException : org.hibernate.HibernateException: Could not find datasource jdbc/companydb

Have someone successfully switched to Glassfish from tomcat?
Thanks


  [1]: http://weblogs.java.net/blog/amyroh/archive/2007/05/context_webapp_1.html
[Message sent by forum member 'gamussa']

http://forums.java.net/jive/thread.jspa?messageID=483677