问题
I'am trying to migrate websphere 7 to JBoss 7.1 and i have several problem to configure my datasource, here is my whole config(database is oracle 10g) :
Jboss deployement looks fine
JBAS010400: Bound data source [jboss/datasources/xx3_oracle_tu_2]
My standalone-full.xml :
<datasources>
<datasource jndi-name="java:jboss/datasources/xx3_oracle_tu_2" pool-name="xx3_oracle_tu_2" enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:@************:1521:*****</connection-url>
<driver>oracle</driver>
<pool>
</pool>
<security>
<user-name>UD1XXBD</user-name>
<password>*******</password>
</security>
</datasource>
</datasources>
<driver name="oracle" module="com.oracle.ojdbc">
<driver-class>oracle.jdbc.OracleDriver</driver-class>
</driver>
Seems ok about oracle driver:
JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 1.0)
Here is my bean in spring xml file :
<bean id="datasource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:jboss/datasources/xx3_oracle_tu_2"/>
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop>
<prop key="java.naming.provider.url">remote://localhost:4447</prop>
<prop key="java.naming.security.principal">user</prop>
<prop key="java.naming.security.credentials">******</prop>
<prop key="remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED">false</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.ejb.client.naming</prop>
</props>
</property>
</bean>
The only error i have is :
Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: jboss/datasources/xx3_oracle_tu_2 -- service jboss.naming.context.java.jboss.exported.jboss.datasources.xx3_oracle_tu_2
On Jboss web admin console, no problems datasource appears. Also with jboss-cli script and this command line, everything seems ok :
jboss-cli.bat -c --command=/subsystem=datasources/data-source=xx3_oracle_tu_2:test-connection-in-pool
{
"outcome" => "success",
"result" => [true]
}
I don't understand why this command line does not work :
jboss-cli.bat -c --command=/subsystem=datasources/data-source=java\:jboss\/datasources\/xx3_oracle_tu_2:test-connection-in-pool
Am i missing something about JBoss 7.1 JNDI configuration ?
Thanks by advance for your help !
EDIT : don't declare jboss/datasources and declare it like this in your standalone file and jboss-web file:
java:/xx3_oracle_tu_2
回答1:
AFAIK That command doesn't accept full JNDI references, it expects a datasource name.
You can view your datasource names with
/subsystem=datasources:read-resource(recursive=true)
Edit: ok, so the problem you have is with remote lookup.
If you look at this thread, you can see that unfortunately:
Remote lookup of datasources is not supported in AS7.
Edit2: so you're not doing a remote lookup after all.
Both this:
<jee:jndi-lookup id="datasource"
jndi-name="java:jboss/datasources/xx3_oracle_tu_2"/>
and this:
<bean id="datasource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:jboss/datasources/xx3_oracle_tu_2" />
</bean>
should do. JNDI env property you should not use, that's meant for remote lookups.
来源:https://stackoverflow.com/questions/21261676/jboss-7-1-declare-datasource-and-access-via-jndi