[jboss-user] [JNDI and Naming] - Deploy resource-env-ref on Jboss 5.1

Francois Richard do-not-reply at jboss.com
Fri Sep 10 21:50:59 EDT 2010


Francois Richard [http://community.jboss.org/people/gazz35] created the discussion

"Deploy resource-env-ref on Jboss 5.1"

To view the discussion, visit: http://community.jboss.org/message/561346#561346

--------------------------------------------------------------
Hi,

I'm trying to deploy on JBoss 5.1 an EAR which is usually running on a websphere server6.0. The only WAR of the EAR use a resource-env-ref :


I give you a quick look of my configuration :

web.xml
<resource-env-ref id="ResourceEnvRef_1234792399813">
        <description>
        </description>
        <resource-env-ref-name>spring/fileConfiguration</resource-env-ref-name>
        <resource-env-ref-type>java.lang.String</resource-env-ref-type>
</resource-env-ref>


jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <resource-env-ref>
        <resource-env-ref-name>spring/fileConfiguration</resource-env-ref-name>
        <jndi-name>spring/fileConfigurationName</jndi-name>
    </resource-env-ref>
</jboss-web>


Code :
String jndiName = "java:comp/env/spring/fileConfiguration";
                Context jndiContext = new InitialContext();
                Reference reference = (Reference) jndiContext.lookup(jndiName);
                RefAddr addr = reference.get(0);
                String applicationContextPath = addr.getContent().toString();
                applicationContext = new ClassPathXmlApplicationContext(
                        applicationContextPath);


To create my resource, I'm using this example :
 http://community.jboss.org/docs/DOC-12811 http://community.jboss.org/wiki/LocalOnlyContextFactory

And I add this line on the "bindings" :
<entry>
    <key>spring/fileConfigurationName</key>
    <value class="java.lang.String">properties/spring/ServicesContext.xml</value>
</entry>


*My problem is that my lookup retrieve a String and not a javax.naming.Reference so I've got a ClassCastException : java.lang.String cannot be cast to javax.naming.Reference.*

I tried to deploy this mbean to do a linkRef (and changing the jboss-web.xml redirection) with no success :
<mbean code="org.jboss.naming.NamingAlias" name="com.bnppa.logviewer:alias=spring/fileConfigurationNameTEST">
    <attribute name="FromName">spring/fileConfigurationLink</attribute>
    <attribute name="ToName">spring/fileConfigurationName</attribute>
    <depends>jboss:service=Naming</depends>
</mbean:xml>



An extract of my jmx-console :
Global JNDI Namespace
+- spring (class: org.jnp.interfaces.NamingContext)
  |   +- fileConfigurationLink[link -> spring/fileConfigurationName] (class: javax.naming.LinkRef)
  |   +- fileConfigurationName (class: java.lang.String)


Anyone knows what's wrong with my configuration ?

Thanks in advance 

François
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/561346#561346]

Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100910/d7f735db/attachment.html 


More information about the jboss-user mailing list