• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to deploy URLs like default URL provider in websphere

 
Greenhorn
Posts: 6
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem:
Our EJBs and WARs (in an EAR) have references to an URL.
I want to deploy this URL in JNDI one time and resolve all references by linking on the deployed URL.
This is the same concept as websphere default URL provider, but how do I do that in jboss?
Which mbean can I use?
Do I have to define a special service?
Right now, I resolved the link using the jboss.xml file and it works. But I do not want to repeat this in each EJB.

Thank you.

My code uses a URL like this:
...
public static final String AUDITLOG_PATH = "java:comp/env/AuditLogPath";
...
Object rep = new InitialContext().lookup(InternalJNDIRefererences.AUDITLOG_PATH);

In ejb-jar.xml:
...
<resource-ref>
<description></description>
<res-ref-name>AuditLogPath</res-ref-name>
<res-type>java.net.URL</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

In jboss.xml:

<enterprise-beans>

<session>
<ejb-name>xyz</ejb-name>
<resource-ref>
<res-ref-name>AuditLogPath</res-ref-name>
<resource-name>AuditLogPath</resource-name>
</resource-ref>
</session>
...
...
<resource-managers>
<resource-manager>
<res-name>AuditLogPath</res-name>
<res-url>file:///c:/audit/audit.log</res-url>;
</resource-manager>

</resource-managers>

This works:
UserTransaction (class: javax.transaction.UserTransaction)
+- env (class: org.jnp.interfaces.NamingContext)
| +- ejb (class: org.jnp.interfaces.NamingContext)
| | +- ConfigurationManager[link -> ConfigurationManager] (class: javax.naming.LinkRef)
| +- AuditLogPath (class: java.net.URL)

But I don't want to duplicate the URL definition in all WARs and EJBs jboss xml config.

How can I define something I can deploy in server/default/deploy ?
Which mbean can I reuse to deploy URLs like in websphere URL provider?
 
Marc Gagnon
Greenhorn
Posts: 6
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After looking around, I found that I can do this:
Add the following to conf/jboss-service.xml:
...
<mbean code="org.jboss.naming.JNDIBindingServiceMgr"
name="pm-urls:service=JNDIBindingServiceMgr">
<attribute name="BindingsConfig" serialDataType="jbxb">
<jndi:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jndi="urn:jboss:jndi-binding-service:1.0"
xs:schemaLocation="urn:jboss:jndi-binding-service:1.0 resource:jndi-binding-service_1_0.xsd"
>

<jndi:binding name="urls/jboss-home">
<jndi:value type="java.net.URL">http://www.jboss.org</jndi:value>;
</jndi:binding>

</jndi:bindings>
</attribute>
<depends>jboss:service=Naming</depends>
</mbean>

Then I see it in the global JNDI tree:
...
+- urls (class: org.jnp.interfaces.NamingContext)
| +- jboss-home (class: java.net.URL)

Which is fine.

As is, this is a working solution.

The only improvement I would like to see is:
How can I define the same behavior outside of the jboss-service.xml file?
The reason I'm asking is because I don't like the idea of adding to an existing configuration file.
When we install a new jboss from the distribution, I like to be able to unzip the whole package and then, only add the config file required.
If I keep the urls in the jboss-service.xml file, I cannot do this: I must open (manually or programmatically) the jboss-service.xml file and add the mbean section at the end.
I would prefer to simply copy a standalone file to do the same.
Any suggestion?
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if this is too late to be helpful, but I believe you can put that in any -service.xml (ex: myApp-service.xml) file and drop it in your deploy directory and have it deployed for JNDI lookup.

Of of these might be a helpful reference (pretty much the same thing in both):
http://docs.jboss.com/jbossas/guides/j2eeguide/r2/en/html_single/#ch3.jndibinding
http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.2/doc/Server_Configuration_Guide/Additional_Naming_MBeans-JNDI_Binding_Manager.html
 
Poop goes in a willow feeder. Wipe with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic