I have my datasource configured in tomcat\context.xml. I have deployed a bridge.war provided by Eclipse to get servletbridge environment.
I have developed another osgi bundle which contains servlet registation code and my aim is to do JNDI look up for datasource from this servlet bundle.
However I get
javax.naming.NoInitialContextException:Cannot instantiate class: org.apache.naming.java.javaURLContextFactory (root cause classnotfound for org.apache.naming.java.javaURLContextFactory)
when I try following code in my OSGI bundle
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/TestDB");
I have added catalina.jar in my osgi container an also as a dependency in my osgi bundle.
My launch.ini of bridge.war looks like this:
osgi.*=@null
org.osgi.*=@null
eclipse.*=@null
osgi.parentClassloader=ext
osgi.contextClassLoaderParent=ext
org.osgi.framework.system.packages.extra=org.apache.naming.java
Can someone help me with it?