title: Struts2+Jquery+JSON - some troubles
body: <p>I need to load a part of code dinamically by using Jquery and Json.</p>
  
  <p>This is my <strong>struts.xml</strong> :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  
  &lt;struts&gt;
      &lt;constant name="struts.enable.DynamicMethodInvocation" value="false" /&gt;
      &lt;constant name="struts.devMode" value="true" /&gt;
  
      &lt;package name="model" extends="struts-default"&gt;
          &lt;action name="UserManager" class="model.UserManager"&gt;
              &lt;result&gt;index.jsp&lt;/result&gt;
          &lt;/action&gt;
      &lt;/package&gt;
  
      &lt;package name="test" extends="json-default"&gt;
          &lt;action name="giveMeJsonData" class="test.testAction" method="myFunction"&gt;
              &lt;result type="json"&gt;&lt;param name="root"&gt;jsonData&lt;/param&gt;&lt;/result&gt;
          &lt;/action&gt;        
      &lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>
  
  <p>this is my <strong>testAction</strong> class :</p>
  
  <pre><code>package test;
  
  import com.opensymphony.xwork2.ActionSupport;
  import java.util.LinkedHashMap;
  
  public class testAction extends ActionSupport {
      private LinkedHashMap&lt;String, String&gt; jsonData;
  
      public LinkedHashMap&lt;String, String&gt; getJsonData() { return jsonData; }
      public void setJsonData(LinkedHashMap&lt;String, String&gt; jsonData) { this.jsonData = jsonData; }
  
      @Override
      public String execute() throws Exception {
          return SUCCESS;
      }
  
      public String myFunction() {
          jsonData = new LinkedHashMap&lt;String, String&gt;();
          jsonData.put("My name is", "marco");
          return SUCCESS;
      }
  }
  </code></pre>
  
  <p>and i call that method with a submit :</p>
  
  <pre><code>&lt;s:div id="my_result" &gt;
      &lt;s:property value="jsonData" /&gt;
  &lt;/s:div&gt;
  
  &lt;s:form action="giveMeJsonData" theme="simple"&gt;
      &lt;sj:submit targets="my_result" value="Example" /&gt;
  &lt;/s:form&gt;
  </code></pre>
  
  <p>Problems :</p>
  
  <p>1 - Unfortunatly, when i try to Run the application, server log (tomcat) says :</p>
  
  <pre><code>Unable to load configuration
  Error building results for action UserManager in namespace
  </code></pre>
  
  <p>regarding the line <code>&lt;action name="UserManager" class="model.UserManager"&gt;</code>, and </p>
  
  <pre><code>There is no result type defined for type 'json' mapped with name 'success'.  Did you mean 'json'?
  </code></pre>
  
  <p>regarding <code>&lt;result&gt;index.jsp&lt;/result&gt;</code></p>
  
  <p>2 - When i click on Example button, i don't get the Json element.</p>
  
  <p>What am I wrong?</p>
  
  <p>Cheers</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <pre><code>&lt;package name="json-default" extends="struts-default"&gt;
      &lt;result-types&gt;
          &lt;result-type name="json" class="com.googlecode.jsonplugin.JSONResult"/&gt;
      &lt;/result-types&gt;
  &lt;/package&gt;
  
  &lt;package name="test" extends="json-default"&gt;
      &lt;action name="giveMeJsonData" class="test.testAction" method="myFunction"&gt;
          &lt;result type="json"&gt;&lt;param name="root"&gt;jsonData&lt;/param&gt;&lt;/result&gt;
      &lt;/action&gt;        
  &lt;/package&gt;
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <pre><code>9-dic-2010 13.49.35 org.apache.catalina.core.StandardContext filterStart
  GRAVE: Exception starting filter struts2
  Unable to load configuration. - action - file:/C:/Users/djfonplaz/Documents/Stage/Struts2/build/web/WEB-INF/classes/struts.xml:11:62
          at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
          at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
          at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
          at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
          at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
          at org.apache.catalina.core.ApplicationFilterConfig.&lt;init&gt;(ApplicationFilterConfig.java:115)
          at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
          at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
          at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
          at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
          at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
          at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
          at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
          at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
          at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
          at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
          at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
          at org.apache.catalina.core.StandardService.start(StandardService.java:519)
          at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
          at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
          at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
  Caused by: Unable to load configuration. - action - file:/C:/Users/djfonplaz/Documents/Stage/Struts2/build/web/WEB-INF/classes/struts.xml:11:62
          at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
          at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
          at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
          ... 29 more
  Caused by: Error building results for action UserManager in namespace  - action - file:/C:/Users/djfonplaz/Documents/Stage/Struts2/build/web/WEB-INF/classes/struts.xml:11:62
          at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:367)
          at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:468)
          at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:264)
          at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
          at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
          at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
          ... 31 more
  Caused by: There is no result type defined for type 'json' mapped with name 'success'.  Did you mean 'json'? - result - file:/C:/Users/djfonplaz/Documents/Stage/Struts2/build/web/WEB-INF/classes/struts.xml:12:35
          at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:621)
          at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:365)
          ... 36 more
  9-dic-2010 13.50.23 org.apache.catalina.core.StandardContext filterStart
  GRAVE: Exception starting filter struts2
  Unable to load configuration. - action - file:/C:/Users/djfonplaz/Documents/Stage/Struts2/build/web/WEB-INF/classes/struts.xml:11:62
          at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
          at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
          at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
          at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
          at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
          at org.apache.catalina.core.ApplicationFilterConfig.&lt;init&gt;(ApplicationFilterConfig.java:115)
          at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
          at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
          at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:521)
          at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1359)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
          at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
          at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
          at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
          at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:849)
          at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:351)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:199)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:558)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
          at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
          at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
          at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
          at java.lang.Thread.run(Thread.java:619)
  Caused by: Unable to load configuration. - action - file:/C:/Users/djfonplaz/Documents/Stage/Struts2/build/web/WEB-INF/classes/struts.xml:11:62
          at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
          at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
          at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
          ... 41 more
  </code></pre>