File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 + JSON : Getting Class Not Found Error

 
Girish Kumar Prabhakar
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am integrating Struts2 and JSON. For this, i am using Struts2 inbuilt support for JSON. But i am getting the following error.
java.lang.NoClassDefFoundError: org/apache/commons/lang/xwork/StringUtils

I have searched on net, but could find this jar, instead commons-lang.jar have org/apache/commons/lang/StringUtils class and no xwork package.

Here is my struts.xml and jsp code.

struts.xml
<package name="default" namespace="/" extends="struts-default">
<result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult" />
</result-types>

<action name="jsonAction" class="com.AutoComplete">
<result name="SUCCESS" type="json"><param name="root">myList</param></result>
</action>
</package>

jsp code
<s:url id="myList" value="jsonAction"/>
<sx:autocompleter label="Enter" href="%{myList}" name="city" autoComplete="true"></sx:autocompleter>

I am using spring2-core-2.1.6.jar and xwork-2.1.2.jar.

Thanks in advance.
Girish
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
spring2-core-2.1.6.jar?

That aside: is there more to the stack trace than that?
 
Girish Kumar Prabhakar
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

Thanks for your reply.
This is the full stacktrace which i am getting.





Or, is there any better way to implement json?

Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please list the actual jars you're deploying.
 
Girish Kumar Prabhakar
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

These are the jars i am using :

struts2-core-2.1.6.jar
xstream-1.2.2.jar
xwork-2.1.2.jar
freemarker-2.3.8.jar
ognl-2.6.9.jar
dom4j-1.6.1.jar
commons-collections-3.1.jar
commons-dbcp-1.2.2.jar
commons-logging-1.0.4.jar
struts2-spring-plugin-2.0.11.2.jar
tiles-api-2.1.2.jar
tiles-core-2.1.2.jar
tiles-jsp-2.1.2.jar
struts2-tiles-plugin-2.0.12.jar
spring.jar


Is there any other information you require.

Thanks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the JSON plugin jar?

And *please* only use plugins from the same version of Struts you're using? It isn't reasonable to mix-and-match like that.
 
Girish Kumar Prabhakar
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using struts2-json-plugin-2.1.8.1.jar for JSON plugin jar.

I am new to Struts2, so can you please explain your last line, or point out which plugins i am mixing and matching or using wrong versions.

Thanks David.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I asked you to list all the jars you're deploying, why isn't that one in the list?!

In any case: see all those Struts 2 jars? See how the versions aren't the same? That *will not work*.
 
Girish Kumar Prabhakar
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the version of JSON plugin correct or there is some other version.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YOU CANNOT MIX PLUGIN VERSIONS AS YOU ARE DOING NOW.

1) Do you see the Struts 2 jars you've listed?

I'll list them again for you:

struts2-core-2.1.6.jar
struts2-spring-plugin-2.0.11.2.jar
struts2-tiles-plugin-2.0.12.jar
struts2-json-plugin-2.1.8.1.jar

2) Do you see how the version numbers are different?

That won't work.

Use the version of the plugin that matches the version of Struts 2 you're using.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic