`

hibernate+tomca5.5t+JOTM 2.10 JTA配置

阅读更多

1,从官网上下载tomcat5.5,在tomcat下的conf/contenxt.xml中配置以下参数。

 

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
	
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

	
	<Resource name="zhang/jta1" 
		auth="Container"
		type="javax.sql.DataSource"
		factory="org.objectweb.jndi.DataSourceFactory"
		username="root" 
		password="123"
		driverClassName="com.mysql.jdbc.Driver"
		url="jdbc:mysql://localhost:3306/jta2?autoReconnect=true" 
		maxActive="30" maxIdle="30"/>
		
	<Resource name="zhang/jta2" 
		auth="Container"
		type="javax.sql.DataSource"
		factory="org.objectweb.jndi.DataSourceFactory"
		username="root" 
		password="123"
		driverClassName="com.mysql.jdbc.Driver"
		url="jdbc:mysql://localhost:3306/jta1?autoReconnect=true" 
		maxActive="30" maxIdle="30"/>
	

<Resource name="UserTransaction" auth="Container"
type="javax.transaction.UserTransaction"
factory = "org.objectweb.jotm.UserTransactionFactory"
jotm.timeout = "60"/>

	<!--<Transaction factory="org.objectweb.jotm.UserTransactionFactory"
jotm.timeout="60"/>-->
	

</Context>

 

2、从网上下载JOTM 2.10. 然后把jotm-2.0.10\lib下的包全部导入到F:\apache-tomcat-5.5.34\common\lib下面,同时加入数据库连接时所需要的jar包。

 

3、用下面附件里的ow_carol.jar来替换F:\apache-tomcat-5.5.34\common\lib下刚加入的ow_carol.jar。因为从JOTM\lib下导入的ow_carol.jar不支持jdk5.0下运行。我附件里的ow_carol.jar是对ow_carol源码用jdk1.5编译重新生成的。可以在JDK5.0下正常使用。

 

4、在F:\apache-tomcat-5.5.34\common\classes下面加入配置文件carol.properties。内容如下。这样JOTM将不会使用CAROL JNDI wrapper,从而可以避免类装载错误的发生。

 

# JNDI (Protocol Invocation)
carol.protocols=jrmp
# Local RMI Invocation
carol.jvm.rmi.local.call=true
# do not use CAROL JNDI wrapper
carol.start.jndi=false
# do not start a name server
carol.start.ns=false
# Naming Factory
carol.jndi.java.naming.factory.url.pkgs=org.apache.naming

 

5、项目中所有的配置都在下面附件中,具体内容可下载查看。

 

6、我在运行这个项目时在tomcat的lib下已经加入了jotm.jar,但是还是有问题。一直报错。后来我把jotm.jar在项目的webapp下的lib下面再加一份就正常了。可能是因为tomcat下加载时没有正常加载jotm包。

 

7,用的是mysql数据库。

 

8  我把tomcat下的apache-tomcat-5.5.34\common\lib下的包全传上来吧。

 

 

 

 

 

  • lib.rar (4.1 MB)
  • 下载次数: 85
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics