Attempting to setup a camel route to test a database locally with EAP but face exception - javax.naming.NamingException: scheme java not recognized
Issue
- I am attempting to setup a camel route to test a database locally that will port my eap/fuse servers.
-
We define our datasources as java:/datasourceSome in eap so the jndi entry is
in my camel context. -
Then in my junit test I define the data sources as
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
jndi.bind("ConnectionToSql", new ConnectionToSqlBean());
DriverManagerDataSource ds = new DriverManagerDataSource(); ds.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); ds.setUrl("jdbc:sqlserver://somehost:1433;databaseName=testDb");
ds.setUsername("user");
ds.setPassword("passwd");
jndi.bind("java:/datasourceSome", ds);
return jndi; }
- Initially I was getting javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or in an application resource file: java.naming.factory.initial. So I added Jndi.properties file and this line
java.naming.factory.initial=org.apache.camel.util.jndi.CamelInitialContextFactory
- now I am getting javax.naming.NamingException: scheme java not recognized
Caused by: javax.naming.NamingException: scheme java not recognized
at org.apache.camel.util.jndi.JndiContext.lookup(JndiContext.java:218)
at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
Environment
- Red Hat Fuse
- 7.3.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.