• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can't include another .xml file in struts.xml

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am creating application using spring, struts2, hibernate framework.

In that my struts.xml looks like :



And i am defining actions in different .xml file named as strutsAuthentication.xml. That file has following code :



I am calling this action class from index.jsp file. That file has following code :




But when i am executing this application in tomcat server, i am getting runtime error as :


There is no Action mapped for namespace / and action name saveCountry. - [unknown location]

com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Thread.java:619)

That means strutsAuthentication.xml file is not including inside struts.xml. Anyone have solution?

Thanks in advance.....

Nirmal.
 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that, since Struts is not a part of the JEE web specs, you need to add the configuration file of struts to the application so that it recognizes it. You've probably already added this snippet to the web.xml:

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts.xml</param-value>
</init-param>
</servlet>

Now the thing is that, you need to add your action mapping xml file as well to this so that the application will check for a URL mapping in that xml also. You can modify the <param-value> contents as :

<param-value>/WEB-INF/struts.xml, /WEB-INF/strutsAuthentication.xml</param-value>

provided your xml files are all inside WEB-INF, else modify accordingly. Then restart the container so that it picks up the change, and try again.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That means strutsAuthentication.xml file is not including inside struts.xml. Anyone have solution?


Or it means that you're not accessing the saveCountry action through its namespace "/authentication", which is why the <s:form> tag has a "namespace" attribute.

Note also that if index.jsp isn't accessed via through action you may run in to various difficulties.
 
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Nirmal

Where do you placed the struts.xml and Another.xml configuration?..
is there in /WEB-INF/classes ?..

Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic