aspose file tools*
The moose likes Struts and the fly likes struts-core-2.0.11.2.jar on two places on the server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts-core-2.0.11.2.jar on two places on the server" Watch "struts-core-2.0.11.2.jar on two places on the server" New topic
Author

struts-core-2.0.11.2.jar on two places on the server

Ylva Degerfeldt
Ranch Hand

Joined: Feb 12, 2008
Posts: 30
Hi everyone,

I'm trying to learn and use Struts 2 (actually migrating from Struts 1 to 2) and I have written lots of java and xml code, which should be working. I just can't run the application! When I try to, I get this
exception:

Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with
the name xwork has already been loaded by bean -
jar:file:/C:/Sun/AppServer/domains/domain1/applications/j2ee-apps/Extract_to_cv_2/struts2-core-2.0.11.2.jar!/struts-default.xml:30:72
- bean - jar:file:/C:/Sun/AppServer/domains/domain1/applications/j2ee-apps/Extract_to_cv_2/Extract_to_cv_2-war_war/WEB-INF/lib/struts2-core-2.0.11.2.jar!/struts-default.xml:30:72

As the exception said, I found that the struts-core-2.0.11.2.jar file
was located in two places under my application on the server. I tried
to remove the topmost copy of the file but when I tried running the
app. again I got the same exception, and found that the file had been
put back there. Then I tried to remove the struts-core.. file that was
further down, but the same thing happened! (the same exception and the
file had been returned to that location as well).

I'm using NetBeans 5.5.1 and Sun Java System Application Server 9 and
my application is an enterprise application with a web module and an
ejb module. I'm wondering whether this problem is due to that I have
the struts2 jars in both the lib directory of the ejb module and the
lib directory of the web module. This might be stupid, but I needed
the ejb module to know about the struts classes as well and didn't
know how to make them visible to the whole application.

But then again, this (having struts jars in both modules) actually
worked when I was using Struts 1.

I'm really confused about this and I'm hoping that someone can help
me! Maybe this is mostly a NetBeans issue so if someone who has used
NetBeans could answer it would be great.

I feel completely lost when it comes to this kind of things (what's
happening "behind the scenes" in NetBeans and the app. server) but I'm
willing to learn from anyone who wants to explain it to me. But please
explain it very thoroughly then.

Please help me! I'm stuck.

/Ylva
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
To me the ideal solution would be to refactor your application to remove the dependency on Struts in the EJB layer. The EJB layer is part of the model and in an MVC architecture, the model shouldn't have a dependency on a view framework such as Struts.

If you're not willing to do that, I'd suggest putting the Struts 2 jar files in the EAR file. You can then create a dependency for both the EJB and the web modules on those jar files.


Merrill
Consultant, Sima Solutions
Ylva Degerfeldt
Ranch Hand

Joined: Feb 12, 2008
Posts: 30
Thanks for your answer, Merrill!

You're right. I shouldn't have a Struts dependency in the EJB layer, so I managed to remove it (and removed all the struts related jars from the lib).

Though, that didn't help (which I was afraid would be the case). I still get the same exception, about the struts2-core-2.0.11.2.jar being in two places and I still can't remove it from either place.

Is there some sort of configuration file somewhere which has a redundant specification of the location of the struts2-core.. file?

Please help me with this!! I have no clue what to do and I really need to move on with and finish this project soon (for financial reasons)!

Thanks!

/Ylva
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The only other thing I can think of is to look in the Sun App Server's shared libraries and see if any of the struts jar files are declared there.
Ylva Degerfeldt
Ranch Hand

Joined: Feb 12, 2008
Posts: 30
Thanks again, Merrill!

I actually solved that problem. I had been stupid enough to only "Build Main project" and never do "Clean and Build..". When I did that the problem with the two places disappeared. (The struts2-core.. file disappeared from the topmost place on the server)

Now I have run into new Struts problems, but I think that has to be a new thread.

Thanks for now!

/Ylva
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts-core-2.0.11.2.jar on two places on the server