论坛首页 入门技术论坛

请教:关于tomcat中配置JNDI的问题。

浏览 11105 次
该帖已经被评为新手帖
作者 正文
   发表时间:2006-12-25  
下面是错误提示。下面还有我的TOMCAT配置文件。(是通过tomcat图形页面生成的)
请各位 。小弟(本人人品低连代码都欺负人)。谢谢。


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /jndiTest.jsp:10

7: <%
8:   
9:  Context initCtx = new InitialContext();
10: DataSource ds = (DataSource)initCtx.lookup("java:comp/env/dbc/Test");
11:
12: Connection conn = ds.getConnection();
13: conn.close();


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.ServletException: Name dbc is not bound in this Context
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.jndiTest_jsp._jspService(jndiTest_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.naming.NameNotFoundException: Name dbc is not bound in this Context
org.apache.naming.NamingContext.lookup(NamingContext.java:769)
org.apache.naming.NamingContext.lookup(NamingContext.java:139)
org.apache.naming.NamingContext.lookup(NamingContext.java:780)
org.apache.naming.NamingContext.lookup(NamingContext.java:139)
org.apache.naming.NamingContext.lookup(NamingContext.java:780)
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
javax.naming.InitialContext.lookup(InitialContext.java:351)
org.apache.jsp.jndiTest_jsp._jspService(jndiTest_jsp.java:55)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.


tomcat配置文件
---------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Server>
  <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
  <GlobalNamingResources>
    <Environment
      name="simpleValue"
      type="java.lang.Integer"
      value="30"/>
    <Resource
      auth="Container"
      description="User database that can be updated and saved"
      name="UserDatabase"
      type="org.apache.catalina.UserDatabase"
      pathname="conf/tomcat-users.xml"
      factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
    <Resource
      name="jdbc/Test"
      type="javax.sql.DataSource"
      password="tiger"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      maxIdle="2"
      maxWait="5000"
      username="scott"
      url="jdbc:oracle:thin:@10.164.11.226:1521:dbserver"
      maxActive="4"/>
  </GlobalNamingResources>
  <Service
      name="Catalina">
    <Connector
        port="8090"
        redirectPort="8443"
        minSpareThreads="25"
        connectionTimeout="20000"
        maxSpareThreads="75"
        maxThreads="150">
    </Connector>
    <Connector
        port="8009"
        redirectPort="8443"
        protocol="AJP/1.3">
    </Connector>
    <Engine
        defaultHost="localhost"
        name="Catalina">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
      <Host
          appBase="webapps"
          name="localhost">
      </Host>
    </Engine>
  </Service>
</Server>


   发表时间:2006-12-25  
likenice 写道
下面是错误提示。下面还有我的TOMCAT配置文件。(是通过tomcat图形页面生成的)
请各位 。小弟(本人人品低连代码都欺负人)。谢谢。


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /jndiTest.jsp:10

7: <%
8:   
9:  Context initCtx = new InitialContext();
10: DataSource ds = (DataSource)initCtx.lookup("java:comp/env/dbc/Test");//你声明的叫这个名子"jdbc/Oracle"
11:
12: Connection conn = ds.getConnection();
13: conn.close();


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.ServletException: Name dbc is not bound in this Context
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.jndiTest_jsp._jspService(jndiTest_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.naming.NameNotFoundException: Name dbc is not bound in this Context
org.apache.naming.NamingContext.lookup(NamingContext.java:769)
org.apache.naming.NamingContext.lookup(NamingContext.java:139)
org.apache.naming.NamingContext.lookup(NamingContext.java:780)
org.apache.naming.NamingContext.lookup(NamingContext.java:139)
org.apache.naming.NamingContext.lookup(NamingContext.java:780)
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
javax.naming.InitialContext.lookup(InitialContext.java:351)
org.apache.jsp.jndiTest_jsp._jspService(jndiTest_jsp.java:55)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.


tomcat配置文件
---------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Server>
  <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
  <GlobalNamingResources>
    <Environment
      name="simpleValue"
      type="java.lang.Integer"
      value="30"/>
    <Resource
      auth="Container"
      description="User database that can be updated and saved"
      name="UserDatabase"
      type="org.apache.catalina.UserDatabase"
      pathname="conf/tomcat-users.xml"
      factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
    <Resource
      name="jdbc/Oracle"
      type="javax.sql.DataSource"
      password="tiger"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      maxIdle="2"
      maxWait="5000"
      username="scott"
      url="jdbc:oracle:thin:@10.164.11.226:1521:dbserver"
      maxActive="4"/>
  </GlobalNamingResources>
  <Service
      name="Catalina">
    <Connector
        port="8090"
        redirectPort="8443"
        minSpareThreads="25"
        connectionTimeout="20000"
        maxSpareThreads="75"
        maxThreads="150">
    </Connector>
    <Connector
        port="8009"
        redirectPort="8443"
        protocol="AJP/1.3">
    </Connector>
    <Engine
        defaultHost="localhost"
        name="Catalina">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
      <Host
          appBase="webapps"
          name="localhost">
      </Host>
    </Engine>
  </Service>
</Server>


0 请登录后投票
   发表时间:2006-12-25  
不好意思。我删错了。上面的本来有一个
<Resource
name="jdbc/Test"
type="javax.sql.DataSource"
password="tiger"
driverClassName="oracle.jdbc.driver.OracleDriver"
maxIdle="2"
maxWait="5000"
username="scott"
url="jdbc:oracle:thin:@10.164.11.226:1521:dbserver"
maxActive="4"/>
我给误删了。应该不是这方面的问题。请在考虑下还可能是哪方面的问题。
0 请登录后投票
   发表时间:2006-12-25  
Name dbc is not bound in this Context
0 请登录后投票
   发表时间:2006-12-25  
javax.naming.NameNotFoundException: Name dbc is not bound in this Context
0 请登录后投票
   发表时间:2006-12-25  
本人在次道歉。
由于仓促。没有检查。
下面是真正的错误提示。请高手们指点。不会在有错了。


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /jndiTest.jsp:12

9:  Context initCtx = new InitialContext();
10: DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/Oracle");
11:
12: Connection conn = ds.getConnection();
13: conn.close();
14: 
15: System.out.println("123");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.ServletException: Cannot create PoolableConnectionFactory (ORA-28000: the account is locked
)
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.jndiTest_jsp._jspService(jndiTest_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ORA-28000: the account is locked
)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
org.apache.jsp.jndiTest_jsp._jspService(jndiTest_jsp.java:57)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.17

tomcat配置文件
---------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Server>
  <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
  <GlobalNamingResources>
    <Environment
      name="simpleValue"
      type="java.lang.Integer"
      value="30"/>
    <Resource
      auth="Container"
      description="User database that can be updated and saved"
      name="UserDatabase"
      type="org.apache.catalina.UserDatabase"
      pathname="conf/tomcat-users.xml"
      factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
<Resource
      name="jdbc/Oracle"
      type="javax.sql.DataSource"
      password="tiger"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      maxIdle="2"
      maxWait="5000"
      username="scott"
      url="jdbc:oracle:thin:@10.164.11.226:1521:dbserver"
      maxActive="4"/>
    <Resource
      name="jdbc/Test"
      type="javax.sql.DataSource"
      password="tiger"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      maxIdle="2"
      maxWait="5000"
      username="scott"
      url="jdbc:oracle:thin:@10.164.11.226:1521:dbserver"
      maxActive="4"/>
  </GlobalNamingResources>
  <Service
      name="Catalina">
    <Connector
        port="8090"
        redirectPort="8443"
        minSpareThreads="25"
        connectionTimeout="20000"
        maxSpareThreads="75"
        maxThreads="150">
    </Connector>
    <Connector
        port="8009"
        redirectPort="8443"
        protocol="AJP/1.3">
    </Connector>
    <Engine
        defaultHost="localhost"
        name="Catalina">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
      <Host
          appBase="webapps"
          name="localhost">
      </Host>
    </Engine>
  </Service>
</Server>


0 请登录后投票
   发表时间:2006-12-25  
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ORA-28000: the account is locked
)
0 请登录后投票
   发表时间:2006-12-25  
Cannot create PoolableConnectionFactory (ORA-28000: the account is locked)

先只留一个数据源。。。。。
其它的数据源先用注释注了。。。 <!--    -->
看着像是连接被锁了。。。


用用google看看有什么启示。。。

http://www.easyjf.com/html/bbs/20060419/23993816-1316542.htm
http://peter-kong.iteye.com/blog/39307
0 请登录后投票
   发表时间:2006-12-25  
不行呀。我关掉其他了所有的程序。删除了jdbc/Test。测试还是不行。同样的错误。去google也没什么收获。我用的是公司的测试数据库,回去自己在装个ORACLE吧。 谢谢 "抛出异常的爱" 的细心指点。 
0 请登录后投票
   发表时间:2006-12-25  
ORA-28000: the account is locked

unlock:alter user 用户名 account unlock;
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics