• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to load struts2-core-2.1.8.1.jar!/struts-default.xml:29:72  RSS feed

 
Pramod Kumar Pandey
Ranch Hand
Posts: 52
Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir I pasted all struts2 jar file in build path of my project and in the lib folder under WEB-INF , but It is showing HTTP 404-/ProjectName/ Showing stack trace as follows :
Is there any side effect of adding all strust2 jar needed in our project, because I am not able to recognize which selected jar should be added , so I added all jars use for struts2.
At some sites I found they say should not add extra jars if you are not using, Are they correct ?


Please help me.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show us the location of those Struts .jars and the CLASSPATH you are using.
 
Pramod Kumar Pandey
Ranch Hand
Posts: 52
Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Please show us the location of those Struts .jars and the CLASSPATH you are using.



Sir, The classpath is as follows :

C:\Users\pramod\workspace1\Second\build\classes

And location of strus2.jars is :

C:\Users\pramod\workspace1\Second\WebContent\WEB-INF\lib
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that a system classpath or a classpath local to your current app? you should only use specific classpaths, not a system classpath.

That classpath is also obviously wrong, so you cannot load that particular .jar. Look at this FAQ about classpaths.
 
Joe Ess
Bartender
Posts: 9439
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This error usually is caused by having different versions of Struts in one's classpath. What JAR files have you placed in your WEB-INF\lib directory?
By the way, Struts 2.1.8.1 is pretty old. If possible, update to the current version (2.3.16).


Pramod Kumar Pandey wrote:
At some sites I found they say should not add extra jars if you are not using, Are they correct ?


As I understand it, the JVM is smart enough not to load a JAR into memory unless there is a reference in the code it is running. Adding JAR files that are not dependencies should not negatively impact your application other than increasing startup time and JAR/WAR/EAR size.
 
Pramod Kumar Pandey
Ranch Hand
Posts: 52
Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Is that a system classpath or a classpath local to your current app? You should only use specific classpaths, not a system classpath.

That classpath is also obviously wrong, so you cannot load that particular .jar. Look at this FAQ about classpaths.


Sir, Should I set classpath in environment variable , by providing all jar's name separated by commas .? Sir please guide me because this forum is only my teacher.
I think you will get my problem.
 
Joe Ess
Bartender
Posts: 9439
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pramod Kumar Pandey wrote: Should I set classpath in environment variable , by providing all jar's name separated by commas .


Absolutely not. It is hard to parse out in the link Campbell gave you, but it states:
In J2EE development, you should generally not modify the CLASSPATH or put application jars (except JDBC drivers) in the lib directories of your application server or jre/lib/ext. Doing so may introduce odd dependencies between your web applications and set you up for classloader problems.


We should deal solely with the contents of WEB-INF/lib. Again, what JAR files have you placed there?
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unable to load configuration. - bean -
jar:file:/C:/Users/pramod/workspace1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Test/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:29:72

...

Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean -
jar:file:/F:/Struts%202%20Interceptors%20Tutorial%20%20%20DZone_files/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:29:72 - bean - jar:file:/C:/Users/pramod/workspace1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Second/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:29:72

You have two copies of struts2-core-2.1.8.1.jar on the classpath somehow.
One in
F:/Struts%202%20Interceptors%20Tutorial%20%20%20DZone_files/lib
and the other in
C:/Users/pramod/workspace1/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Second/WEB-INF/lib
(which is the eclipse deployment of your app, so presumably drawn from your applications lib driectory).
Where is that first one coming from?
 
Pramod Kumar Pandey
Ranch Hand
Posts: 52
Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess wrote:
Pramod Kumar Pandey wrote: Should I set classpath in environment variable , by providing all jar's name separated by commas .


Absolutely not. It is hard to parse out in the link Campbell gave you, but it states:
In J2EE development, you should generally not modify the CLASSPATH or put application jars (except JDBC drivers) in the lib directories of your application server or jre/lib/ext. Doing so may introduce odd dependencies between your web applications and set you up for classloader problems.


We should deal solely with the contents of WEB-INF/lib. Again, what JAR files have you placed there?


Dear Sir, this helped me lot. but now this error is showing :
Some days ago this error was occured and didn't get resolved, when I googled I found they are saying that look at your Action class name. but that is correct.


while I defined action named "pramod" in struts.xml :



What does it mean.? Sometimes it runs without any problem and same code sometimes shows this error, is there no reliability of eclipse IDE ? Sir How you get the reason for that stack trace ...
. because there is very large LOC . When I'll able to trace that reasons.
 
Joe Ess
Bartender
Posts: 9439
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that the namespace in the form (line 1) and the namespace in struts.xml (line 4) do not match.


You need to declare the namespace in your package declaration.
 
Pramod Kumar Pandey
Ranch Hand
Posts: 52
Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess wrote:Note that the namespace in the form (line 1) and the namespace in struts.xml (line 4) do not match.


You need to declare the namespace in your package declaration.


 
Pramod Kumar Pandey
Ranch Hand
Posts: 52
Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Ess wrote:Note that the namespace in the form (line 1) and the namespace in struts.xml (line 4) do not match.


You need to declare the namespace in your package declaration.


Joe Sir if we are not using namespace then what is the need of declare namespace . By the way I declared namespace attribute in form tag with the same
literal value as namespace have in package tag. but it is still showing that HTTP Status 404 - There is no Action mapped for namespace / and action name user.

index page code :



and struts.xml has code :



Once I was confused that in form tag namespace literal value should start with / or not but both are tested , not working. Joe Sir please help me, error is in code or IDE ? SIR.
 
Joe Ess
Bartender
Posts: 9439
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pramod Kumar Pandey wrote:
Joe Sir if we are not using namespace then what is the need of declare namespace .


It appears from your errors that the defaults for namespace do not match.

Pramod Kumar Pandey wrote:
By the way I declared namespace attribute in form tag with the same
literal value as namespace have in package tag. but it is still showing that HTTP Status 404 - There is no Action mapped for namespace / and action name user.

You should be aware that declaring a namespace other than root changes the location of a resource. see here. Note that you declared a namespace of "/pramod" but you are still trying to access "/". You should remove the namespace declaration from your form and set the one in your struts.xml to the root: "/". That will place your form and JSP where you are looking for them.

Pramod Kumar Pandey wrote:
error is in code or IDE ? SIR.


Since thousands of people (including myself) use Eclipse every day without a problem I can practically guarantee that the problem is in your code. You can always run the application outside Eclipse to make sure.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!