[jboss-user] [Datasource Configuration] - Cannot lookup datasource remotely in Jboss 7.10 final
Bob Kung
do-not-reply at jboss.com
Wed Mar 14 23:59:43 EDT 2012
Bob Kung [https://community.jboss.org/people/r4_1314] created the discussion
"Cannot lookup datasource remotely in Jboss 7.10 final"
To view the discussion, visit: https://community.jboss.org/message/723893#723893
--------------------------------------------------------------
hi, I am newly to Jboss 7 and I am testing remote lookup XA datasource from JNDI but no luck. Admittedly, this is not a recommend solution for connection usage remotely, however I just do a testing since it should provide in the previous jboss version.
Here is my datasource configuration.
<xa-datasource jndi-name="java:jboss/exported/datasources/abc" pool-name="abc" enabled="true" use-java-context="false" use-ccm="false">
<xa-datasource-property name="ServerName">
localhost
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
abc
</xa-datasource-property>
<driver>mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<xa-pool>
<min-pool-size>0</min-pool-size>
<max-pool-size>3</max-pool-size>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>true</wrap-xa-resource>
</xa-pool>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
<background-validation-millis>0</background-validation-millis>
</validation>
<statement>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
And here is my client
public class DataSourceClient {
// *************** DATASOURCE *************************
// public final static String DATASOURCE = "java:/datasources/abc";
public final static String DATASOURCE = "datasources/abc";
private DataSource myDS;
public DataSource init(Context ctx) throws NamingException,
JMSException {
return myDS = (DataSource) ctx.lookup(DATASOURCE);
}
public void test() throws SQLException{
String sql = "INSERT INTO test values (null,'xxx');";
Connection con = myDS.getConnection();
Statement stat = con.createStatement();
stat.execute(sql);
stat.close();
con.close();
}
public static void main(String[] args) throws Exception {
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
env.put(Context.PROVIDER_URL, "remote://10.1.24.103:4447");
env.put(Context.SECURITY_PRINCIPAL, "user");
env.put(Context.SECURITY_CREDENTIALS, "user");
InitialContext remoteContext = new InitialContext(env);
DataSourceClient qs = new DataSourceClient();
qs.init(remoteContext);
qs.test();
}
}
When I trigger client I hit the following error.
ERROR: java.io.EOFException
Exception in thread "main" javax.naming.NamingException: Failed to lookup [Root exception is java.io.NotSerializableException: org.jboss.jca.core.connectionmanager.pool.strategy.OnePool]
I had googled a lot with no luck. And I have another confuse is that then use-java-context marked to false, it should no need to start the jndi name with "java:", however, server can't start when I removed the prefix and get similar error message "jndi name should start with java: or java:jboss".
Can somebody tell me whether the jboss 7 support remotely datasource? if so can somebody point out whats the problem of my client, tons thanks!
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/723893#723893]
Start a new discussion in Datasource Configuration at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120314/98b56295/attachment.html
More information about the jboss-user
mailing list