Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in struts 2.0 autocompleter tag.

 
amishrm sharma
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Every one,

i am new in struts 2.0. and i am using autocompleter tag of struts-dojo for autocomplete the field from database. But i am facing the below error while running my code.

java.lang.NoSuchMethodError: com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:355)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:259)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:141)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:456)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:227)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:248)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:49)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:230)
at com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:229)


below is my jsp code.

<s:url var="userList" value="/autocomplete/LookupAction.action"/>


<sx:autocompleter
indicator="indicator1"
href="%{userList}"
cssStyle="width: 200px;"
autoComplete="true"
searchType="substring"
name="firstName" label="First Name" showDownArrow="false"/>


and below is my struts.xml code

<package name="autocomplete" namespace="/autocomplete" extends="json-default">
<default-interceptor-ref name="completeStack" />
<action name="LookupAction" class="example.LookupAction">
<result type="json" />
</action>
</package>

and my action code.

package example;
import java.util.List;
import com.myapp.dao.LookupDaoImpl;
import com.myapp.dto.User;
import com.opensymphony.xwork2.ActionSupport;
import java.util.HashMap;
import java.util.Map;

public class LookupAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 7025220437464516839L;
private Map<String, String> map;

public String execute() throws Exception {
map = new HashMap<String, String>();

LookupDaoImpl objLookupDaoImpl = new LookupDaoImpl();
List<User> users = objLookupDaoImpl.doLookup();

for (User user : users) {
map.put(user.getUserCode(), user.getUserFirstName() + " "
+ user.getUserLastName());
}

return SUCCESS;
}
public Map<String, String> getMap() {
return map;
}

public void setMap(Map<String, String> map) {
this.map = map;
}
}


i would appreciate you guys, could you please help me find out the problem.

Regards,
Amit Sharma
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
amishrm sharma wrote:java.lang.NoSuchMethodError: com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
The given method is missing in the classpath. That´s all. Just upgrade the JAR file with the desired class to a version containing the method. Or if it is already there, then you most probably have an older version of the JAR/class somewhere else in the classpath. Remove it then.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic