gpt4 book ai didi

mysql - 如何配置Tapestry5、Hibernate、Tomcat7、JNDI、Mysql

转载 作者:行者123 更新时间:2023-11-29 03:39:23 25 4
gpt4 key购买 nike

我一直在尝试弄清楚如何配置 Tapestry5、Hibernate、Tomcat7 和 Mysql,但一直无法让它工作。有人可以告诉我我做错了什么吗?

首先,Tapestry 已经配置为可以毫无问题地使用 hibernate 和 jetty,我在使用 Tomcat7 设置连接池时遇到了困难

到目前为止我所拥有的。

MyApp 配置

hibernate .cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/rolemanager</property>
<property name="hbm2ddl.auto">create</property>
<property name="hibernate.show_sql">false</property>
</session-factory>
</hibernate-configuration>

myapp/Web Pages/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>rolemanager Tapestry 5 Application</display-name>
<context-param>
<!-- The only significant configuration for Tapestry 5, this informs Tapestry
of where to look for pages, components and mixins. -->
<param-name>tapestry.app-package</param-name>
<param-value>com.mycompany.rolemanager</param-value>
</context-param>
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<resource-ref>
<description>MyDatabase Description</description>
<res-ref-name>jdbc/rolemanager</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

</web-app>

Tomcat 配置

Tomcat7/conf/server.xml

<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/rolemanager" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="test" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/rolemanager"/>

</GlobalNamingResources>

Tomcat7/conf/context.xml

<Context>

<!-- 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" />
-->

<WatchedResource>WEB-INF/web.xml</WatchedResource>
<ResourceLink global="jdbc/rolemanager" name="jdbc/rolemanager" type="javax.sql.DataSource"/>

</Context>

控制台错误

我收到以下控制台错误。

SEVER: Parse error in application web.xml file at jndi:localhost/WEB-INF/web.xml
java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addResourceRef

最佳答案

这似乎是我的 pom 中添加冲突类的依赖项的问题。我能够从我的类路径中删除冲突的类并修复解决我的问题。

关于mysql - 如何配置Tapestry5、Hibernate、Tomcat7、JNDI、Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16284005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com