On 13 Apr, Jason Dillon wrote:
> Hello, I am getting an odd naming exception when I try to lookup the
> connection factory:


Hi, this will not work in JBoss due to a feature in ApplicationMetaData.
A JNDI pointed out in a res-jndi-name must be part of the java:
namespace. If java: is not found in the JNDI name it will be added by
ApplicationMetaData

(if (jndi != null && !jndi.startsWith("java:/"))
               jndi = "java:/"+jndi;
               )

Meaning that you will try to lookup "java:QueueConnectionFactory", but
since non of the JMS JNDI objects are bound to java: namespace, they
will not be found.

There is a workaround/hack that uses the way the Container currently is
implemented: use <res-url> instead of <res-jndi-name>. Here is a working
jboss.xml for the Publisher bean from the SUN JMS tutorial:


<?xml version="1.0" encoding="Cp1252"?>

<jboss>
     <secure>false</secure>
      <resource-managers>
        <resource-manager>
          <res-name>topicfactoryref</res-name>
          <res-url>TopicConnectionFactory</res-url>
        </resource-manager>
        <resource-manager>
          <res-name>topicref</res-name>
          <res-url>topic/TestTopic</res-url>
        </resource-manager>
    </resource-managers>

     <enterprise-beans>
       <session>
         <ejb-name>Publisher</ejb-name>
         <jndi-name>publisher</jndi-name>
         <configuration-name>Standard Stateless SessionBean</configuration-name>
          <resource-ref>
           <res-ref-name>jms/MyTopicConnectionFactory</res-ref-name>
           <resource-name>topicfactoryref</resource-name>
         </resource-ref>
         <resource-ref>
           <res-ref-name>jms/TopicName</res-ref-name>
          <resource-name>topicref</resource-name>
         </resource-ref>
       </session>
     </enterprise-beans>
</jboss>


This might not allways work, since it is based on a sideffect of the
current implementation of the Container class.

The truth is that JBoss currently really has no support for JMS as a
resource (see repply on your other mail).


//Peter

> 
> <snip>
> javax.naming.NameNotFoundException: QueueConnectionFactory not bound
>       at org.jnp.server.NamingServer.getBinding(NamingServer.java:474)
>       at org.jnp.server.NamingServer.getBinding(NamingServer.java:482)
>       at org.jnp.server.NamingServer.getObject(NamingServer.java:488)
>       at org.jnp.server.NamingServer.lookup(NamingServer.java:283)
>       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:295)
>       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:279)
>       at javax.naming.InitialContext.lookup(InitialContext.java:350)
>       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:367)
>       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:279)
>         <snip-truncate/>
> 
> </snip>
> 
> Here are the bits that I added to the ejb-jar and jboss xml files, as well
> as a bit of the JNDIView output from the server this is running in:
> 
> <snip from="ejb-jar">
> 
>   <resource-ref>
>     <description>Default QueueConnectionFactory</description>
>     <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
>     <res-type>javax.jms.QueueConnectionFactory</res-type>
>     <res-auth>Container</res-auth>
>   </resource-ref>
> 
> </snip>
> 
> <snip from="jboss">
> 
>   <resource-ref>
>     <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
>     <resource-name>QueueConnectionFactory</resource-name>
>   </resource-ref>
> 
>   <snip-truncate/>
> 
>   <resource-managers>
>     <resource-manager res-class="">
>       <res-name>QueueConnectionFactory</res-name>
>       <res-jndi-name>QueueConnectionFactory</res-jndi-name>
>     </resource-manager>
>   </resource-managers>
> 
> </snip>
> 
> <snip from="JNDIView Output">
>   +- QueueConnectionFactory (class: org.jbossmq.SpyQueueConnectionFactory)
> </snip>
> 
> --
> 
> It looks like the namespace of the bean is ok:
> 
> <snip from="JNDIView Output">
>   +- env (class: org.jnp.interfaces.NamingContext)
>     |   +- jms (class: org.jnp.interfaces.NamingContext)
>     |   |   +- QueueConnectionFactory (class: javax.naming.LinkRef)
> </snip>
> 
> --
> 
> To lookup the object I am first getting the env context:
> 
>  context = new InitialContext().lookup("java:comp/env/");
>  ...
>  factory = (...) context.lookup("jms/QueueConnectionFactory");
> 
> --
> 
> I am not really sure where the naming problem comes up.  It looks like it
> might be having touble with the LinkRef, but that is only a guess since the
> name I am looking for has a 'jms/' prefix on it at the bean level, but the
> resource does not.
> 
> I will play around with it some more, but if you (or anyone else) has any
> ideas please let me know.
> 
> Thanks,
> 
> --jason
> 
> On Thu, 12 Apr 2001, Scott M Stark wrote:
> 
>> A ConnectionFactory is a resource factory and the spec talks about JMS
>> being located by convention under the java:comp/env/jms context. To
>> access a QueueConnectionFactory independent of which app server you
>> deploy in you would define an ejb-jar resource-ref as:
>>
>> ejb-jar.xml:
>> <ejb-jar>
>>     <display-name>ENC Tests</display-name>
>>     <enterprise-beans>
>>         <session>
>>             <description>A session bean on looks up stuff in the ENC</description>
>> ...
>>             <!-- JMS Connection Factories (java:comp/env/jms) -->
>>             <resource-ref>
>>                 <description>Default QueueFactory</description>
>>                 <res-ref-name>jms/QueFactory</res-ref-name>
>>                 <res-type>javax.jms.QueueConnectionFactory</res-type>
>>                 <res-auth>Container</res-auth>
>>             </resource-ref>
>>         </session>
>>     </enterprise-beans>
>> </ejb-jar>
>>
>> jboss.xml:
>> <jboss>
>>     <enterprise-beans>
>>         <session>
>>             <ejb-name>ENCBean</ejb-name>
>>             <resource-ref>
>>                 <resource-name>QueFactory</resource-name>
>>                 <res-ref-name>jms/QueFactory</res-ref-name>
>>             </resource-ref>
>>         </session>
>>     </enterprise-beans>
>>
>>     <resource-managers>
>>         <resource-manager res-class="">
>>             <res-name>QueFactory</res-name>
>>             <res-jndi-name>QueueConnectionFactory</res-jndi-name>
>>         </resource-manager>
>>     </resource-managers>
>> </jboss>
>>
>> Your bean is indepdendent of the app server but its deployment unit is not.
>>
>> ----- Original Message -----
>> From: "Jason Dillon" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Thursday, April 12, 2001 5:25 PM
>> Subject: Re: [JBoss-user] Using JMS resources (or other resources)
>>
>>
>> > That is more or less what I am going to be doing, but I wanted to know if
>> > there was a standard way to provide the queue information to a bean.  My
>> > guess is that it should be as a resource, but I am not 100% sure.
>> >
>> > --jason
>> >
>>
>>
>>
>> _______________________________________________
>> JBoss-user mailing list
>> [EMAIL PROTECTED]
>> http://lists.sourceforge.net/lists/listinfo/jboss-user
>>
> 
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user

-- 
------------------------------------------------------------
Peter Antman             Technology in Media, Box 34105 100 26 Stockholm
Systems Architect        WWW: http://www.tim.se
Email: [EMAIL PROTECTED]        WWW: http://www.backsource.org
Phone: +46-(0)8-506 381 11 Mobile: 070-675 3942 
------------------------------------------------------------


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to