JBoss JNP as a standalone server and using resource configurations from tomcat context.xml


I have several modules that now need JNDI.
One of these modules works through Apache Tomcat, while the rest work autonomously as a J2SE application.
I managed to configure a module that uses tomcat without any problems, and I did a bit of searching and compiled that JBoss JNP could be a good stand-alone JNDI server to use.
I do not understand how I can reuse the resource definitions that I have already configured (for my module that runs through tomcat in the context.xml file).
Say I have the following resource defined in an XML file:

  <Resource name="jdbc/dataSource" auth="Container" type="javax.sql.DataSource" 
    driverClassName="com.mchange.v2.c3p0.ComboPooledDataSource"
    url="jdbc:sqlserver://******
    username="**" password="**"/>

And the corresponding code that runs JNP is as follows:

System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
System.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
NamingBeanImpl jnpServer = new NamingBeanImpl();
jnpServer.start();

InitialContext jdbc/dataSource?

+3

Source: https://habr.com/ru/post/1774783/


All Articles