Adding custom object to JNDI on Weblogic 10
Asked Answered
V

3

10

Is it possible to add a custom object (String or URL) to JNDI using Weblogic Server Administration Console (Weblogic 10.0) or by editing server's configuration file (config.xml)?

Vociferous answered 11/1, 2010 at 15:31 Comment(0)
L
6

I don't think so. Quoting Load objects in the JNDI tree:

Using the Administration Console, you can load WebLogic Server J2EE services and components, such as RMI, JMS, EJBs, and JDBC Data Sources, in the JNDI tree.

And indeed, I couldn't find a way to add a String or URL using the console.

AFAIK, the standard way is to put an env-entry in your deployment descriptor (web.xml, ejb-jar.xml):

<env-entry>
    <env-entry-name>string/foo</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>foobar</env-entry-value>
</env-entry>

<env-entry>
    <env-entry-name>url/bar</env-entry-name>
    <env-entry-type>java.net.URL</env-entry-type>
    <env-entry-value>http://foobar/</env-entry-value>
</env-entry>
Lindbom answered 11/1, 2010 at 16:46 Comment(2)
But if I put it in web.xml any change will require rebuild and redeploy. It's strange, that I can put JDBC configuration on server, so that changes don't require rebuilding, but I can't put my custom variables (eg. password to mail account, which can't be configured in mail session) there and need to keep them in my application.Vociferous
You should use plan.xml to update/overwrite the default values from the web.xmlCaylor
W
1

I have reached this with exactly the same problem. In Websphere, for example, I can add arbitrary parameters such as temporary directories, passwords, and other information to JNDI without having to recompile/rebuild the EAR.

I've searched for a while and seems Weblogic lacks this feature. What I did was write a helper class that first searches JNDI for a given configuration key, and if it doesn't find it then falls back to searching environment or system variables.

Perhaps this could be enhanced to also search for those properties prefixed by the application's name or context root, discovered at runtime, to avoid name clashes when multiple instances of the same EAR are deployed.

Whoredom answered 9/5, 2011 at 17:33 Comment(0)
R
1

You can but you will lose high availability if using cluster. See:http://docs.oracle.com/cd/E11035_01/wls100/jndi/jndi.html#wp475702

Reciprocate answered 19/8, 2014 at 11:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.