我希望通过JBoss 7.1.1服务器上的JNDI在Spring中本地远程DataSource
这是我的配置
WEB-INF文件夹中的datasource-ds.xml :
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<datasource jndi-name="java:jboss/DBTest"
pool-name="dbtest-pool" enabled="true"
use-java-context="true" jta="true">
<connection-url>jdbc:mysql://localhost:3306/sample</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<!-- <driver>com.mysql.jdbc.Driver</driver> -->
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
</datasource>
</datasources>
的applicationContext.xml
<!-- Create DataSource Bean -->
<bean id="sampleDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:jboss/DBTest" />
</bean>
<bean id="sampleHibernateSessionFactory"
class="com.liferay.portal.spring.hibernate.PortletHibernateConfiguration">
<property name="dataSource">
<ref bean="sampleDataSource" />
</property>
</bean>
<bean id="sampeSessionFactory" class="com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl"
lazy-init="true">
<property name="sessionFactoryImplementor">
<ref bean="sampleHibernateSessionFactory" />
</property>
</bean>
<bean id="sampleTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="dataSource">
<ref bean="sampleDataSource" />
</property>
<property name="sessionFactory">
<ref bean="sampleHibernateSessionFactory" />
</property>
</bean>
例外:
Caused by: javax.naming.NameNotFoundException: DBTest -- service jboss.naming.context.java.jboss.DBTest
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:123)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryB
有人能告诉我配置有什么问题。 非常感谢