struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "red phoenix" <rodphoe...@gmail.com>
Subject Re: How to configure Struts connection pool
Date Sun, 02 Apr 2006 05:05:48 GMT
when I start Tomcat,it raise following error:
New org.apache.commons.dbcp.BasicDataSource
Begin event threw exception
java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass (
WebappClassLoader.java:1352)
at org.apache.catalina.loader.WebappClassLoader.loadClass(
WebappClassLoader.java:1198)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0 (Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.struts.digester.ObjectCreateRule.begin(ObjectCreateRule.java
:152)
at org.apache.struts.digester.Digester.startElement (Digester.java:528)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown
Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown
Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.struts.digester.Digester.parse(Digester.java:755)
at org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java
:1332)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:466)
at javax.servlet.GenericServlet.init(GenericServlet.java :211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java
:1105)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at org.apache.catalina.core.StandardContext.loadOnStartup (
StandardContext.java:3915)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4176)
at org.apache.catalina.core.ContainerBase.addChildInternal(
ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)

at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java
:910)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java
:873)
at org.apache.catalina.startup.HostConfig.deployApps (HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent (
LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start (StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java :275)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2006-4-2 8:40:02 org.apache.coyote.http11.Http11BaseProtocol start

My use Microsoff Access2000 Database,and I have configure in ODBC,why it
still above raise error?


On 4/2/06, Tarun Reddy <btarunreddy@gmail.com> wrote:
>
> Hi,
> First of all we need not use "key" attribute in <data-source> tag until we
> have more than one data source to be configured. So, try removing the
> "key"
> attribute and use the getDataSource() method which is already defined in
> DBCP.
> DataSource db = getDataSource(request);
> You need not worry about all the naming lookups. That method will take
> care of retrieving DataSource object . Even if you want to keep the "key"
> attribute, then try using this,
> DataSource db= getDataSource(request,key);
>
> This should work for you. Let me know if you still face any issues.
>
> Thanks,
> Tarun.
>
>
> On 4/1/06, red phoenix <rodphoenix@gmail.com> wrote:
> >
> > I use struts-1.2.9,and want to configure a connection pool,so I
> configure
> > struts-config.xml file
> > <struts-config>
> > <data-source key="bb1" type="org.apache.commons.dbcp.BasicDataSource">
> > <set-property property="driverClassName" value="
> > sun.jdbc.odbc.JdbcOdbcDriver" />
> > <set-property property="url" value="jdbc:odbc:SMS"/>
> > <set-property property="maxActive" value="5" />
> > <set-property property="username" value="administrator" />
> > <set-property property="password" value="123" />
> > <set-property property="autoCommit" value="true" />
> > </data-source>
> > ....
> > </struts-config>
> >
> > Then I use this configure in a jsp file,like follows:
> > <%@page import="java.sql.*"%>
> > <%@page import="javax.sql.DataSource"%>
> > <%@page import="javax.naming.*"%>
> > <html>
> > <body>
> > <%
> > try{
> > Context initCtx=new InitialContext();
> > System.out.println("ok");
> > DataSource db = (DataSource)initCtx.lookup("java:comp/env/jdbc/bb1");
> > System.out.println("db="+db);
> > Connection conn = db.getConnection();
> > System.out.println("conn="+conn);
> > Statement stmt = conn.createStatement();
> > ResultSet rs = stmt.executeQuery("SELECT * FROM abc");
> > out.println("User-list"+"<br>");
> > while(rs.next()){
> >   out.print(rs.getString(1)+"<br>");
> > }
> > rs.close();
> > stmt.close();
> > conn.close();
> > }catch(Exception e){
> > out.print(e);
> > }
> > %>
> > </body>
> > </html>
> >
> > When I run this jsp file,it raise follow errors:
> > javax.naming.NameNotFoundException: Name jdbc is not bound in this
> Context
> >
> > Where error is in my code? Please give me some examples about how to
> > configure connection pool in Struts and how to call this connection in
> JSP
> > file and JavaBean.
> >
> > Thanks in advance!
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message