my dog learned polymorphism*
The moose likes Struts and the fly likes Creating genric Action class for lib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Creating genric Action class for lib" Watch "Creating genric Action class for lib" New topic
Author

Creating genric Action class for lib

Mike Glickman
Greenhorn

Joined: Dec 28, 2003
Posts: 7
I am trying to create a generic action class, which allows developers to extend it and overwrite the execute method. The structure is something like:
GenericAction extends Action -- resides in a global.jar file which is part of the server classpath
//Contains methods that will be inherited
MyAction extend GenricAction -- resides in a application
//overwrite execute method and some other stuff
A problem occurs when I run MyAction, I receive an error telling me that I cannot load 'Action' class. If I add the struts libraries to that global.jar file, the error goes away.
There is one problem with this, struts libraries are in two places (global.jar) and in the server classpath. Is there a way to do this and not have the struts libraries in two places?
Thank you,
Mike.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

struts.jar should not be in your server classpath; it will confuse your server.
< Server with struts.jar classpath
< Server without the classpath

You do still need it for the classpath used by your compiler.


A good workman is known by his tools.
Mike Glickman
Greenhorn

Joined: Dec 28, 2003
Posts: 7
How would the server know where to find the struts classes? They are not deployed with the applications.
Thanks,
Mike.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

To quote Struts site,
lib/struts.jar - This JAR file contains all of the Java classes included in Struts. It should be copied into the WEB-INF/lib directory of your web application. WARNING - If you are going to be hosting multiple Struts based applications on the same servlet container, you will be tempted to place the struts.jar file into the shared repository supported by your container. Be advised that this will like cause you to encounter ClassNotFoundException problems unless all of your application classes are stored in the shared repository.

What Development Environment are you using that does not include struts.jar in the exporting of deployment file?
Mike Glickman
Greenhorn

Joined: Dec 28, 2003
Posts: 7
Oracle IAS v2 running on a middle-tier arch. with Orion servers (J2EE), we use a shared repository which allows all of our applications (Production/Enterprise) to access the same struts libraries (no need to update all applications if a change is needed). How does this affect extending a struts action, placing that class (C1) in a common library and then extending that class (C1) in a local application?
Thanks Mike.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

A problem occurs when I run MyAction, I receive an error telling me that I cannot load 'Action' class. If I add the struts libraries to that global.jar file, the error goes away.
That should be the first clue that the server classpath is not doing "what it should". The quote of the Struts site says why.
Is there a way to do this and not have the struts libraries in two places?
I think I answered that. I get the feeling you'd rather have an answer of how to make your server classpath do what you want it to. That I can't do much about other than to suggest dumping your application code into the shared resources along with it.
Mike Glickman
Greenhorn

Joined: Dec 28, 2003
Posts: 7
"I get the feeling you'd rather have an answer of how to make your server classpath do what you want it to"
That triggered me to check the setting for the server, someone changed the setting on the server to read from the application/jar first and then the repository; changed it to the other way and all works now.
Thank you,
Mike.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Creating genric Action class for lib