4 Replies Latest reply on Jul 8, 2010 5:57 AM by mid491 mid491

    Struts2 Annotations in ear file don't work

    mid491 mid491 Newbie

      Hi,

       

      I am trying to deploy a struts 2 (2.1.8) exemple to Jboss 5.1.0 GA :

       

      - deploying the WAR just works fine,  my action is  mapped  (checked with the struts 2 config browser plugin and from the url)

      - deploying the same WAR as part of an EAR is working but struts's actions are no more mapped :  (either from Eclipse or Maven's ear plugin)

       

      I've trying many things as this : http://struts.apache.org/2.x/docs/convention-plugin.html but sames results : There is no Action mapped for namespace ...

       

      any hints ?

        • 1. Re: Struts2 Annotations in ear file don't work
          mid491 mid491 Newbie

          up!

           

          still doesn't work : war deployed alone is working, inside EAR not.

           

          thx )

          • 2. Re: Struts2 Annotations in ear file don't work
            jaikiran pai Master

            In their documentation, they have a section on "Actions in jar files" and another section on "JBoss". Have you followed those sections and configured accordingly? If yes, then post your exact configs here. Also try to enable debug and/or trace level logging as explained in their "Troubleshooting" section and see if it provides any useful information.

            • 3. Re: Struts2 Annotations in ear file don't work
              mid491 mid491 Newbie

              [edited after some tries]

               

              yes I've tried many things with same results ! : all is fine when WAR is deployed apart of the EAR, no more when the WAR is packaged inside EAR ???

               

              Very strange....

               

              Also I just don't understand what to do with this trick :

               

              Actions in jar files

              By default the Convention plugin will not scan jar files for actions. For a jar to be scanned, its URL needs to match at least one of the regular expressions in struts.convention.action.includeJars. In this example myjar1.jar and myjar2.jar will be scanned:

              <constant name="struts.convention.action.includeJars" value=".*?/myjar1.*?jar(!/)?,.*?/myjar2*?jar(!/)?"
              

              Note that the regular expression will be evaluated against the URL of the jar, and not the file name, the jar URL can contain a path to the jar file and a trailing "!/".

               

              My actions are not packaging into a jar but in a WAR.

               

              I discovered something : when I run JBoss (war packaged inside EAR) I've got logs where I can see that there no processing on my Action Classes;

               

              Here the logs during the deployement, first the EAr with WAR inside and second, the WAr apart of the EAR :

               

               

              1) WAR outside the EAR (working fine) :

               

               

              INFO  [XmlConfigurationProvider] Parsing configuration file [struts.xml]

              INFO  [BeanSelectionProvider] Choosing bean (struts) for class com.opensymphony.xwork2.ObjectFactory

              INFO  [BeanSelectionProvider] Choosing bean (struts) for class com.opensymphony.xwork2.conversion.impl.XWorkConverter

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.TextProvider

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.ActionProxyFactory

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.conversion.ObjectTypeDeterminer

              DEBUG [BeanSelectionProvider] Choosing bean (class org.apache.struts2.dispatcher.mapper.DefaultActionMapper) for interface org.apache.struts2.dispatcher.mapper.ActionMapper

              INFO  [BeanSelectionProvider] Choosing bean (jakarta) for interface org.apache.struts2.dispatcher.multipart.MultiPartRequest

              INFO  [BeanSelectionProvider] Choosing bean (struts) for class org.apache.struts2.views.freemarker.FreemarkerManager

              DEBUG [BeanSelectionProvider] Choosing bean (struts) for class org.apache.struts2.views.velocity.VelocityManager to be loaded from the ObjectFactory

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface org.apache.struts2.components.UrlRenderer

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.validator.ActionValidatorManager

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.util.ValueStackFactory

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.util.reflection.ReflectionProvider

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.util.reflection.ReflectionContextFactory

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.util.PatternMatcher

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface org.apache.struts2.dispatcher.StaticContentLoader

              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.UnknownHandlerManager

              DEBUG [LocalizedTextUtil] Added default resource bundle 'org/apache/struts2/struts-messages' to default resource bundles = [org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]

              INFO  [BeanSelectionProvider] Loading global messages from globalmessages

              DEBUG [LocalizedTextUtil] Added default resource bundle 'globalmessages' to default resource bundles = [globalmessages, org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]

              DEBUG [XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:struts-default namespace: parents:[]}

              DEBUG [DefaultValidatorFactory] Loading validator definitions.

              DEBUG [I18nInterceptor] new I18nInterceptor()

              DEBUG [I18nInterceptor] new I18nInterceptor()

              DEBUG [I18nInterceptor] new I18nInterceptor()

              DEBUG [XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:convention-default namespace: parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}

              DEBUG [XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:config-browser namespace:/config-browser parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}

              DEBUG [XmlConfigurationProvider] Loaded /config-browser/index in 'config-browser' package:{ActionConfig index () - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo-presentation-1.0-snapshot.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:45:30}

              DEBUG [XmlConfigurationProvider] Loaded /config-browser/actionNames in 'config-browser' package:{ActionConfig actionNames (org.apache.struts2.config_browser.ActionNamesAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo-presentation-1.0-snapshot.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:49:96}

              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showConfig in 'config-browser' package:{ActionConfig showConfig (org.apache.struts2.config_browser.ShowConfigAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo-presentation-1.0-snapshot.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:53:94}

              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showConstants in 'config-browser' package:{ActionConfig showConstants (org.apache.struts2.config_browser.ShowConstantsAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo-presentation-1.0-snapshot.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:57:100}

              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showBeans in 'config-browser' package:{ActionConfig showBeans (org.apache.struts2.config_browser.ShowBeansAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo-presentation-1.0-snapshot.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:61:92}

              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showJars in 'config-browser' package:{ActionConfig showJars (org.apache.struts2.config_browser.ShowJarsAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo-presentation-1.0-snapshot.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:65:90}

              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showValidators in 'config-browser' package:{ActionConfig showValidators (org.apache.struts2.config_browser.ListValidatorsAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo-presentation-1.0-snapshot.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:69:102}

              DEBUG [XmlConfigurationProvider] Loaded /config-browser/validatorDetails in 'config-browser' package:{ActionConfig validatorDetails (org.apache.struts2.config_browser.ShowValidatorAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo-presentation-1.0-snapshot.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:75:103}

              DEBUG [XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:laposte namespace:/ parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}

              DEBUG [PackageBasedActionConfigBuilder] Setting action default parent package to [convention-default]

              DEBUG [PackageBasedActionConfigBuilder] Loading action configurations

              DEBUG [PackageBasedActionConfigBuilder] Actions being loaded from action packages [fr.mycompagny.foo.presentation]

              DEBUG [PackageBasedActionConfigBuilder] Actions being loaded using package locators [presentation]

              DEBUG [PackageBasedActionConfigBuilder] Excluding actions from packages [org.apache.struts.*, org.apache.struts2.*, org.springframework.web.struts.*, org.springframework.web.struts2.*, org.hibernate.*]

              DEBUG [PackageBasedActionConfigBuilder] Class [fr.mycompagny.foo.presentation.categories.AbstractCategory] did not pass the instantiation test and will be ignored

              DEBUG [PackageBasedActionConfigBuilder] Processing class [fr.mycompagny.foo.presentation.categories.CategoryAction] in package [fr.mycompagny.foo.presentation.categories]

              DEBUG [SEOActionNameBuilder] Changed action name from [categories] to [categories]

              DEBUG [SEOActionNameBuilder] Changed action name from [CategoryAction] to [category]

              DEBUG [PackageBasedActionConfigBuilder] Got actionName for class [class fr.mycompagny.foo.presentation.categories.CategoryAction] of [category]

              DEBUG [PackageBasedActionConfigBuilder] Created package config named [fr.mycompagny.foo.presentation.categories#convention-default#/categories] with a namespace [/categories]

              DEBUG [PackageBasedActionConfigBuilder] Creating action config for class [class fr.mycompagny.foo.presentation.categories.CategoryAction], name [category] and package name [fr.mycompagny.foo.presentation.categories#convention-default#/categories] in namespace [/categories]

              DEBUG [DefaultResultMapBuilder] Using final calculated namespace [/categories]

              DEBUG [DefaultResultMapBuilder] Searching for results in the Servlet container at [/jsp/categories/] with result prefix of [/jsp/categories/category]

              DEBUG [DefaultResultMapBuilder] Processing resource path [/jsp/categories/category-list.jsp]

              DEBUG [DefaultResultMapBuilder] The result file [/jsp/categories/category-list.jsp] has a result code and therefore will be associated with only that result code.

              DEBUG [DefaultResultMapBuilder] Processing resource path [/jsp/categories/category-form.jsp]

              DEBUG [DefaultResultMapBuilder] The result file [/jsp/categories/category-form.jsp] has a result code and therefore will be associated with only that result code.

              DEBUG [DefaultResultMapBuilder] Searching for results in the class path at [jsp/categories/] with a result prefix of [/jsp/categories/category] and action name [category]

              DEBUG [PackageBasedActionConfigBuilder] Creating action config for class [class fr.mycompagny.foo.presentation.categories.CategoryAction], name [category] and package name [fr.mycompagny.foo.presentation.categories#convention-default#/categories] in namespace [/categories]

              DEBUG [DefaultResultMapBuilder] Using final calculated namespace [/categories]

              DEBUG [DefaultResultMapBuilder] Searching for results in the Servlet container at [/jsp/categories/] with result prefix of [/jsp/categories/category]

              DEBUG [DefaultResultMapBuilder] Processing resource path [/jsp/categories/category-list.jsp]

              DEBUG [DefaultResultMapBuilder] The result file [/jsp/categories/category-list.jsp] has a result code and therefore will be associated with only that result code.

              DEBUG [DefaultResultMapBuilder] Processing resource path [/jsp/categories/category-form.jsp]

              DEBUG [DefaultResultMapBuilder] The result file [/jsp/categories/category-form.jsp] has a result code and therefore will be associated with only that result code.

              DEBUG [DefaultResultMapBuilder] Searching for results in the class path at [jsp/categories/] with a result prefix of [/jsp/categories/category] and action name [category]

              DEBUG [PackageBasedActionConfigBuilder] Class [fr.mycompagny.foo.presentation.AbstractBaseAction] did not pass the instantiation test and will be ignored

               

               

               

              2) WAR insidde the EAR (not working)

               

              DEBUG [XmlConfigurationProvider] Loaded action configuration from: struts.xml
              INFO  [XmlConfigurationProvider] Parsing configuration file [struts.xml]
              INFO  [BeanSelectionProvider] Choosing bean (struts) for class com.opensymphony.xwork2.ObjectFactory
              INFO  [BeanSelectionProvider] Choosing bean (struts) for class com.opensymphony.xwork2.conversion.impl.XWorkConverter
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.TextProvider
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.ActionProxyFactory
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.conversion.ObjectTypeDeterminer
              DEBUG [BeanSelectionProvider] Choosing bean (class org.apache.struts2.dispatcher.mapper.DefaultActionMapper) for interface org.apache.struts2.dispatcher.mapper.ActionMapper
              INFO  [BeanSelectionProvider] Choosing bean (jakarta) for interface org.apache.struts2.dispatcher.multipart.MultiPartRequest
              INFO  [BeanSelectionProvider] Choosing bean (struts) for class org.apache.struts2.views.freemarker.FreemarkerManager
              DEBUG [BeanSelectionProvider] Choosing bean (struts) for class org.apache.struts2.views.velocity.VelocityManager to be loaded from the ObjectFactory
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface org.apache.struts2.components.UrlRenderer
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.validator.ActionValidatorManager
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.util.ValueStackFactory
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.util.reflection.ReflectionProvider
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.util.reflection.ReflectionContextFactory
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.util.PatternMatcher
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface org.apache.struts2.dispatcher.StaticContentLoader
              INFO  [BeanSelectionProvider] Choosing bean (struts) for interface com.opensymphony.xwork2.UnknownHandlerManager
              DEBUG [LocalizedTextUtil] Added default resource bundle 'org/apache/struts2/struts-messages' to default resource bundles = [org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]
              INFO  [BeanSelectionProvider] Loading global messages from globalmessages
              DEBUG [LocalizedTextUtil] Added default resource bundle 'globalmessages' to default resource bundles = [globalmessages, org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]
              DEBUG [XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:struts-default namespace: parents:[]}
              DEBUG [DefaultValidatorFactory] Loading validator definitions.
              DEBUG [I18nInterceptor] new I18nInterceptor()
              DEBUG [I18nInterceptor] new I18nInterceptor()
              DEBUG [I18nInterceptor] new I18nInterceptor()
              DEBUG [XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:convention-default namespace: parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
              DEBUG [XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:config-browser namespace:/config-browser parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
              DEBUG [XmlConfigurationProvider] Loaded /config-browser/index in 'config-browser' package:{ActionConfig index () - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo.ear/foo-presentation-1.0-SNAPSHOT.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:45:30}
              DEBUG [XmlConfigurationProvider] Loaded /config-browser/actionNames in 'config-browser' package:{ActionConfig actionNames (org.apache.struts2.config_browser.ActionNamesAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo.ear/foo-presentation-1.0-SNAPSHOT.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:49:96}
              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showConfig in 'config-browser' package:{ActionConfig showConfig (org.apache.struts2.config_browser.ShowConfigAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo.ear/foo-presentation-1.0-SNAPSHOT.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:53:94}
              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showConstants in 'config-browser' package:{ActionConfig showConstants (org.apache.struts2.config_browser.ShowConstantsAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo.ear/foo-presentation-1.0-SNAPSHOT.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:57:100}
              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showBeans in 'config-browser' package:{ActionConfig showBeans (org.apache.struts2.config_browser.ShowBeansAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo.ear/foo-presentation-1.0-SNAPSHOT.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:61:92}
              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showJars in 'config-browser' package:{ActionConfig showJars (org.apache.struts2.config_browser.ShowJarsAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo.ear/foo-presentation-1.0-SNAPSHOT.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:65:90}
              DEBUG [XmlConfigurationProvider] Loaded /config-browser/showValidators in 'config-browser' package:{ActionConfig showValidators (org.apache.struts2.config_browser.ListValidatorsAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo.ear/foo-presentation-1.0-SNAPSHOT.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:69:102}
              DEBUG [XmlConfigurationProvider] Loaded /config-browser/validatorDetails in 'config-browser' package:{ActionConfig validatorDetails (org.apache.struts2.config_browser.ShowValidatorAction) - action - vfszip:/C:/java/dev/ejb3/jboss-5.1.0.GA/server/default/deploy/foo.ear/foo-presentation-1.0-SNAPSHOT.war/WEB-INF/lib/struts2-config-browser-plugin-2.1.8.1.jar/struts-plugin.xml:75:103}
              DEBUG [XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:laposte namespace:/ parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
              DEBUG [PackageBasedActionConfigBuilder] Setting action default parent package to [convention-default]
              DEBUG [PackageBasedActionConfigBuilder] Loading action configurations
              DEBUG [PackageBasedActionConfigBuilder] Actions being loaded from action packages [fr.mycompagny.foo.presentation]
              DEBUG [PackageBasedActionConfigBuilder] Actions being loaded using package locators [presentation]
              DEBUG [PackageBasedActionConfigBuilder] Excluding actions from packages [org.apache.struts.*, org.apache.struts2.*, org.springframework.web.struts.*, org.springframework.web.struts2.*, org.hibernate.*]

               

               

               

              when I packaged the WAr outside the EAr i just remove the reference from the ear's pom

               

               

               

              Any idea ?