9 Replies Latest reply on Nov 30, 2007 8:50 AM by Tam Mains

    java.lang.ClassCastException: org.jnp.interfaces.NamingConte

    Tam Mains Newbie

      Hi all,

      help for a relative newbie required...

      Having problems running a slight modification of an example from the book Eclipse Web Tools Platform.
      Platform first...


      Linux.
      Eclipse 3.2 with J2EE

      JDK 1.4.
      EJB Module 2.1
      EJB Doclet(XDoclet) 1.2.3.


      When running a message driven EJB I get the following exception in the console ...
      20:58:29,953 ERROR [STDERR] java.lang.ClassCastException: org.jnp.interfaces.NamingContext
      20:58:29,955 ERROR [STDERR] at com.jujitsu.ejb.AsyncJujitsuFacadeUtil.getQueueConnection(AsyncJujitsuFacadeUtil.java:69)
      20:58:29,955 ERROR [STDERR] at com.jujitsu.servlets.CreateClubAction.sendMessage(CreateClubAction.java:51)
      20:58:29,955 ERROR [STDERR] at com.jujitsu.servlets.CreateClubAction.doGet(CreateClubAction.java:34)
      20:58:29,955 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      20:58:29,955 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      20:58:29,955 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      20:58:29,955 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      20:58:29,956 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      20:58:29,956 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      20:58:29,956 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      20:58:29,956 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      20:58:29,956 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      20:58:29,956 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      20:58:29,957 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      20:58:29,957 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      20:58:29,957 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      20:58:29,957 ERROR [STDERR] at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      20:58:29,957 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      20:58:29,957 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      20:58:29,958 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      20:58:29,958 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      20:58:29,958 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      20:58:29,958 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      20:58:29,958 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      


      Now the exception occurs in the call to...

      cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;

      in the xdoclet generated class AsyncJujitsuFacadeUtil.

      I added the destination-jndi-name to the jbossmq-destinations-service.xml file as so...

      <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=AsyncJujitsuFacade">
      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
      </mbean>


      This looks to have been bound...

      20:50:40,964 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
      20:50:41,721 INFO [A] Bound to JNDI name: queue/A
      20:50:41,725 INFO [B] Bound to JNDI name: queue/B
      20:50:41,728 INFO [C] Bound to JNDI name: queue/C
      20:50:41,731 INFO [D] Bound to JNDI name: queue/D
      20:50:41,734 INFO [ex] Bound to JNDI name: queue/ex
      20:50:41,736 INFO [AsynchLeagueFacade] Bound to JNDI name: queue/AsynchLeagueFacade
      20:50:41,739 INFO [AsyncJujitsuFacade] Bound to JNDI name: queue/AsyncJujitsuFacade
      20:50:41,823 INFO [testTopic] Bound to JNDI name: topic/testTopic
      20:50:41,826 INFO [securedTopic] Bound to JNDI name: topic/securedTopic
      20:50:41,829 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic
      20:50:41,843 INFO [testQueue] Bound to JNDI name: queue/testQueue
      20:50:42,023 INFO [UILServerILService] JBossMQ UIL service available at : /0.0.0.0:8093
      20:50:42,319 INFO [DLQ] Bound to JNDI name: queue/DLQ
      20:50:42,890 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
      20:50:43,066 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
      20:50:43,541 INFO [EARDeployer] Init J2EE application: file:/home/tam/opt/jboss-4.0.5.GA/server/default/deploy/JujitsuEJBEAR.ear
      20:50:44,265 INFO [EjbModule] Deploying JujitsuFacade
      20:50:44,523 INFO [EjbModule] Deploying AsyncJujitsuFacade
      20:50:45,005 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'JujitsuFacade' to jndi 'JujitsuFacadeLocal'
      20:50:45,057 INFO [ProxyFactory] Bound EJB Home 'JujitsuFacade' to jndi 'JujitsuFacade'
      20:50:45,500 INFO [EJBDeployer] Deployed: file:/home/tam/opt/jboss-4.0.5.GA/server/default/tmp/deploy/tmp412JujitsuEJBEAR.ear-contents/JujitsuEJB.jar
      20:50:45,750 INFO [TomcatDeployer] deploy, ctxPath=/jujitsuWeb, warUrl=.../tmp/deploy/tmp412JujitsuEJBEAR.ear-contents/jujitsuWeb-exp.war/
      20:50:46,103 INFO [EARDeployer] Started J2EE application: file:/home/tam/opt/jboss-4.0.5.GA/server/default/deploy/JujitsuEJBEAR.ear
      20:50:46,108 INFO [EARDeployer] Init J2EE application: file:/home/tam/opt/jboss-4.0.5.GA/server/default/deploy/LeaguePlanetEAR.ear
      20:50:46,444 INFO [EjbModule] Deploying LeagueFacade
      20:50:46,474 INFO [EjbModule] Deploying AsynchLeagueFacade
      20:50:46,766 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'LeagueFacade' to jndi 'LeagueFacadeLocal'
      20:50:46,806 INFO [ProxyFactory] Bound EJB Home 'LeagueFacade' to jndi 'LeagueFacade'
      20:50:46,860 INFO [EJBDeployer] Deployed: file:/home/tam/opt/jboss-4.0.5.GA/server/default/tmp/deploy/tmp414LeaguePlanetEAR.ear-contents/LeaguePlanetEJB.jar
      20:50:46,964 INFO [TomcatDeployer] deploy, ctxPath=/LeaguePlanetWeb, warUrl=.../tmp/deploy/tmp414LeaguePlanetEAR.ear-contents/LeaguePlanetWeb-exp.war/
      20:50:47,372 INFO [EARDeployer] Started J2EE application: file:/home/tam/opt/jboss-4.0.5.GA/server/default/deploy/LeaguePlanetEAR.ear
      20:50:47,651 INFO [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080
      20:50:48,195 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
      20:50:48,267 INFO [JkMain] Jk running ID=0 time=0/223 config=null
      20:50:48,395 INFO [Server] JBoss (MX MicroKernel) [4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)] Started in


      Anyone any idea why this is happening and the actions needed to remedy the situation. When debugging I follow the trace which does not go as far as any code I have produced.

      SIDE NOTE...I hate when running a program runs into an exception which is hard to dig out because you have not coded where the exception occurs. Not that would make any difference :)


        • 1. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
          Tam Mains Newbie

          Contents of the jbossmq-destinations-service.xml again never showed well in the above post...

          <mbean code="org.jboss.mq.server.jmx.Queue"
           name="jboss.mq.destination:service=Queue,name=A">
           <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
           </mbean>
           <mbean code="org.jboss.mq.server.jmx.Queue"
           name="jboss.mq.destination:service=Queue,name=B">
           <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
           </mbean>
           <mbean code="org.jboss.mq.server.jmx.Queue"
           name="jboss.mq.destination:service=Queue,name=C">
           <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
           </mbean>
           <mbean code="org.jboss.mq.server.jmx.Queue"
           name="jboss.mq.destination:service=Queue,name=D">
           <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
           </mbean>
           <mbean code="org.jboss.mq.server.jmx.Queue"
           name="jboss.mq.destination:service=Queue,name=ex">
           <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
           </mbean>
           <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=AsynchLeagueFacade">
           <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
           </mbean>
           <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=AsyncJujitsuFacade">
           <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
           </mbean>
          


          • 2. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
            Tam Mains Newbie

            Anyone got any idea whats going wrong here?

            Kind of stuck.

            • 3. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
              jaikiran pai Master

              Looks like you are looking up a object and casting it to javax.jms.QueueConnectionFactory. Post the code where you are doing the lookup.

              • 4. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
                Tam Mains Newbie

                Okay here goes. This is a message driven ejb. The user enters a string which represents an identification. This is done from a html form and text input. The idea is the string is used as an id for the creation of a new object.

                Here is the html

                <form action="CreateClubAction" method="GET">
                 <table>
                 <tr><th>Club ID</th><th><input type="text" name="clubId" value=""/></th></tr>
                 <tr><td colspan="2"><input type="submit" name="add" value="add"/></td></tr>
                 </table>
                </form>
                


                The url "CreateClubAction" is a servlet which creates an "in memory copy of data required to initialize the application. It then sends a message, the string entered into the html page and replies to standout the string entered whilst displaying a jsp page with a copy of the in memory data.

                here is some of CreateClubAction.java, the servlet.
                protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                 try{
                 String clubId = request.getParameter("clubId");
                 sendMessage(clubId);
                 forward(request, response);
                 }catch(Exception e){
                 e.printStackTrace();
                 }
                 }
                
                private void sendMessage(String clubId) throws
                 NamingException, JMSException {
                 QueueConnection qConnection =
                 AsyncJujitsuFacadeUtil.getQueueConnection();
                 Queue queue = AsyncJujitsuFacadeUtil.getQueue();
                 QueueSession qSession =
                 qConnection.createQueueSession(false, SESSIONTYPE);
                 QueueSender qSender = qSession.createSender(queue);
                
                 Club aClub = new Club();
                 aClub.setId(clubId);
                
                 ObjectMessage objectMessage = qSession.createObjectMessage(aClub);
                 qSender.send(objectMessage);
                 qSession.close();
                 qConnection.close();
                
                 }
                
                private void forward(HttpServletRequest request, HttpServletResponse response)
                 throws ServletException, IOException {
                 this.getServletContext().getRequestDispatcher("/students.jsp")
                 .forward(request, response);
                
                 }
                


                Where it is falling down is on the call to sendMessage() above. Which equates to the line in the xdoclet created class AsyncJujitsuFacadeUtil.java shown below.
                 public static javax.jms.QueueConnection getQueueConnection() throws javax.naming.NamingException, javax.jms.JMSException
                 {
                 if (cachedConnectionFactory == null) {
                 // Obtain initial context
                 javax.naming.InitialContext initialContext = new javax.naming.InitialContext();
                 try {
                 java.lang.Object objRef = initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME);
                 cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;
                 } finally {
                 initialContext.close();
                 }
                 }
                 return cachedConnectionFactory.createQueueConnection();
                 }
                


                The line below is where the exception points to...

                 cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;
                


                The bean class is shown below...

                public class AsyncJujitsuFacadeBean implements javax.ejb.MessageDrivenBean,
                 javax.jms.MessageListener {
                
                 /**
                 *
                 */
                 private static final long serialVersionUID = 1L;
                 /**
                 * <!-- begin-user-doc -->
                 * <!-- end-user-doc -->
                 * The context for the message-driven bean, set by the EJB container.
                 * @generated
                 */
                 private javax.ejb.MessageDrivenContext messageContext = null;
                 private JujitsuFacade jujitsuFacade;
                
                 /**
                 * Required method for container to set context.
                 * @generated
                 */
                 public void setMessageDrivenContext(
                 javax.ejb.MessageDrivenContext messageContext)
                 throws javax.ejb.EJBException {
                 this.messageContext = messageContext;
                 }
                
                 /**
                 * Required creation method for message-driven beans.
                 *
                 * <!-- begin-user-doc -->
                 * <!-- end-user-doc -->
                 *
                 * <!-- begin-xdoclet-definition -->
                 * @ejb.create-method
                 * <!-- end-xdoclet-definition -->
                 * @generated
                 */
                 public void ejbCreate() {
                 //no specific action required for message-driven beans
                 jujitsuFacade = ClubFacade.getJujitsuFacade();
                 }
                
                 /**
                 * Required removal method for message-driven beans.
                 * <!-- begin-user-doc -->
                 * <!-- end-user-doc -->
                 * @generated
                 */
                 public void ejbRemove() {
                 messageContext = null;
                 }
                
                 /**
                 * This method implements the business logic for the EJB.
                 *
                 * <p>Make sure that the business logic accounts for asynchronous message processing.
                 * For example, it cannot be assumed that the EJB receives messages in the order they were
                 * sent by the client. Instance pooling within the container means that messages are not
                 * received or processed in a sequential order, although individual onMessage() calls to
                 * a given message-driven bean instance are serialized.
                 *
                 * <p>The <code>onMessage()</code> method is required, and must take a single parameter
                 * of type javax.jms.Message. The throws clause (if used) must not include an application
                 * exception. Must not be declared as final or static.
                 *
                 * <!-- begin-user-doc -->
                 * <!-- end-user-doc -->
                 * @generated
                 */
                 public void onMessage(javax.jms.Message message) {
                 // begin-user-code
                 try{
                 Club club = (Club)((ObjectMessage) message).getObject();
                 jujitsuFacade.createClub(club);
                 System.out.println("A New Club: " + club.getId());
                 }catch(JMSException e){
                 e.printStackTrace();
                 }
                 // end-user-code
                 }
                
                 /**
                 *
                 */
                 public AsyncJujitsuFacadeBean() {
                 // TODO Auto-generated constructor stub
                 }
                }
                


                Hope someone can understand whats going wrong here as I can't.

                • 5. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
                  Tam Mains Newbie

                  When debugging in Eclipse...

                  when entering the sendMessage() method of the servlet...the

                  QueueConnection qConnection =
                   AsyncJujitsuFacadeUtil.getQueueConnection();
                  

                  eventually stepping into...
                  java.lang.Object objRef = initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME);
                  

                  in the xdoclet generated class AsyncJujitsufacadeUtil.

                  When the following method is called...
                  cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;
                  

                  we step into the class ClassLoader method below
                  // This method is invoked by the virtual machine to load a class.
                   private synchronized Class loadClassInternal(String name)
                   throws ClassNotFoundException
                   {
                   return loadClass(name);
                   }
                  


                  which I take is the
                  javax.jms.QueueConnectionFactory
                  The next method stepped into is
                   public Class<?> loadClass(String name) throws ClassNotFoundException {
                   return loadClass(name, false);
                   }
                  


                  The next method I think causes the exception...
                   private void checkPackageAccess(Class cls, ProtectionDomain pd) {
                   final SecurityManager sm = System.getSecurityManager();
                   if (sm != null) {
                   final String name = cls.getName();
                   final int i = name.lastIndexOf('.');
                   if (i != -1) {
                   AccessController.doPrivileged(new PrivilegedAction() {
                   public Object run() {
                   sm.checkPackageAccess(name.substring(0, i));
                   return null;
                   }
                   }, new AccessControlContext(new ProtectionDomain[] {pd}));
                   }
                   }
                   domains.add(pd);
                   }
                  


                  When it gets to the comarison for sm != null, sm = null so goes to domain.add() then from there to the ClassCastException creation method.

                  • 6. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
                    jaikiran pai Master

                    What's the value of the string CONNECTION_FACTORY_JNDI_NAME and what's type of cachedConnectionFactory ?

                    • 7. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
                      Tam Mains Newbie

                      The type of cachedConnectionFactory is...

                      /** Cached connection factory. Uses lazy loading to obtain its value. */
                       private static javax.jms.QueueConnectionFactory cachedConnectionFactory = null;
                      

                      declared at the top of the class

                      Declaration of CONNECTION_FACTORY_JNDI_NAME...
                      private static final java.lang.String CONNECTION_FACTORY_JNDI_NAME="";
                      


                      The full code for the xdoclet produced class...
                      /*
                       * Generated file - Do not edit!
                       */
                      package com.jujitsu.ejb;
                      
                      /**
                       * Utility class for AsyncJujitsuFacade.
                       * @generated
                       * @wtp generated
                       */
                      public class AsyncJujitsuFacadeUtil
                      {
                      
                       /** Cached queue (javax.jms.Queue). Uses lazy loading to obtain its value (loaded by getQueue() methods). */
                       private static javax.jms.Queue cachedQueue = null;
                       /** Cached connection factory. Uses lazy loading to obtain its value. */
                       private static javax.jms.QueueConnectionFactory cachedConnectionFactory = null;
                      
                       private static final java.lang.String DESTINATION_JNDI_NAME="queue/AsyncJujitsuFacade";
                       private static final java.lang.String CONNECTION_FACTORY_JNDI_NAME="";
                      
                       /**
                       * Obtain destination queue from default initial context
                       * @return Destination JMS Queue for AsyncJujitsuFacade. Lookup using JNDI_NAME
                       */
                       public static javax.jms.Queue getQueue() throws javax.naming.NamingException
                       {
                       if (cachedQueue == null) {
                       // Obtain initial context
                       javax.naming.InitialContext initialContext = new javax.naming.InitialContext();
                       try {
                       java.lang.Object objRef = initialContext.lookup(DESTINATION_JNDI_NAME);
                       cachedQueue = (javax.jms.Queue) objRef;
                       } finally {
                       initialContext.close();
                       }
                       }
                       return cachedQueue;
                       }
                      
                       /**
                       * Obtain destination queue from parameterised initial context
                       * @param environment Parameters to use for creating initial context
                       * @return Destination JMS Queue for AsyncJujitsuFacade. Lookup using JNDI_NAME
                       */
                       public static javax.jms.Queue getQueue( java.util.Hashtable environment ) throws javax.naming.NamingException
                       {
                       // Obtain initial context
                       javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment);
                       try {
                       java.lang.Object objRef = initialContext.lookup(DESTINATION_JNDI_NAME);
                       return (javax.jms.Queue) objRef;
                       } finally {
                       initialContext.close();
                       }
                       }
                      
                       /**
                       * Obtain destination queue from default initial context
                       * @return Destination JMS Connection Factory for AsyncJujitsuFacade. Lookup using JNDI_NAME
                       */
                       public static javax.jms.QueueConnection getQueueConnection() throws javax.naming.NamingException, javax.jms.JMSException
                       {
                       if (cachedConnectionFactory == null) {
                       // Obtain initial context
                       javax.naming.InitialContext initialContext = new javax.naming.InitialContext();
                       try {
                       java.lang.Object objRef = initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME);
                       cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;
                       } finally {
                       initialContext.close();
                       }
                       }
                       return cachedConnectionFactory.createQueueConnection();
                       }
                      
                       /**
                       * Obtain destination queue from parameterised initial context
                       * @param environment Parameters to use for creating initial context
                       * @return Destination JMS Connection Factory for AsyncJujitsuFacade. Lookup using JNDI_NAME
                       */
                       public static javax.jms.QueueConnection getQueueConnection( java.util.Hashtable environment ) throws javax.naming.NamingException, javax.jms.JMSException
                       {
                       // Obtain initial context
                       javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment);
                       try {
                       java.lang.Object objRef = initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME);
                       return ((javax.jms.QueueConnectionFactory) objRef).createQueueConnection();
                       } finally {
                       initialContext.close();
                       }
                       }
                      
                       /** Cached per JVM server IP. */
                       private static String hexServerIP = null;
                      
                       // initialise the secure random instance
                       private static final java.security.SecureRandom seeder = new java.security.SecureRandom();
                      
                       /**
                       * A 32 byte GUID generator (Globally Unique ID). These artificial keys SHOULD <strong>NOT </strong> be seen by the user,
                       * not even touched by the DBA but with very rare exceptions, just manipulated by the database and the programs.
                       *
                       * Usage: Add an id field (type java.lang.String) to your EJB, and add setId(XXXUtil.generateGUID(this)); to the ejbCreate method.
                       */
                       public static final String generateGUID(Object o) {
                       StringBuffer tmpBuffer = new StringBuffer(16);
                       if (hexServerIP == null) {
                       java.net.InetAddress localInetAddress = null;
                       try {
                       // get the inet address
                      
                       localInetAddress = java.net.InetAddress.getLocalHost();
                       }
                       catch (java.net.UnknownHostException uhe) {
                       System.err.println("AsyncJujitsuFacadeUtil: Could not get the local IP address using InetAddress.getLocalHost()!");
                       // todo: find better way to get around this...
                       uhe.printStackTrace();
                       return null;
                       }
                       byte serverIP[] = localInetAddress.getAddress();
                       hexServerIP = hexFormat(getInt(serverIP), 8);
                       }
                      
                       String hashcode = hexFormat(System.identityHashCode(o), 8);
                       tmpBuffer.append(hexServerIP);
                       tmpBuffer.append(hashcode);
                      
                       long timeNow = System.currentTimeMillis();
                       int timeLow = (int)timeNow & 0xFFFFFFFF;
                       int node = seeder.nextInt();
                      
                       StringBuffer guid = new StringBuffer(32);
                       guid.append(hexFormat(timeLow, 8));
                       guid.append(tmpBuffer.toString());
                       guid.append(hexFormat(node, 8));
                       return guid.toString();
                       }
                      
                       private static int getInt(byte bytes[]) {
                       int i = 0;
                       int j = 24;
                       for (int k = 0; j >= 0; k++) {
                       int l = bytes[k] & 0xff;
                       i += l << j;
                       j -= 8;
                       }
                       return i;
                       }
                      
                       private static String hexFormat(int i, int j) {
                       String s = Integer.toHexString(i);
                       return padHex(s, j) + s;
                       }
                      
                       private static String padHex(String s, int i) {
                       StringBuffer tmpBuffer = new StringBuffer();
                       if (s.length() < i) {
                       for (int j = 0; j < i - s.length(); j++) {
                       tmpBuffer.append('0');
                       }
                       }
                       return tmpBuffer.toString();
                       }
                      
                      }
                      


                      This is code which is generated when the ejb is created...
                      it seems as though the value of CONNECTION_FACTORY_JNDI_NAME maybe an empty string when called in the getQueueConnection() method (no params) above. I have no control over this code or it's parameters?

                      The value of objRef when the last method is called, the method in which the exception occurs.
                      objRef NamingContext (id=263)
                       env Hashtable<K,V> (id=265)
                       naming NamingServer (id=270)
                       parser NamingParser (id=274)
                       prefix CompoundName (id=277)
                      



                      • 8. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
                        jaikiran pai Master

                         

                        private static final java.lang.String CONNECTION_FACTORY_JNDI_NAME=""


                        The value for this constant should be "ConnectionFactory".


                        private static final java.lang.String CONNECTION_FACTORY_JNDI_NAME="ConnectionFactory"
                        




                        This is code which is generated when the ejb is created...
                        it seems as though the value of CONNECTION_FACTORY_JNDI_NAME maybe an empty string when called in the getQueueConnection() method (no params) above. I have no control over this code or it's parameters?


                        I guess, you should be able to specify the connection_factory_jndi_name as a parameter to your XDoclet task (similar to what you are doing with DESTINATION_JNDI_NAME). You might have to look at the appropriate XDoclet task's documentation.



                        • 9. Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
                          Tam Mains Newbie

                          Thanks jaikiran,

                          Been away for a couple of days. Just to confirm your prognosis was correct. Sorted by including "ConnectionFactory" in the xdoclet comments.