JBoss: JNDI binding values ​​in JBoss EAP 6 are similar to JNDIBindingServiceMgr

  • How to associate an arbitrary string with JNDI in JBoss EAP 6? I use do it through org.jboss.naming.JNDIBindingServiceMgr MBean in the previous version of EAP.

  • Is there something similar to org.jboss.naming.JNDIBindingServiceMgr in JBoss EAP 6?

  • We port applications from jboss-5.1.EAP to jboss-eap-6.1. We need to associate some things with JNDI so that applications can look up the values ​​of environment variables.

Many thanks.

+3
source share
3 answers

You can do the following:

standalone.xml:

<subsystem xmlns="urn:jboss:domain:naming:1.2"> <bindings> <simple name="java:global/user" value="newUser"/> </bindings> </subsystem> 

and in the context of spring:

 <bean class="java.util.Properties"> <constructor-arg> <map> <entry key="user"> <jee:jndi-lookup jndi-name="java:global/user" /> </entry> </map> </constructor-arg> </bean> 
+4
source

In the configuration of your application, you can have things in the deployment descriptor ejb-jar.xml, for example

 <javaee:env-entry> <javaee:description>JNDI logging context for this app</javaee:description> <javaee:env-entry-name>logback/context-name</javaee:env-entry-name> <javaee:env-entry-type>java.lang.String</javaee:env-entry-type> <javaee:env-entry-value>our-app-context</javaee:env-entry-value> </javaee:env-entry> 

or, if you prefer it on standalone.xml server, run

 <subsystem xmlns="urn:jboss:domain:naming:1.1"> <bindings> <simple name="my/jndi/key" value="MyJndiValue"/> </bindings> </subsystem> 

the latter (standalone.xml) is the JBoss 7.1 function, available in EAP 6.0. In JBoss AS 7.0, you must use a dummy application in accordance with this thread .

+2
source

What to do if simply:

 InitialContext ctx = new InitialContext(); ctx.bind("varName", "value"); 

If you use this code inside a JBoss instance, you can bind variables to jndi. Remember to use the correct format for varName to bind the variable in the required scope.

0
source

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


All Articles