You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Jason Pyeron (Issue Comment Edited) (JIRA)" <ji...@apache.org> on 2011/10/02 03:02:34 UTC

[jira] [Issue Comment Edited] (WW-3662) convention-plugin not work in jboss-7.0.0

    [ https://issues.apache.org/jira/browse/WW-3662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13118940#comment-13118940 ] 

Jason Pyeron edited comment on WW-3662 at 10/2/11 1:01 AM:
-----------------------------------------------------------

looking for comment on how to load container specific items

does adding urlHandlers to the short list sound justified? http://struts.apache.org/2.x/docs/webxml.html
{code}
        <init-param>
        	<description>The comma delimited list of url handlers to load first.</description>
        	<param-name>urlHandlers</param-name>
        	<param-value>org.apache.struts2.container.jboss.JBossURLHandler,com.foo.URLHandler,org.example.xyzzy.URLHandler</param-value>
       	</init-param>
{code}
it cannot be done through constants, since they are loaded by the url processing framework.

using the JDBC approach:
{code}
===================================================================
--- core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java    (revision 1177994)
+++ core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java    (working copy)
@@ -427,6 +427,7 @@

         try {
             init_DefaultProperties(); // [1]
+            init_URLHandlers(); // [1b]
             init_TraditionalXmlConfigurations(); // [2]
             init_LegacyStrutsProperties(); // [3]
             init_CustomConfigurationProviders(); // [5]
@@ -450,6 +451,33 @@
         }
     }

+    private void init_URLHandlers()
+    {
+        String urlHandlers = initParams.get("urlHandlers");
+        if (urlHandlers == null)
+        {
+            return;
+        }
+        String[] handlers = urlHandlers.split("\\s*[,]\\s*");
+        for (String handler : handlers)
+        {
+            if (handler==null || handler.equals("")) continue;
+            try
+            {
+                Class.forName(handler);
+            }
+            catch (ClassNotFoundException e)
+            {
+                LOG.warn("handler ["+handler+"] not found.", e);
+            }
+            catch (Throwable e)
+            {
+                LOG.warn("handler ["+handler+"] failed.", e);
+            }
+        }
+
+    }
+
{code}
                
      was (Author: jpyeron):
    looking for comment on how to load container specific items

does adding urlHandlers to the short list sound justified? http://struts.apache.org/2.x/docs/webxml.html

        <init-param>
        	<description>The comma delimited list of url handlers to load first.</description>
        	<param-name>urlHandlers</param-name>
        	<param-value>org.apache.struts2.container.jboss.JBossURLHandler,com.foo.URLHandler,org.example.xyzzy.URLHandler</param-value>
       	</init-param>

it cannot be done through constants, since they are loaded by the url processing framework.

using the JDBC approach:

===================================================================
--- core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java    (revision 1177994)
+++ core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java    (working copy)
@@ -427,6 +427,7 @@

         try {
             init_DefaultProperties(); // [1]
+            init_URLHandlers(); // [1b]
             init_TraditionalXmlConfigurations(); // [2]
             init_LegacyStrutsProperties(); // [3]
             init_CustomConfigurationProviders(); // [5]
@@ -450,6 +451,33 @@
         }
     }

+    private void init_URLHandlers()
+    {
+        String urlHandlers = initParams.get("urlHandlers");
+        if (urlHandlers == null)
+        {
+            return;
+        }
+        String[] handlers = urlHandlers.split("\\s*[,]\\s*");
+        for (String handler : handlers)
+        {
+            if (handler==null || handler.equals("")) continue;
+            try
+            {
+                Class.forName(handler);
+            }
+            catch (ClassNotFoundException e)
+            {
+                LOG.warn("handler ["+handler+"] not found.", e);
+            }
+            catch (Throwable e)
+            {
+                LOG.warn("handler ["+handler+"] failed.", e);
+            }
+        }
+
+    }
+

                  
> convention-plugin not work in jboss-7.0.0
> -----------------------------------------
>
>                 Key: WW-3662
>                 URL: https://issues.apache.org/jira/browse/WW-3662
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Convention
>    Affects Versions: 2.2.3, 2.3
>         Environment: OS:win7, JDK:1.6.0_26, APP:jboss 7.0.0
>            Reporter: lwen.ma
>             Fix For: 2.2.x, 2.3
>
>         Attachments: JBoss7Fix-2.patch, JBoss7Fix.patch, xwork-core-2.2.1.2-SNAPSHOT.jar
>
>
> 1. first, replace the xwork-x.x.x.jar with a bug-fixed version, see: https://issues.apache.org/jira/browse/WW-3558, prevent the bug breaking the deployment
> 2. use follow config in struts.xml
>     <constant name="struts.convention.exclude.parentClassLoader" value="true" />
>     <constant name="struts.convention.action.fileProtocols" value="jar,vfs,vfsfile,vfszip" />
>     <constant name="struts.convention.package.locators" value="actions,action" />
>     <constant name="struts.convention.package.locators.disable" value="false" />
>     <constant name="struts.convention.package.locators.basePackage" value="com.mcms.web.actions" />
> 3. deploy *.war file to jboss, then start it, get follow error log
> 	17:40:27,711 SEVERE [com.opensymphony.xwork2.util.finder.ClassFinder] Unable to read URL [vfs:/G:/jboss-as-7.0.0.Final/bin/content/struts2.war/WEB-INF/classes/]: java.io.FileNotFoundException: G:\jboss-as-7.0.0.Final\bin\content\struts2.war\WEB-INF\classes
>         at java.io.FileInputStream.open(Native Method) [:1.6.0_26]
>         at java.io.FileInputStream.<init>(FileInputStream.java:120) [:1.6.0_26]
>         at java.io.FileInputStream.<init>(FileInputStream.java:79) [:1.6.0_26]
>         at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70) [:1.6.0_26]
>         at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161) [:1.6.0_26]
>         at java.net.URL.openStream(URL.java:1010) [:1.6.0_26]
>         at com.opensymphony.xwork2.util.finder.ClassFinder.jar(ClassFinder.java:480) [xwork-core-2.2.3.jar:]
>         at com.opensymphony.xwork2.util.finder.ClassFinder.<init>(ClassFinder.java:144) [xwork-core-2.2.3.jar:]
>         at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:376) [struts2-convention-plugin-2.2.3.jar:]
>         at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:334) [struts2-convention-plugin-2.2.3.jar:]
>         at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53) [struts2-convention-plugin-2.2.3.jar:]
> 4. use follow config in struts.xml
>     <constant name="struts.convention.package.locators" value="actions,action" />
>     <constant name="struts.convention.package.locators.disable" value="false" />
>     <constant name="struts.convention.package.locators.basePackage" value="com.mcms.web.actions" />
> 5. deploy *.war file to jboss, then start it. 
>    The war package deployed without any error, but no struts actions will be found(either use package scan or annotation)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira