aspose file tools*
The moose likes Struts and the fly likes Facing problem while compiling Action Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Facing problem while compiling Action Class" Watch "Facing problem while compiling Action Class" New topic
Author

Facing problem while compiling Action Class

Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
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

Joined: Apr 26, 2007
Posts: 249
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

Joined: Jun 08, 2008
Posts: 214
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

Joined: Jun 08, 2008
Posts: 214
Attachment ......


[Thumbnail for classpath.jpg]

Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 539
    
    7
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

Joined: Jun 08, 2008
Posts: 214
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

Joined: Jun 08, 2008
Posts: 214
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

Joined: Sep 29, 2008
Posts: 12617

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
Ranch Hand

Joined: Apr 04, 2009
Posts: 539
    
    7
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

Joined: Sep 29, 2008
Posts: 12617

Ah, good catch; missed the "org".
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
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

Joined: Jun 08, 2008
Posts: 214
oh my Bad.

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

Thanks.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Facing problem while compiling Action Class