users@glassfish.java.net

Re: Migration Apache Tomcat 6 project with context.xml to GlassFish

From: Amy Roh <amy.roh_at_oracle.com>
Date: Fri, 24 Sep 2010 17:15:33 -0700

glassfish_at_javadesktop.org wrote:
> 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?
>

Have you defined the jdbc/companydb resource in domain.xml? In addition
to the context.xml, you still need to create jdbc resource (asadmin
create-jdbc-resource) for GlassFish to be aware of this resource.

Amy

> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>