• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating genric Action class for lib

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Mike Glickman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would the server know where to find the struts classes? They are not deployed with the applications.
Thanks,
Mike.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic