I'm trying to establish a connection using DataSource, and it's returning the following error:
Feb 08, 2016 8:15:03 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.2.Final
Feb 08, 2016 8:15:03 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.2.Final
Feb 08, 2016 8:15:03 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version (unknown)
Feb 08, 2016 8:15:04 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
Feb 08, 2016 8:15:04 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@2a556333, receiver=Remoting connection EJB receiver [connection=Remoting connection <b96b4f4>,channel=jboss.ejb,nodename=ingo-pc]} on channel Channel ID de71a44d (outbound) of Remoting connection 0f720e7c to localhost/127.0.0.1:8080
Feb 08, 2016 8:15:04 PM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 2.0.1.Final
javax.naming.NameNotFoundException: jboss/datasources/trabalhoes14bim -- service jboss.naming.context.java.jboss.exported.jboss.datasources.trabalhoes14bim
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:202)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "main" java.lang.NullPointerException
at col.cliente.ColCliente.consultaClientePorCPF(ColCliente.java:136)
at manager.cliente.UCCliente.cadastrarCliente(UCCliente.java:32)
at view.teste.Main.populate(Main.java:73)
at view.teste.Main.main(Main.java:277)
I'm not able to resolve, I retrieve DataSource
remotely from JNDI, as below:
public static void getConnection() {
DataSource ds = null;
try{
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.put(Context.PROVIDER_URL,"http-remoting://localhost:8080");
properties.put(Context.SECURITY_PRINCIPAL, "user");
properties.put(Context.SECURITY_CREDENTIALS, "password");
properties.put("jboss.naming.client.ejb.context", true);
Context init = new InitialContext(properties);
Context ctx = (Context) init.lookup("java:");
ds = (DataSource)ctx.lookup("jboss/datasources/trabalhoes14bim");
ctx.close();
con = ds.getConnection();
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I'm using the server - WildFly 10.0.0 Final - Eclipse Luna - MySQL 5.0.7