You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Felix von Delius <fv...@t-online.de> on 2001/06/13 12:13:57 UTC

struts-example and resin-1.2.7 under linux

I'm having trouble to bring the struts-example application to work with resin-1.2.7 under linux. With Win2K it runs just fine, but when doing the same installation under linux, I always catch the exceptions appended at the end of this mail.

According to Scott Ferguson (developer of resin), this is a bug in struts, here a quote from the resin mailinglist:

>It's a struts bug.
>
>The current struts code looks like:
>
>   Class clazz = Class.forName(actionClass);
>
>It should be rewritten to be:
>
>   ClassLoader loader = Thread.currentThread().getContextClassLoader();
>   Class clazz = Class.forName(actionClass, true, loader);

Is this verified by someone else? Is this problem known to the struts people and will it be fixed in the nightly build binary release?

Thanks!

-Felix


[2001/06/12 18:39:50] org.apache.struts.webapp.example.DatabaseServlet: init
[2001/06/12 18:39:50] org.apache.struts.webapp.example.DatabaseServlet: Initializing database servlet
[2001/06/12 18:39:50] org.apache.struts.webapp.example.DatabaseServlet: Loading database from '/WEB-INF/database.xml'
[2001/06/12 18:39:51] org.apache.struts.webapp.example.DatabaseServlet: Database load exception
java.lang.ClassNotFoundException: org.apache.struts.webapp.example.User
        at org.apache.struts.digester.Digester.startElement(Digester.java:531)
        at com.caucho.xml.ContentHandlerAdapter.startElement(ContentHandlerAdapter.java:100)
        at com.caucho.xml.XmlParser.addElement(XmlParser.java:800)
        at com.caucho.xml.XmlParser.parseElement(XmlParser.java:520)
        at com.caucho.xml.XmlParser.parseNode(XmlParser.java:325)
        at com.caucho.xml.XmlParser.parseInt(XmlParser.java:178)
        at com.caucho.xml.AbstractParser.parseDocument(AbstractParser.java:503)
        at com.caucho.xml.AbstractParser.parse(AbstractParser.java:403)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:117)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:71)
        at org.apache.struts.digester.Digester.parse(Digester.java:755)
        at org.apache.struts.webapp.example.DatabaseServlet.load(DatabaseServlet.java:251)
        at org.apache.struts.webapp.example.DatabaseServlet.init(DatabaseServlet.java:175)
        at javax.servlet.GenericServlet.init(GenericServlet.java:52)
        at com.caucho.server.http.Application.createServlet(Application.java:1741)
        at com.caucho.server.http.Application.loadServlet(Application.java:1705)
        at com.caucho.server.http.Application.initServlets(Application.java:1122)
        at com.caucho.server.http.Application.init(Application.java:1075)
        at com.caucho.server.http.VirtualHost.init(VirtualHost.java:382)
        at com.caucho.server.http.ServletServer.initHosts(ServletServer.java:439)
        at com.caucho.server.http.ServletServer.init(ServletServer.java:343)
        at com.caucho.server.http.ServletServer.<init>(ServletServer.java:186)
        at com.caucho.server.http.ResinServer.init(ResinServer.java:286)
        at com.caucho.server.http.ResinServer.main(ResinServer.java:868)
        at com.caucho.server.http.HttpServer.main(HttpServer.java:93)
[2001/06/12 18:39:51] Cannot load database from '/WEB-INF/database.xml'
javax.servlet.UnavailableException: Cannot load database from '/WEB-INF/database.xml'
        at org.apache.struts.webapp.example.DatabaseServlet.init(DatabaseServlet.java:180)
        at javax.servlet.GenericServlet.init(GenericServlet.java:52)
        at com.caucho.server.http.Application.createServlet(Application.java:1741)
        at com.caucho.server.http.Application.loadServlet(Application.java:1705)
        at com.caucho.server.http.Application.initServlets(Application.java:1122)
        at com.caucho.server.http.Application.init(Application.java:1075)
        at com.caucho.server.http.VirtualHost.init(VirtualHost.java:382)
        at com.caucho.server.http.ServletServer.initHosts(ServletServer.java:439)
        at com.caucho.server.http.ServletServer.init(ServletServer.java:343)
        at com.caucho.server.http.ServletServer.<init>(ServletServer.java:186)
        at com.caucho.server.http.ResinServer.init(ResinServer.java:286)
        at com.caucho.server.http.ResinServer.main(ResinServer.java:868)
        at com.caucho.server.http.HttpServer.main(HttpServer.java:93)



important tip for installing struts within resin!

Posted by Felix von Delius <fv...@t-online.de>.
Now I found a reason for my trouble: I had a copy of struts.jar in $RESIN_HOME/lib instead of having it only in my application's WEB-INF/lib. This caused resin not to find any application classes. After deleting struts.jar from $RESIN_HOME/lib everything works fine.

It costs me half a day to find out, so I hope this hint prevents some of you from wasting your time!

-Felix

On Wed, Jun 13, 2001 at 12:13:57PM +0200, Felix von Delius wrote:
> I'm having trouble to bring the struts-example application to work with resin-1.2.7 under linux. With Win2K it runs just fine, but when doing the same installation under linux, I always catch the exceptions appended at the end of this mail.
> 
> According to Scott Ferguson (developer of resin), this is a bug in struts, here a quote from the resin mailinglist:
> 
> >It's a struts bug.
> >
> >The current struts code looks like:
> >
> >   Class clazz = Class.forName(actionClass);
> >
> >It should be rewritten to be:
> >
> >   ClassLoader loader = Thread.currentThread().getContextClassLoader();
> >   Class clazz = Class.forName(actionClass, true, loader);
> 
> Is this verified by someone else? Is this problem known to the struts people and will it be fixed in the nightly build binary release?
> 
> Thanks!
> 
> -Felix
> 
> 
> [2001/06/12 18:39:50] org.apache.struts.webapp.example.DatabaseServlet: init
> [2001/06/12 18:39:50] org.apache.struts.webapp.example.DatabaseServlet: Initializing database servlet
> [2001/06/12 18:39:50] org.apache.struts.webapp.example.DatabaseServlet: Loading database from '/WEB-INF/database.xml'
> [2001/06/12 18:39:51] org.apache.struts.webapp.example.DatabaseServlet: Database load exception
> java.lang.ClassNotFoundException: org.apache.struts.webapp.example.User
>         at org.apache.struts.digester.Digester.startElement(Digester.java:531)
>         at com.caucho.xml.ContentHandlerAdapter.startElement(ContentHandlerAdapter.java:100)
>         at com.caucho.xml.XmlParser.addElement(XmlParser.java:800)
>         at com.caucho.xml.XmlParser.parseElement(XmlParser.java:520)
>         at com.caucho.xml.XmlParser.parseNode(XmlParser.java:325)
>         at com.caucho.xml.XmlParser.parseInt(XmlParser.java:178)
>         at com.caucho.xml.AbstractParser.parseDocument(AbstractParser.java:503)
>         at com.caucho.xml.AbstractParser.parse(AbstractParser.java:403)
>         at javax.xml.parsers.SAXParser.parse(SAXParser.java:117)
>         at javax.xml.parsers.SAXParser.parse(SAXParser.java:71)
>         at org.apache.struts.digester.Digester.parse(Digester.java:755)
>         at org.apache.struts.webapp.example.DatabaseServlet.load(DatabaseServlet.java:251)
>         at org.apache.struts.webapp.example.DatabaseServlet.init(DatabaseServlet.java:175)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:52)
>         at com.caucho.server.http.Application.createServlet(Application.java:1741)
>         at com.caucho.server.http.Application.loadServlet(Application.java:1705)
>         at com.caucho.server.http.Application.initServlets(Application.java:1122)
>         at com.caucho.server.http.Application.init(Application.java:1075)
>         at com.caucho.server.http.VirtualHost.init(VirtualHost.java:382)
>         at com.caucho.server.http.ServletServer.initHosts(ServletServer.java:439)
>         at com.caucho.server.http.ServletServer.init(ServletServer.java:343)
>         at com.caucho.server.http.ServletServer.<init>(ServletServer.java:186)
>         at com.caucho.server.http.ResinServer.init(ResinServer.java:286)
>         at com.caucho.server.http.ResinServer.main(ResinServer.java:868)
>         at com.caucho.server.http.HttpServer.main(HttpServer.java:93)
> [2001/06/12 18:39:51] Cannot load database from '/WEB-INF/database.xml'
> javax.servlet.UnavailableException: Cannot load database from '/WEB-INF/database.xml'
>         at org.apache.struts.webapp.example.DatabaseServlet.init(DatabaseServlet.java:180)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:52)
>         at com.caucho.server.http.Application.createServlet(Application.java:1741)
>         at com.caucho.server.http.Application.loadServlet(Application.java:1705)
>         at com.caucho.server.http.Application.initServlets(Application.java:1122)
>         at com.caucho.server.http.Application.init(Application.java:1075)
>         at com.caucho.server.http.VirtualHost.init(VirtualHost.java:382)
>         at com.caucho.server.http.ServletServer.initHosts(ServletServer.java:439)
>         at com.caucho.server.http.ServletServer.init(ServletServer.java:343)
>         at com.caucho.server.http.ServletServer.<init>(ServletServer.java:186)
>         at com.caucho.server.http.ResinServer.init(ResinServer.java:286)
>         at com.caucho.server.http.ResinServer.main(ResinServer.java:868)
>         at com.caucho.server.http.HttpServer.main(HttpServer.java:93)
> 
> 

Re: struts-example and resin-1.2.7 under linux

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 13 Jun 2001, Felix von Delius wrote:

> I'm having trouble to bring the struts-example application to work with resin-1.2.7 under linux. With Win2K it runs just fine, but when doing the same installation under linux, I always catch the exceptions appended at the end of this mail.
> 
> According to Scott Ferguson (developer of resin), this is a bug in struts, here a quote from the resin mailinglist:
> 
> >It's a struts bug.
> >
> >The current struts code looks like:
> >
> >   Class clazz = Class.forName(actionClass);
> >
> >It should be rewritten to be:
> >
> >   ClassLoader loader = Thread.currentThread().getContextClassLoader();
> >   Class clazz = Class.forName(actionClass, true, loader);
> 
> Is this verified by someone else? Is this problem known to the struts people and will it be fixed in the nightly build binary release?
> 

There's a current Bugzilla bug report about this
(http://nagoya.apache.org/bugzilla and then look up bug number 2009).  
I'm considering doing something about it (there are roughly five more
cases where you'd have to do the same thing), but I'd appreciate it if you
could verify something first.

Do you have struts.jar in your system classpath, instead of in
/WEB-INF/lib?  If so, that is *strictly* prohibited by the documentation,
and causes exactly the problem you are seeing.

The problem with relying on the context class loader is that, in a servlet
2.2 container, it is not *required* that this be the same as the web app
class loader (although this is very common).  Thus, making a change to use
it runs the risk of breaking existing applications on containers that
don't use the context class loader this way.

In servlet 2.3 (actually, in the J2EE 1.3 platform spec), it is likely
that the context class loader will be required to operate in a manner that
the above code would be safe.  Until then, though, I'm more than a little
hesitant.

> Thanks!
> 
> -Felix
> 

Craig McClanahan


Re: Struts Datasource problem

Posted by Martin Cooper <ma...@tumbleweed.com>.
Are you the only person connecting to the database with this driver? One of
the unusual things about the demo version of Sprinta is that the connection
limit is per database server, not per client. So if two other people already
have one connection each open to the same database, you will see this error
when you try to open your connection.

Hope this helps.

--
Martin Cooper


----- Original Message -----
From: "Bill Clinton" <bc...@snipermail.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, June 13, 2001 1:47 PM
Subject: Struts Datasource problem


> Hello,
>      I am having a recurring problem with struts and jdbc.  The demo
> driver I am using, inet's Sprinta200, only allows 2 connections.  I have
> my data source max set to 1, but I still get errors from the driver:
>
> java.sql.SQLException: [TDS Driver]Too many connections :3
> at com.inet.tds.e.<init>(Unknown Source)
> at com.inet.tds.TdsDriver.connect(Unknown Source)
> at
>
org.apache.struts.util.GenericDataSource.createConnection(GenericDataSource.
java:731)
> at
org.apache.struts.util.GenericDataSource.open(GenericDataSource.java:668)
> at
>
org.apache.struts.action.ActionServlet.initDataSources(ActionServlet.java:10
77)
> at org.apache.struts.action.ActionServlet.init(ActionServlet.java:471)
> at javax.servlet.GenericServlet.init(GenericServlet.java:52)
> at com.caucho.server.http.Application.createServlet(Application.java:1741)
> ___________________________________________
>
> this is how I have it set up in my struts-config:
>
> <data-source>
>    <set-property property="autoCommit" value="false"/>
>    <set-property property="description" value="I-Net Sprinta2000"/>
>    <set-property property="driverClass" value="com.inet.tds.TdsDriver"/>
>    <set-property property="maxCount" value="1"/>
>    <set-property property="minCount" value="1"/>
>    <set-property property="password" value="password"/>
>    <set-property property="url"value="jdbc:inetdae7a:192.168.0.20:1433/>
>    <set-property property="user" value="sa"/>
> </data-source>
>
>
> I sometimes get this problem right after I stop and start resin and
> bring up a JSP that doesn't even use a connection.  Any ideas?
>
> Bill
>



Struts Datasource problem

Posted by Bill Clinton <bc...@snipermail.com>.
Hello,
     I am having a recurring problem with struts and jdbc.  The demo 
driver I am using, inet's Sprinta200, only allows 2 connections.  I have 
my data source max set to 1, but I still get errors from the driver:

java.sql.SQLException: [TDS Driver]Too many connections :3
at com.inet.tds.e.<init>(Unknown Source)
at com.inet.tds.TdsDriver.connect(Unknown Source)
at 
org.apache.struts.util.GenericDataSource.createConnection(GenericDataSource.java:731)
at org.apache.struts.util.GenericDataSource.open(GenericDataSource.java:668)
at 
org.apache.struts.action.ActionServlet.initDataSources(ActionServlet.java:1077)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:471)
at javax.servlet.GenericServlet.init(GenericServlet.java:52)
at com.caucho.server.http.Application.createServlet(Application.java:1741)
___________________________________________

this is how I have it set up in my struts-config:

<data-source>
   <set-property property="autoCommit" value="false"/>
   <set-property property="description" value="I-Net Sprinta2000"/>
   <set-property property="driverClass" value="com.inet.tds.TdsDriver"/>
   <set-property property="maxCount" value="1"/>
   <set-property property="minCount" value="1"/>
   <set-property property="password" value="password"/>
   <set-property property="url"value="jdbc:inetdae7a:192.168.0.20:1433/>
   <set-property property="user" value="sa"/>
</data-source>


I sometimes get this problem right after I stop and start resin and 
bring up a JSP that doesn't even use a connection.  Any ideas?

Bill


Re: struts-example and resin-1.2.7 under linux

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 13 Jun 2001, Felix von Delius wrote:

> I'm having trouble to bring the struts-example application to work
> with resin-1.2.7 under linux. With Win2K it runs just fine, but when
> doing the same installation under linux, I always catch the exceptions
> appended at the end of this mail.
> 
> According to Scott Ferguson (developer of resin), this is a bug in
> struts, here a quote from the resin mailinglist:
> 
> >It's a struts bug.
> >
> >The current struts code looks like:
> >
> >   Class clazz = Class.forName(actionClass);
> >
> >It should be rewritten to be:
> >
> >   ClassLoader loader = Thread.currentThread().getContextClassLoader();
> >   Class clazz = Class.forName(actionClass, true, loader);
> 
> Is this verified by someone else? Is this problem known to the struts
> people and will it be fixed in the nightly build binary release?
> 
> Thanks!
> 
> -Felix
> 

Calling it a "bug" is not accurate.  What Scott wants Struts to do is rely
on a feature of many (but not all) servlet containers -- setting the
thread context class loader to be the web app class loader.

In servlet 2.2 this is ***NOT*** guaranteed to be portable, so making this
change would cause Struts apps to fail on a servlet container that did not
do it.  It's likely that it will be mandated in servlet 2.3 (because it
will actually be mandated in the J2EE 1.3 platform spec).  Until then, I'm
not going to introduce a non-portable dependency into Struts.

Besides, the real answer is to take struts.jar out of your classpath, as
the Struts documentation stresses -- it should be in /WEB-INF/lib.  
That's what is really causing the problem.

Craig McClanahan