将带有 context.xml 的 Apache Tomcat 6 项目迁移到 GlassFish
我有最初为 Tomcat 开发的应用程序。 META-INF 中有 context.xml 文件用于创建数据源。正如此处提到的,glassfish 支持上下文。来自 Tomcat 的 xml 文件。我尝试将此应用程序迁移到 Glassfishv3。但我仍然,我的应用程序(实际上是 Hibernate)无法通过 jndi 找到 jdbc 数据源资源。 有来自 tomcat 的 context.xml 代码
<?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>
我从 tomcat 重新部署了应用程序,没有对 Glassfish 进行任何更改。 Glassfish 有一个例外
java.lang.RuntimeException:org.hibernate.HibernateException:找不到数据源 jdbc/companydb
有人成功从 tomcat 切换到 Glassfish 吗? 谢谢
I have application originally developed for Tomcat. There is context.xml file in META-INF using for creating datasource. As was mentioned here 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对此百分百肯定。但我从未尝试过 context.xml 支持。就我个人而言,我什至不会尝试重用
context.xml
,而只是在 GlassFish 下重新创建连接池。这将比写问题所花费的时间更少,并且将为您提供更好的管理支持:)I'm 100% positive about that. I never tried the
context.xml
support though. And personally I wouldn't even try to reuse acontext.xml
but just re-create the connection pool under GlassFish. This will take less time than the time spent to write your question and will give you better administration support :)