Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Facing problem while compiling Action Class

 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to Struts 2 application.
I am facing problem in compiling an below Action Class.




errors am getting is:

package org.opensymphony.xwork2 does not exists.

But i have this all kinds of package in ..


Struts2Application/WebContent/WEB-INF/lib folder.

Above folder contains below jar files.

struts2-core-2.0.11.jar
xwork2-2.0.1.jar


Moreover below is the Class path:


%CLASSPATH%;D:\Eclipse_wrksp\Struts2Application\WebContent\WEB-INF\lib\xwork2-2.0.1.jar;D:\Eclipse_wrksp\Struts2Application\WebContent\WEB-INF\lib\struts2-core-2.0.11.jar


What could be wrong in above? Is there anything getting wrong while compiling GetUserAction.

Please Help.

Thanks in Advance.
Jay Shukla
 
Dawn Charangat
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you check if there are more than one xwork.jar in the same path ? or, more than one org.opensymphony.xpath.* entries available in the same classpath ???
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi dawn,

Thanks for Reply.

I have manually set the classpath and moreover i have attached exact screen shot of output of echo %CLASSPATH% commnad.

Hope this may help you.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attachment ......
classpath.jpg
[Thumbnail for classpath.jpg]
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jay,

It's a compilation problem, so the jars should be added to your Eclipse project. Adding jars to CLASSPATH will not help in compilation, because while compiling, Eclipse overrides the classpath with only jars that have been added to the project.

Cheers
karthik
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karthik,

Jars are already present in the my eclipse folder in lib folder (D:\Eclipse_wrksp\Struts2Application\WebContent\WEB-INF\lib).

Do you want to me to add 'Add As External Jars' in the Eclipse porject build path??

Thanks.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karthik,

I tried by adding jars in 'Add External Jars..'

But in vain.

What other option could be tried?

Thanks.
Jay.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They need to be added to the build path in the project properties.

Please, please don't attach screenshots for textual information: cut and paste exists for a reason.
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jay,

Ok I got the problem now after looking into xwork. The correct package name is com.opensymphony.xwork2.Action, not org.opensymphony.xwork2.Action.

In fact, Eclipse IDE itself would have flagged this problem by highlighting the line in red.

And yes, you also have add both jars to the build path. Since it's already available in one of your project folders (./lib), you can use the "Add jars" button instead of "Add external jars".

Cheers
Karthik
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, good catch; missed the "org".
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

I added those Jars in Build Path as well but in vain.

I compiled same kind of java file earlier same way but i don't know why such error is coming this time.

Thanks.
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh my Bad.

Thanks Karthik for pointing this problem.
But surprisingly it didn't highlighted this problem.

Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure it did: "package org.opensymphony.xwork2 does not exist."

Are you talking about your IDE not indicating it was an error? If so, your IDE is not configured correctly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic