7 Replies Latest reply on Jul 28, 2011 9:27 AM by prasad.deshpande

    jndi jms topic lookup fails while deployment

    prasad.deshpande

      Hi,

       

      I have defined a topic in hornetq & referring that topic using some other name in my ejb, it throws me following error.

       

      15:10:07,604 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 1) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"efp.ear\".\"efprocess.jar\".jndiDependencyService missing [ jboss.naming.context.java.comp.efp.efprocess.ErrorLoggerHandler.env/jms/ErrorTopic ]","jboss.naming.context.java.comp.efp.efprocess.ErrorLoggerHandler.env/jms/ErrorTopic.jboss.deployment.subunit.\"efp.ear\".\"efprocess.jar\".component.ErrorLoggerHandler.9 missing [ jboss.naming.context.java.comp.efp.efprocess.ErrorLoggerHandler.env/topic/efpErrorTopic ]"]}}}

       

      Annotation is like below :

       

      @Resource(name="jms/ErrorTopic", type=Topic.class, mappedName="topic/efpErrorTopic")

      public class ErrorLoggerHandlerBean implements ErrorLoggerHandlerLocal {

      ...........

      }

       

       

      I can see all my topics & queus are deployed from following logs:

       

      15:09:54,213 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-8) trying to deploy queue jms.topic.AuditTopic

      15:09:54,229 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-4) trying to deploy queue jms.topic.ErrorTopic

      15:09:54,244 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) trying to deploy queue jms.topic.FreeTextTopic

      15:09:54,260 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-6) trying to deploy queue jms.topic.AdminTopic

      15:09:54,276 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) trying to deploy queue jms.queue.ActiveActivityQueue

       

      Does anyone have any clues as why this is failing (that too while ejb deployment.. actual lookup is way too far.)?

        • 1. Re: jndi jms topic lookup fails while deployment
          prasad.deshpande

          Aparently, mappedName should start with "java:/". So tag becomes mappedName="java:/topic/efpErrorTopic", then it works fine.

           

          A small question still if someone can answer,

           

          what is a default namespace in AS7? So suppose, I don't specify "java:/", then where exactly jndi lookup performed? I guess in earlier versions it was "java:comp/env", I tried in AS7 for com/env, but it didn't work for  me. Could anyone answer please?

          • 2. Re: jndi jms topic lookup fails while deployment
            jaikiran

            Prasad Deshpande wrote:

             

            Aparently, mappedName should start with "java:/". So tag becomes mappedName="java:/topic/efpErrorTopic", then it works fine.

             

            Hmm, I'll have to see what's going on here. I mean, I'll have to check to what namespace the queue/topics are bound by default when you have

             

            <jms-queue name="testQueue">
                             <entry name="queue/test"/>
                          </jms-queue>
            

             

            From what you say, it looks like they are by default bound to java: namespace.

             

             

             

            Prasad Deshpande wrote:

             

            A small question still if someone can answer,

             

            what is a default namespace in AS7? So suppose, I don't specify "java:/", then where exactly jndi lookup performed? I guess in earlier versions it was "java:comp/env", I tried in AS7 for com/env, but it didn't work for  me. Could anyone answer please?

            This might help http://lists.jboss.org/pipermail/jboss-as7-dev/2011-July/002890.html

            • 3. Re: jndi jms topic lookup fails while deployment
              prasad.deshpande

              Yes, I had look at this discussion over weekned, but I thought since the issue is not yet fixed, it still allows to bind to java:/ namespace. I've created a small piece of code to expose JNDI tree, & I found that when you deploy queue/topic like

               

              <jms-queue name="testQueue">
                <entry name="queue/test"/>
              </jms-queue>
              <jms-topic name="testTopic">
                <entry name="topic/testTopic"/>
              </jms-topic>

              It get's bound under "java:/queue" & "java:/topic" namespace. This is exactly how, I was able to proceed with the error in the first post. But since, http://lists.jboss.org/pipermail/jboss-as7-dev/2011-July/002890.html is going to change the way it is now, I'll have to wait until this is being fixed.

              • 4. Re: jndi jms topic lookup fails while deployment
                jaikiran

                This is fixed as part of AS7-1210 and is available in latest AS7 nightly builds.

                1 of 1 people found this helpful
                • 5. Re: jndi jms topic lookup fails while deployment
                  prasad.deshpande

                  Strange enough, If I specify as follows in destination configuration:

                  <jms-queue name="testQueue">
                    <entry name="queue/testQueue"/>
                  </jms-queue>
                  <jms-topic name="testTopic">
                    <entry name="topic/testTopic"/>
                  </jms-topic>

                  I get message that it is bound to "java:jboss/jms/queue/testQueue" & "java:jboss/jms/topic/testTopic" resp. but when I see it in JNDI It shows in "java:jboss/queue/testQueue" & "java:jboss/topic/testTopic" resp.

                   

                  Not sure why..

                   

                  so I explicitely have to specify as :

                   

                  <jms-queue name="testQueue">
                    <entry name="java:jboss/jms/queue/testQueue"/>
                  </jms-queue>
                  <jms-topic name="testTopic">
                    <entry name="
                  java:jboss/jms/topic/testTopic"/>
                  </jms-topic>

                   

                  need to dig-in more..

                  • 6. Re: jndi jms topic lookup fails while deployment
                    jaikiran

                    Prasad Deshpande wrote:

                     

                    Strange enough, If I specify as follows in destination configuration:

                    <jms-queue name="testQueue">
                      <entry name="queue/testQueue"/>
                    </jms-queue>
                    <jms-topic name="testTopic">
                      <entry name="topic/testTopic"/>
                    </jms-topic>

                    I get message that it is bound to "java:jboss/jms/queue/testQueue" & "java:jboss/jms/topic/testTopic" resp. but when I see it in JNDI It shows in "java:jboss/queue/testQueue" & "java:jboss/topic/testTopic" resp.

                     

                    Which JNDI tree? The one available from the command line client?

                    • 7. Re: jndi jms topic lookup fails while deployment
                      prasad.deshpande

                      Not really, I created a sample servlet that browses JNDI, until AS7 comesup with JNDI console, it will be helpful to me...

                       

                      package com;

                       

                      import java.io.IOException;

                      import java.io.PrintWriter;

                       

                      import javax.naming.Context;

                      import javax.naming.InitialContext;

                      import javax.naming.NameClassPair;

                      import javax.naming.NamingEnumeration;

                      import javax.naming.NamingException;

                      import javax.servlet.ServletConfig;

                      import javax.servlet.ServletException;

                      import javax.servlet.http.HttpServlet;

                      import javax.servlet.http.HttpServletRequest;

                      import javax.servlet.http.HttpServletResponse;

                       

                       

                      public class JNDITree extends HttpServlet {

                       

                          private static final long serialVersionUID = 1L;

                          private Context context;

                          PrintWriter out = null;

                          HttpServletResponse response = null;

                          StringBuffer htmlBuf = null;

                          Boolean isFirstElement = true;

                       

                          public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

                              response = res;

                              response.setContentType("text/html");

                              out = res.getWriter();

                              printHTMLJNDITree("");

                              out.print(htmlBuf.toString());

                          }

                       

                          private void printHTMLJNDITree(String ct) {

                              htmlBuf = new StringBuffer();

                              htmlBuf.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" +

                                      "\n<HTML>" +

                                      "\n<HEAD>\n<TITLE>JBoss JNDI Tree</TITLE>" +

                                      "\n<link rel=\"stylesheet\" href=\"./jquery.treeview.css\" />" +

                                      "\n<script src=\"./jquery.js\" type=\"text/javascript\"></script>" +

                                      "\n<script src=\"./jquery.treeview.js\" type=\"text/javascript\"></script>" +

                                      "\n<script>" +

                                      "\n$(document).ready(function(){" +

                                      "\n\t$(\"#jndiTreeView\").treeview({" +

                                      "\n\t\tanimated: \"fast\"," +

                                      "\n\t\tcollapsed: true," +

                                      "\n\t\tunique: false});" +

                                      "\n});" +

                                      "\n</script>" +

                                      "\n</HEAD>" +

                                      "\n<BODY>" +

                                      "\n<h1>JBoss JNDI Tree</h1>" +

                                      "\n<ul id=\"jndiTreeView\">");

                              increaseIndent();

                              printJNDITree("");

                              htmlBuf.append("\n</ul>\n</BODY></HTML>");

                          }

                       

                          public void init(ServletConfig config) throws ServletException{

                              super.init(config);

                              setEnv();

                          }

                       

                          public void setEnv() {

                              try {

                                  context = new InitialContext();

                              } catch (Exception e) {

                                  e.printStackTrace();

                              }

                          }

                       

                          public void printJNDITree(String ct) {

                              try {

                                  printNE(context.list(ct), ct);

                              } catch (NamingException e) {

                                  // ignore leaf node exception

                              }

                          }

                       

                          private void printNE(NamingEnumeration ne, String parentctx) throws NamingException {

                              Boolean shouldDecreaseIndent = false;

                              if (ne.hasMoreElements() &&!isFirstElement) {

                                  htmlBuf.append("\n" + printIndent() + "<ul>");

                                  increaseIndent();

                                  shouldDecreaseIndent = true;

                              }

                              while (ne.hasMoreElements()) {

                                  isFirstElement = false;

                                  NameClassPair next = (NameClassPair) ne.nextElement();

                                  printEntry(next);

                                  increaseIndent();

                                  printJNDITree((parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName());

                                  decreaseIndent();

                                  htmlBuf.append("\n" + printIndent() + "</li>");

                              }

                       

                              if (shouldDecreaseIndent) {

                                  decreaseIndent();

                                  htmlBuf.append("\n" + printIndent() + "</ul>");

                              }

                          }

                       

                          private void printEntry(NameClassPair next) {

                              htmlBuf.append("\n" + printIndent() + "<li><span>" + next + "</span>");

                          }

                       

                          private int indentLevel = 0;

                       

                          private void increaseIndent() {

                              indentLevel += 4;

                          }

                       

                          private void decreaseIndent() {

                              indentLevel -= 4;

                          }

                       

                          private String printIndent() {

                              StringBuffer buf = new StringBuffer(indentLevel);

                              for (int i = 0; i < indentLevel; i++) {

                                  buf.append(" ");

                              }

                              return buf.toString();

                          }

                      }