我一直在试图弄清楚如何配置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-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
答案 0 :(得分:0)
这似乎是我的pom中添加冲突类的依赖问题。我能够从类路径中删除冲突的类并修复解决我的问题。