请教一个struts+tomcat 数据源配置的问题

06-06-02 jinfan
初学struts,很多不懂,望高手指教!!

我用的是myeclipse + tomcat + mysql数据库,

下面是在struts项目中 struts-comfig.xml中数据源的配置

<data-sources>

<data-source key="oracleDB1" type="org.apache.commons.dbcp.BasicDataSource">

<set-property property="driverClassName"

value="org.gjt.mm.mysql.Driver" />

<set-property property="url"

value="jdbc:mysql://localhost/test" />

<set-property property="maxActive"

value="5"/>

<set-property property="username"

value="root"/>

<set-property property="password"

value="admin"/>

<set-property property="autoCommit"

value="true"/>

</data-source>

我在eclipse中启动tomcat时报下面的错误,

严重: Unable to initialize Struts ActionServlet due to an unexpected exception or error thrown, so marking the servlet as unavailable. Most likely, this is due to an incorrect or missing library dependency.

java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

at java.lang.Class.getDeclaredConstructors0(Native Method)

at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)

at java.lang.Class.getConstructor0(Class.java:2640)

at java.lang.Class.newInstance0(Class.java:321)

at java.lang.Class.newInstance(Class.java:303)

at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)

at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:803)

at org.apache.struts.action.ActionServlet.init(ActionServlet.java:333)

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:3917)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)

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:904)

at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)

at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)

at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)

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:1021)

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

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)

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:709)

at org.apache.catalina.startup.Catalina.start(Catalina.java:551)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)

2006-6-2 14:53:24 org.apache.catalina.core.ApplicationContext log

信息: Marking servlet actionServlet as unavailable

2006-6-2 14:53:24 org.apache.catalina.core.StandardContext loadOnStartup

严重: Servlet /Z_Begin threw load() exception

javax.servlet.UnavailableException: org/apache/commons/pool/impl/GenericObjectPool

at org.apache.struts.action.ActionServlet.init(ActionServlet.java:366)

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:3917)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)

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:904)

at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)

at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)

at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)

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:1021)

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

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)

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:709)

at org.apache.catalina.startup.Catalina.start(Catalina.java:551)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)

2006-6-2 14:53:24 org.apache.coyote.http11.Http11BaseProtocol start

说少了一个包,不知道少了哪个包,大家指点一下。谢谢了。

jinfan
2006-06-02 15:42
数据源是这样子的,刚才没有发上去!!

<data-sources>

<data-source key="oracleDB1" type="org.apache.commons.dbcp.BasicDataSource">

<set-property property="driverClassName"

value="org.gjt.mm.mysql.Driver" />

<set-property property="url"

value="jdbc:mysql://localhost/test" />

<set-property property="maxActive"

value="5"/>

<set-property property="username"

value="root"/>

<set-property property="password"

value="admin"/>

<set-property property="autoCommit"

value="true"/>

</data-source>

</data-sources>

jinfan
2006-06-02 15:45

<data-sources>
		<data-source key="oracleDB1" type="org.apache.commons.dbcp.BasicDataSource">
			<set-property property="driverClassName"	
				value="org.gjt.mm.mysql.Driver" />
			<set-property property="url"
				value="jdbc:mysql://localhost/test" />
			<set-property property="maxActive"
				value="5"/>
			<set-property property="username"
				value="root"/>
			<set-property property="password"
				value="admin"/>
			<set-property property="autoCommit"
				value="true"/>
		</data-source>
	</data-sources>

banq
2006-06-06 10:45
>org/apache/commons/pool/impl/GenericObjectPool

你将这个类打入Google搜索一下,就出现那个项目了,好像是Apache的commons-pool

jinfan
2006-06-07 16:56
谢谢!用这个jar后,这个问题可以过了!!

猜你喜欢