Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > acsess DB with struts:Error

Reply
Thread Tools

acsess DB with struts:Error

 
 
marcelino
Guest
Posts: n/a
 
      02-04-2004
Hi,

still I'm a newbie handling struts. I tried to expand the
struts-example with a mysql DB-Connection called test. I can access
the example-welcome-site, but trying to activate the link to my site I
become this error:

ERROR: User database not loaded -- check servlet container logs for
error messages.

In the logs I find this two striking errors:

1)
2004-02-04 19:13:44 StandardContext[/test_struts]: Servlet
/test_struts threw load() exception
javax.servlet.ServletException: Servlet.init() for servlet action
threw exception at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:963)
etc.

2)
----- Root Cause -----
java.lang.NoClassDefFoundError:
org/apache/struts/legacy/GenericDataSource at
java.lang.ClassLoader.defineClass0(Native Method)
etc.

The versions I tried to find the DataSource (xml see below) out of
TestAction.java:
1)
dataSource = servlet.findDataSource("org.apache.struts.action.D ATA_SOURCE");

DATA_SOURCE was the key easy-strus-editor generated- I changed it into
personDS - see DataSources- tags below.
After finding out method is deprecated tried with:
2)
dataSource = (DataSource)servlet.getServletContext().getAttribu te("org.apache.struts.action.DATA_SOURCE");
3)
dataSource = (DataSource)servlet.getServletContext().getAttribu te(Globals.DATA_SOURCE_KEY);
4)
dataSource = (DataSource)servlet.getServletContext().getAttribu te("personDS");

I tried it also with genericDS - still the same error!

This are my DataSources:

<!-- ========== Data Source Configuration
=============================== -->
<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource"
key="personDS">
<set-property property="driverClassName"
value="org.gjt.mm.mysql.Driver" />
<set-property property="url"
value="jdbc:mysql://localhost/protokollDB" />
<set-property property="username" value="root" />
<set-property property="password" />
<set-property property="maxActive" value="10" />
<set-property property="maxWait" value="5000" />
<set-property property="defaultAutoCommit" value="false" />
<set-property property="defaultReadOnly" value="false" />
<set-property property="validationQuery" value="SELECT * FROM
Person" />
</data-source>
<data-source type="org.apache.struts.util.GenericDataSource"
key="genericDS">
<set-property property="autoCommit" value="false" />
<set-property property="description" value="Example Data Source
Conf"/>
<set-property property="driverClass"
value="org.gjt.mm.mysql.Driver" />
<set-property property="maxCount" value="4" />
<set-property property="minCount" value="2" />
<set-property property="password" />
<set-property property="url"
value="jdbc:mysql://localhost/protokollDB" />
<set-property property="user" value="root" />
</data-source>
</data-sources>



I built the following files:

Interfaces:
myTable.java
myDB.java

actionBean:
TestAction.java

formBean:
TestForm.java

jsp:
testMyTable.jsp

struts-conf:

struts-conf-test.xml

whats wrong?
I would be very thankful for a hint.

thanks in advance

marcelino
 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      02-05-2004
marcelino wrote:
> Hi,
>
> still I'm a newbie handling struts. I tried to expand the
> struts-example with a mysql DB-Connection called test. I can access
> the example-welcome-site, but trying to activate the link to my site I
> become this error:
>
> ERROR: User database not loaded -- check servlet container logs for
> error messages.

<snip>

There is a method in the Action class called getDataSource. It requires
an HttpServletRequest as an argument and will optionally accept a key.
RTFM for details.

 
Reply With Quote
 
 
 
 
KD
Guest
Posts: n/a
 
      02-06-2004
Hi

There is a file (struts-legacy.jar) that is missing from your tomcat lib.

-Karim


marcelino wrote:

> Hi,
>
> still I'm a newbie handling struts. I tried to expand the
> struts-example with a mysql DB-Connection called test. I can access
> the example-welcome-site, but trying to activate the link to my site I
> become this error:
>
> ERROR: User database not loaded -- check servlet container logs for
> error messages.
>
> In the logs I find this two striking errors:
>
> 1)
> 2004-02-04 19:13:44 StandardContext[/test_struts]: Servlet
> /test_struts threw load() exception
> javax.servlet.ServletException: Servlet.init() for servlet action
> threw exception at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:963)
> etc.
>
> 2)
> ----- Root Cause -----
> java.lang.NoClassDefFoundError:
> org/apache/struts/legacy/GenericDataSource at
> java.lang.ClassLoader.defineClass0(Native Method)
> etc.
>
> The versions I tried to find the DataSource (xml see below) out of
> TestAction.java:
> 1)
> dataSource = servlet.findDataSource("org.apache.struts.action.D ATA_SOURCE");
>
> DATA_SOURCE was the key easy-strus-editor generated- I changed it into
> personDS - see DataSources- tags below.
> After finding out method is deprecated tried with:
> 2)
> dataSource = (DataSource)servlet.getServletContext().getAttribu te("org.apache.struts.action.DATA_SOURCE");
> 3)
> dataSource = (DataSource)servlet.getServletContext().getAttribu te(Globals.DATA_SOURCE_KEY);
> 4)
> dataSource = (DataSource)servlet.getServletContext().getAttribu te("personDS");
>
> I tried it also with genericDS - still the same error!
>
> This are my DataSources:
>
> <!-- ========== Data Source Configuration
> =============================== -->
> <data-sources>
> <data-source type="org.apache.commons.dbcp.BasicDataSource"
> key="personDS">
> <set-property property="driverClassName"
> value="org.gjt.mm.mysql.Driver" />
> <set-property property="url"
> value="jdbc:mysql://localhost/protokollDB" />
> <set-property property="username" value="root" />
> <set-property property="password" />
> <set-property property="maxActive" value="10" />
> <set-property property="maxWait" value="5000" />
> <set-property property="defaultAutoCommit" value="false" />
> <set-property property="defaultReadOnly" value="false" />
> <set-property property="validationQuery" value="SELECT * FROM
> Person" />
> </data-source>
> <data-source type="org.apache.struts.util.GenericDataSource"
> key="genericDS">
> <set-property property="autoCommit" value="false" />
> <set-property property="description" value="Example Data Source
> Conf"/>
> <set-property property="driverClass"
> value="org.gjt.mm.mysql.Driver" />
> <set-property property="maxCount" value="4" />
> <set-property property="minCount" value="2" />
> <set-property property="password" />
> <set-property property="url"
> value="jdbc:mysql://localhost/protokollDB" />
> <set-property property="user" value="root" />
> </data-source>
> </data-sources>
>
>
>
> I built the following files:
>
> Interfaces:
> myTable.java
> myDB.java
>
> actionBean:
> TestAction.java
>
> formBean:
> TestForm.java
>
> jsp:
> testMyTable.jsp
>
> struts-conf:
>
> struts-conf-test.xml
>
> whats wrong?
> I would be very thankful for a hint.
>
> thanks in advance
>
> marcelino

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control Acsess To Shared Docs =?Utf-8?B?UmljaGll?= Wireless Networking 4 11-08-2005 01:21 AM



Advertisments