3 Replies Latest reply on Jul 16, 2003 3:55 AM by madooreddy

    Datasource not bounding

    madooreddy Newbie

      Hi All !

      I am getting exceptions when javax.naming.ServiceUnavailableException: jna. Root exception is java.net.UnknownHostException: jna
      pls see the log trace for exceptions

      Here is client code for Ejb JNDI Context

      public static Connection getConnection() throws NamingException,SQLException
      {
      Connection con = null;
      String jndiName = "java:/SmsDBDS";
      Properties props = new Properties();
      props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.setProperty(Context.PROVIDER_URL, "jnp://192.168.0.2:1099");
      props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      Context context = new InitialContext(props);
      DB2XADataSource ds = (DB2XADataSource) context.lookup(jndiName);
      con = ds.getConnection("smsdb", "smsdb");
      return con;
      }


      javax.servlet.ServletException: jna
      at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:463)
      at org.apache.jsp.retrieveNoticeUserList$jsp._jspService(retrieveNoticeUserList$jsp.java:434)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
      at com.wizit.servlet.NoticeUserServlet.service(NoticeUserServlet.java:47)

      ______________________________________________________________________________________

      root cause

      javax.naming.ServiceUnavailableException: http. Root exception is java.net.UnknownHostException: jna
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:143)
      at java.net.Socket.connect(Socket.java:425)
      at java.net.Socket.connect(Socket.java:375)
      at java.net.Socket.(Socket.java:290)
      at java.net.Socket.(Socket.java:118)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:102)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:776)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:340)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)
      at javax.naming.InitialContext.lookup(InitialContext.java:354)
      at com.wizit.notice.ejb.NoticeGroupRetrieveHelper.findByALL(NoticeGroupRetrieveHelper.java:57)
      at org.apache.jsp.retrieveNoticeUserList$jsp._jspService(retrieveNoticeUserList$jsp.java:103)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
      at com.wizit.servlet.NoticeUserServlet.service(NoticeUserServlet.java:47)

        • 1. Re: Datasource not bounding
          Bernd Zeitler Expert

          Is 192.168.0.2 localhost for you? You can't lookup a datasource outside the vm.

          Try to post more about your configuration if the problem still persists.

          Greetings,
          Frito

          • 2. Re: Datasource not bounding
            madooreddy Newbie

            I am using Jboss-2.4.4 + Tomcat-4.0.3(Both are in same Red Hat linux 7.2 machine
            while accesing through JNDI name(java:/SmsDBDS) from browser getting exceptions javax.naming.ServiceUnavailableException
            Here is the exception trace:
            javax.servlet.ServletException: jnp
            at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:463)
            at org.apache.jsp.retrieveNoticeUserList$jsp._jspService(retrieveNoticeUserList$jsp.java:434)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
            at com.wizit.servlet.NoticeUserServlet.service(NoticeUserServlet.java:47)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
            at com.wizit.acs.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:105)
            --------------------------------------------------------------------------
            --------------------------------------------------------------------------
            root cause

            javax.naming.ServiceUnavailableException: jnp. Root exception is java.net.UnknownHostException: jnp
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:143)
            at java.net.Socket.connect(Socket.java:425)
            at java.net.Socket.connect(Socket.java:375)
            at java.net.Socket.(Socket.java:290)
            at java.net.Socket.(Socket.java:118)
            at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:102)
            at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:776)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:340)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:333)
            at javax.naming.InitialContext.lookup(InitialContext.java:354)
            at com.wizit.notice.ejb.NoticeGroupRetrieveHelper.findByALL(NoticeGroupRetrieveHelper.java:54)
            at org.apache.jsp.retrieveNoticeUserList$jsp._jspService(retrieveNoticeUserList$jsp.java:103)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
            at com.wizit.servlet.NoticeUserServlet.service(NoticeUserServlet.java:47)


            Note : As for my requirement i have to use two datsources(DefaultDS & SmsDBDS) which are in DB2

            Here are the files which modified & changed
            1) Configuration file for adding datasource: jboss.jcml -> $JBOSS-HOME/conf/default/


            COM.ibm.db2.jdbc.app.DB2Driver



            DefaultDS
            org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

            jdbc:db2:acs
            1200000
            acs
            10
            acs
            false
            false
            false
            true
            120000
            1800000
            false
            false
            1.0
            0



            SmsDBDS
            org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

            jdbc:db2:smsdb
            1200000
            smsdb
            10
            smsdb
            false
            false
            false
            true
            120000
            1800000
            false
            false
            1.0
            0


            2) This is the JNDI lookup method which is using by all beans when looking for DB Connection
            public static Connection getConnection() throws NamingException, SQLException
            {
            Connection con = null;
            String jndiName = "java:/SmsDBDS";
            Properties props = new Properties();
            props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" ) ;
            props.setProperty(Context.PROVIDER_URL, "jnp://61.250.65.230:1099");-->Jboss 2.4.4 and Tomact 4.0.3 are same machine 61.250.65.230)
            props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
            InitialContext context = new InitialContext(props);
            DataSource ds = (DataSource) context.lookup(jndiName);
            db = ds.getConnection("smsdb", "smsdb");
            return con;
            }

            Note:
            3) Deployment Descriptor files in META-INF directory for my beans : Below three files are attached to this as attachment files
            jboss.xml
            ejb-jar.xml
            jaws.xml


            After I added datasource and restart JBoss server can see data source "SmsDBDS" successfully added message in trace
            INFO,DefaultDS] Starting
            [INFO,DefaultDS] XA Connection pool DefaultDS bound to java:/DefaultDS
            [INFO,DefaultDS] Started
            [INFO,SmsDBDS] Starting
            [INFO,SmsDBDS] XA Connection pool SmsDBDS bound to java:/SmsDBDS
            [INFO,SmsDBDS] Started
            And very strangely which are using "DefaultDS" datasource working perfectly with out any worries, but which are using "SmsDBDS" datasource not at all working and giving above mentiond not bound expections.

            I have been trying my level best to resolve this problem, but unfortunately failed
            Don't understand what could be the real problem ?
            Do I need to modify any more configuration files? (i.e. standardjaws.xml or standardjboss.xml or some others)

            Please look at once on this and try to give your best suggestions/ ideas, it will be great help to me

            Many thanks in advance

            Regards
            Madhu

            • 3. Re: Datasource not bounding
              madooreddy Newbie

              Hi again !!

              I forgot to attache deployment descriptor files
              jboss.xml

              <?xml version="1.0" encoding="UTF-8" ?>

              false
              <enterprise-beans>

              <ejb-name>NoticeBean</ejb-name>
              <jndi-name>com/wizit/notice/ejb/NoticeHome</jndi-name>



              <ejb-name>NoticeControlBean</ejb-name>
              <jndi-name>com/wizit/notice/ejb/NoticeControlHome</jndi-name>
              <configuration-name></configuration-name>



              <ejb-name>NoticegroupBean</ejb-name>
              <jndi-name>com/wizit/notice/ejb/NoticegroupHome</jndi-name>



              <ejb-name>NoticeGroupControlBean</ejb-name>
              <jndi-name>com/wizit/notice/ejb/NoticeGroupControlHome</jndi-name>
              <configuration-name></configuration-name>



              </enterprise-beans>


              jaws.xml

              SmsDBDS
              <type-mapping>DB2</type-mapping>
              <enterprise-beans>

              <ejb-name>NoticeBean</ejb-name>
              <table-name>TBL_NOTICE</table-name>

              <create-table>true</create-table>
              <remove-table>true</remove-table>

              <cmp-field>
              <field-name>content</field-name>
              <column-name>CONTENT</column-name>
              </cmp-field>
              <cmp-field>
              <field-name>create_date</field-name>
              <column-name>CREATE_DATE</column-name>
              </cmp-field>
              <cmp-field>
              <field-name>create_time</field-name>
              <column-name>CREATE_TIME</column-name>
              </cmp-field>
              <cmp-field>
              <field-name>is_url</field-name>
              <column-name>IS_URL</column-name>
              </cmp-field>
              <cmp-field>
              <field-name>notice_grp_seq</field-name>
              <column-name>NOTICE_GRP_SEQ</column-name>
              </cmp-field>
              <cmp-field>
              <field-name>seq</field-name>
              <column-name>SEQ</column-name>
              </cmp-field>
              <cmp-field>
              <field-name>title</field-name>
              <column-name>TITLE</column-name>
              </cmp-field>



              <ejb-name>NoticegroupBean</ejb-name>
              <table-name>TBL_NOTICE_GRP</table-name>

              <create-table>true</create-table>
              <remove-table>true</remove-table>

              <cmp-field>
              <field-name>desc</field-name>
              <column-name>DESC</column-name>
              </cmp-field>
              <cmp-field>
              <field-name>name</field-name>
              <column-name>NAME</column-name>
              </cmp-field>
              <cmp-field>
              <field-name>seq</field-name>
              <column-name>SEQ</column-name>
              </cmp-field>

              </enterprise-beans>


              ejb-jar.xml
              <?xml version="1.0" encoding="UTF-8"?>

              <ejb-jar>
              <enterprise-beans>

              <ejb-name>NoticeBean</ejb-name>
              com.wizit.notice.ejb.NoticeHome
              com.wizit.notice.ejb.Notice
              <ejb-class>com.wizit.notice.ejb.NoticeBean</ejb-class>
              <persistence-type>Container</persistence-type>
              <prim-key-class>com.wizit.notice.ejb.NoticeKey</prim-key-class>
              False
              <cmp-field><field-name>content</field-name></cmp-field>
              <cmp-field><field-name>create_date</field-name></cmp-field>
              <cmp-field><field-name>create_time</field-name></cmp-field>
              <cmp-field><field-name>is_url</field-name></cmp-field>
              <cmp-field><field-name>notice_grp_seq</field-name></cmp-field>
              <cmp-field><field-name>seq</field-name></cmp-field>
              <cmp-field><field-name>title</field-name></cmp-field>
              <!--<primkey-field>resultPK</primkey-field>-->



              <ejb-name>NoticegroupBean</ejb-name>
              com.wizit.notice.ejb.NoticegroupHome
              com.wizit.notice.ejb.Noticegroup
              <ejb-class>com.wizit.notice.ejb.NoticegroupBean</ejb-class>
              <persistence-type>Container</persistence-type>
              <prim-key-class>com.wizit.notice.ejb.NoticegroupKey</prim-key-class>
              False
              <cmp-field><field-name>desc</field-name></cmp-field>
              <cmp-field><field-name>name</field-name></cmp-field>
              <cmp-field><field-name>seq</field-name></cmp-field>
              <!--<primkey-field>resultPK</primkey-field>-->



              <ejb-name>NoticeControlBean</ejb-name>
              com.wizit.notice.ejb.NoticeControlHome
              com.wizit.notice.ejb.NoticeControl
              <ejb-class>com.wizit.notice.ejb.NoticeControlBean</ejb-class>
              <session-type>Stateless</session-type>
              <transaction-type>Container</transaction-type>



              <ejb-name>NoticeGroupControlBean</ejb-name>
              com.wizit.notice.ejb.NoticeGroupControlHome
              com.wizit.notice.ejb.NoticeGroupControl
              <ejb-class>com.wizit.notice.ejb.NoticeGroupControlBean</ejb-class>
              <session-type>Stateless</session-type>
              <transaction-type>Container</transaction-type>

              </enterprise-beans>
              <assembly-descriptor>
              <container-transaction>

              <ejb-name>NoticeBean</ejb-name>
              <method-name>*</method-name>


              <ejb-name>NoticeControlBean</ejb-name>
              <method-name>*</method-name>


              <ejb-name>NoticegroupBean</ejb-name>
              <method-name>*</method-name>


              <ejb-name>NoticeGroupControlBean</ejb-name>
              <method-name>*</method-name>

              <trans-attribute>Required</trans-attribute>
              </container-transaction>
              </assembly-descriptor>
              </ejb-jar>


              thank you
              regards
              Mahdu