Solved

Problems with database connecting in Struts

Posted on 2003-11-14
5
736 Views
Last Modified: 2010-03-31
struts config looks like this:

...
      <data-sources>
            <data-source>
                  <set-property property="driverClass"
                                    value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />
                  <set-property property="url"
                                    value="jdbc:microsoft:sqlserver://i-prime:1433;databaseName=cca" />
                  <set-property property="maxCount"
                                    value="50"/>
                  <set-property property="minCount"
                                    value="1"/>
                  <set-property property="user"
                                    value="cca"/>
                  <set-property property="password"
                                    value="cca"/>
            </data-source>
      </data-sources>
...

and I get this message :

javax.servlet.ServletException: Servlet.init() for servlet action threw exception
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:963)
      at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:668)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
      at java.lang.Thread.run(Thread.java:534)


root cause

java.lang.NoClassDefFoundError: org/apache/struts/legacy/GenericDataSource
      at java.lang.ClassLoader.defineClass0(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
      at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1679)
      at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:968)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1409)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1289)
      at org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.java:207)
      at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:231)
      at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1079)
      at org.apache.struts.action.ActionServlet.init(ActionServlet.java:471)
      at javax.servlet.GenericServlet.init(GenericServlet.java:256)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:935)
      at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:668)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
      at java.lang.Thread.run(Thread.java:534)


Does anybody know what is the problem?
0
Comment
Question by:milosr
  • 2
  • 2
5 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 100 total points
ID: 9747464
Have you copied the struts-legacy.jar file into your classpath?
0
 

Author Comment

by:milosr
ID: 9754458
I' m not on my job now, and I dont know.
I will see in mondey.

What is for struts-legacy.jar?
0
 

Author Comment

by:milosr
ID: 9776882
Yes, that was the problem.
Thank you!
0
 

Expert Comment

by:smitha_ajay
ID: 9778194
I had a similar problem and it got resolved by copying the struts-legacy.jar file into the classpath. Thanks Tim for the suggestion.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9778206
:-) Glad I could help :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumHeights2  challenge 7 76
java continue statement 10 72
powerN  challenge 3 47
changeXy challenge 13 57
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now