Announcement Announcement Module
Collapse
No announcement yet.
Jndi/jsp Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jndi/jsp Problem

    Hi,
    I am getting "datasource not bound" exception.Please help me to solve this.I have given the following details:

    My datasource connection name is OracleDS.I have put that xml in server/default/deploy folder as oracle-ds.xml and classes12.jar folder.

    In web.xml,i have included the following:

    <resource-ref>
    <description>DB Connection</description>
    <res-ref-name>OracleDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>

    In jboss-web.xml,
    <jboss-web>
    <resource-ref>
    <res-ref-name>OracleDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <jndi-name>java:/OracleDS</jndi-name>
    </resource-ref>
    </jboss-web>

    I have put the spring jars and jar files in the lib folder of WEB-INF

    In a jsp file when i try to access like this
    <%
    String sql = "select * from emp";

    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    ResultSetMetaData rsm = null;
    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "org.jnp.interfaces.NamingContextFactory");
    env.put(Context.PROVIDER_URL,"jnp://localhost:1099");

    Context ctx = new InitialContext(env);
    DataSource datasource= (DataSource) ctx.lookup("java:/OracleDS");
    Connection con=datasource.getConnection();
    stmt = conn.createStatement( );
    rs = stmt.executeQuery(sql);
    rsm = rs.getMetaData( );
    int colCount = rsm.getColumnCount( );

    %>
    I am getting error as follows,
    javax.naming.NameNotFoundException: OracleDS not bound
    org.jnp.server.NamingServer.getBinding(NamingServe r.java:491)
    org.jnp.server.NamingServer.getBinding(NamingServe r.java:499)
    org.jnp.server.NamingServer.getObject(NamingServer .java:505)
    org.jnp.server.NamingServer.lookup(NamingServer.ja va:278)
    org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:610)
    org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:572)
    javax.naming.InitialContext.lookup(InitialContext. java:347)
    org.apache.jsp.one_jsp._jspService(org.apache.jsp. one_jsp:66)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)


    Please help me to solve this..........

  • #2
    use the jmx console from jboss to browse the JNDI tree - most probably the OracleDS is there but under a different path.

    Comment


    • #3
      kannak7,

      How is this related to Spring Framework?

      Comment


      • #4
        String sql = "select * from emp";
        starts with the same letter as Spring .

        Comment


        • #5
          new Exception

          Thanks,
          I corrected the datasource path.But now struck up with another exception,

          exception

          org.apache.jasper.JasperException: StatementCallback; uncategorized SQLException for SQL [select * from tab]; SQL state [null]; error code [0]; Invalid scale size. Cannot be less than zero; nested exception is java.sql.SQLException: Invalid scale size. Cannot be less than zero
          org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:370)
          org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
          org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
          javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
          org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)


          root cause

          org.springframework.jdbc.UncategorizedSQLException : StatementCallback; uncategorized SQLException for SQL [select * from tab]; SQL state [null]; error code [0]; Invalid scale size. Cannot be less than zero; nested exception is java.sql.SQLException: Invalid scale size. Cannot be less than zero
          org.springframework.jdbc.support.SQLStateSQLExcept ionTranslator.translate(SQLStateSQLExceptionTransl ator.java:96)
          org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator.translate(SQLErrorCodeSQLExcepti onTranslator.java:257)
          org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:266)
          org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:326)
          org.springframework.jdbc.core.JdbcTemplate.queryFo rRowSet(JdbcTemplate.java:369)
          org.apache.jsp.AdminUI_jsp.doSelect(org.apache.jsp .AdminUI_jsp:26)
          org.apache.jsp.AdminUI_jsp._jspService(org.apache. jsp.AdminUI_jsp:96)
          org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
          javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
          org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322)
          org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
          org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
          javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
          org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)


          please say me the reason ?

          Comment


          • #6
            there is something wrong with your database or query. Spring can't categorize the exception so you have to figure out why your OracleDS throughs "Invalid scale size".

            Comment


            • #7
              Sun rowset issue with Oracle 10g

              See post: http://forum.java.sun.com/thread.jspa?threadID=569712
              Let me know if you come up with a solution.

              Comment


              • #8
                Originally posted by rbirch View Post
                See post: http://forum.java.sun.com/thread.jspa?threadID=569712
                Let me know if you come up with a solution.
                Also see: http://forum.springframework.org/showthread.php?t=19848

                Comment

                Working...
                X