Struts2 no Action mapped for namespace [/] and action name [index] associated with context path

463 Views Asked by At

This has been asked many times before, but not quite the same as this. Everything seems to be present and in the right place. I'm using Java8, Eclipse, Maven, Struts2 w/ Convention Plugin, Spring, Tiles and annotations. The context-root is iquality, FYI.

  • The struts.xml is being read because I see the correct constants in the config-browser
    • struts.convention.default.parent.package=convention-json-tiles
  • convention-json-tiles extends struts-default
  • The web.xml has
    • the correct "actionPackages" value
    • welcome-file=index.action
    • filter-class=org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
  • The WAR file has the correct .class files in the actionPackages package

The jar files I'm using:

  • struts2-config-browser-plugin 2.5.29
  • struts2-convention-plugin 2.5.29
  • struts2-core 2.5.29
  • struts2-javatemplates-plugin 2.5.29
  • struts2-json-plugin 2.5.29
  • struts2-spring-plugin 2.5.29
  • struts2-tiles-plugin 2.5.29
  • spring-orm 4.3.26.RELEASE
  • spring-tx 4.3.26.RELEASE

The only error in the log I see is:

  • org.apache.struts2.dispatcher.Dispatcher - Could not find action or result: /iquality
  • There is no Action mapped for action name.

Here is a standard Action class that I have.

package com.icumed.ifactory.qa.web.actions;

public class ElementsAction extends ActionSupport
{
  @Action(value = "/elements-page", results =
  {
    @Result(name = "success", type = "tiles", location = "elements")
  })
  public String execute()
  {
    return SUCCESS;
  }

  @Action(value = "/element", results =
  {
    @Result(name = "success", type = "tiles", location = "element")
  })
  public String getElement() throws ApplicationException
  {
    return super.get();
  }

  @Action(value = "/elements", results =
  {
    @Result(name = "success", type = "json", params =
    {
      "root",
      ROOT_ELEMENT_TAG,
      "excludeNullProperties",
      "false",
    })
  })
  public String search() throws ApplicationException
  {
    return super.search();
  }
}

Here's my complete struts.xml:

<struts>
  <constant name="struts.custom.i18n.resources" value="iquality_messages" />
  <constant name="struts.ui.theme" value="xhtml" />
  <constant name="struts.multipart.enabled" value="true" />
  <constant name="struts.json.dateformat" value="EEE, dd MMM yyyy HH:mm:ss zzz" />
  <constant name="struts.objectFactory" value="spring" /> 
  <constant name="struts.convention.action.includeJars" value=".*?/ifactory.*?jar(!/)?" />
  <constant name="struts.convention.exclude.parentClassLoader" value="true" />
  <constant name="struts.convention.action.fileProtocols"      value="jar,file,zip,vfs,vfsfile,vfszip" />
  <constant name="struts.convention.default.parent.package" value="convention-json-tiles" />

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

    <default-interceptor-ref name="defaultStack" />

    <global-results>
      <result name="Exception">/WEB-INF/content/application_exception.jsp</result>
    </global-results>

    <global-exception-mappings>
      <exception-mapping exception="java.lang.Exception" result="Exception" />
    </global-exception-mappings>
  </package>
</struts>

What am I missing or what do I have wrong?

1

There are 1 best solutions below

0
Gary Kephart On

It was a WebLogic issue. I'm using WebLogic 12.1.3 and had to add the following to weblogic.xml

  <wls:container-descriptor>
    <wls:prefer-application-packages>
      <wls:package-name>org.objectweb.asm.*</wls:package-name>
      <wls:package-name>org.springframework.web.servlet.*</wls:package-name>
      <wls:package-name>org.springframework.web.*</wls:package-name>
      <wls:package-name>org.hibernate.validator.*</wls:package-name>
      <wls:package-name>javax.validation.*</wls:package-name>
      <wls:package-name>javax.validation.spi.*</wls:package-name>
      <wls:package-name>javassist.util.proxy..*</wls:package-name>
    </wls:prefer-application-packages>

    <wls:show-archived-real-path-enabled>true</wls:show-archived-real-path-enabled>
  </wls:container-descriptor>