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

Vignesh Manickam Periaswamy commented on WW-3487:
-------------------------------------------------

I am facing this same issue and did mroe investigation to trace the problem. 
Initially I thought the problem could be that 
PackageBasedActionConfigBuilder.findActions() is not able to trace the WAR when 
it is deployed inside an EAR. But I was wrong and the real problem is related 
to the WAR's protocol recognized as "vfsfile" protocol. I am not part of the 
Struts developer group but I tried by best to learn internals of Struts and 
hope my troubeshooting could help resolve the issue.

I am using Struts 2.2.1.1 on JBoss 5.1. I have configured the below constant in 
struts.xml as I am using JBoss.
<constant name="struts.convention.action.fileProtocols" 
value="jar,vfsfile,vfszip" />

My troubleshooting involved 3 scenarios based on the way the WAR is deployed. 
Cases 1 & 2 WAR is deployed inside WAR; exploded and packaged respectively, 
investigate where the failure happens. Case 3 WAR is deployed directly without 
EAR, shows why it works correctly without the issues in Cases 1 & 2.

Case 1: EAR containing a WAR deployed as exploded
==========================================

Step (1): [Detecting the WAR] In URLSet.includeClassesUrl() method (invoked at 
PackageBasedActionConfigBuilder.buildUrlSet() line: 418), rootUrlEnumeration 
returns 
vfsfile:/C:/_server/jboss-eap-5.1/jboss-as/server/MyServer/deploy/MyTest.ear/MyWeb.war/WEB-INF/classes.
 The URL is normalized as 
vfsfile:/C:/_server/jboss-eap-5.1/jboss-as/server/MyServer/deploy/MyTest.ear/MyWeb.war
 truncating the "WEB-INF/classes". Please note that the WAR's protocol is 
"vfsfile" and not "vfszip", though it is an archive (exploded in my case). 
Step (2): [Built URL set] The URL of the WAR is included to the UrlSet passed 
as argument to the constructor of ClassFinder (at 
PackageBasedActionConfigBuilder.findActions() line: 377). 
Step (3): [Finding actions] While trying to add all classNames in the WAR file 
(at ClassFinder.<init>() line: 144) the util method jar(URL) normalizes the URL 
from JBoss file protocol using URLUtil.normalizeToFileProtocol(URL).
Step (4): [Converting protocol] While converting URL to "file" protocol, 
URLUtil.isJBoss5Url(URL) method checks whether the protocol is either "vfszip" 
or "vfsmemory". But in Case 1 stated above, the protocol of the WAR file is 
"vfsfile" and the method returns null. Henceforth the classNames are returned 
as an empty list.

And so, the plugin can't find the actions, though it tried looking into the WAR.

I also tried altering the value "vfsfile" protocol to "vfszip" in the debugger 
(to skip the vfsfile problem), but ClassFinder.jar(JarInputStream) fails while 
recognizing WAR as a JAR.

Case 2: EAR containing a WAR deployed as package
=========================================

Step (1): rootUrlEnumeration returns 
vfszip:/C:/_server/jboss-eap-5.1/jboss-as/server/MyServer/deploy/MyTest.ear/MyWeb.war/WEB-INF/classes
 and normalized as "file" protocol as opposed "vfsfile" in Case 1. 
(file:/C:/_server/jboss-eap-5.1/jboss-as/server/MyServer/deploy/MyTest.ear/MyWeb.war)
Step (2): Same as Case 1.
Step (3): As the protocol is "file", it checks if the file is a JAR and at 
JarURLConnection.getJarFile() gets a java.io.FileNotFoundException: 
C:\_server\jboss-eap-5.1\jboss-as\server\MyServer\deploy\MyTest.ear\MyWeb.war 
(The system cannot find the path specified), as it is directly pointing to a 
file inside an archive in the file system. It catches the exception and calls 
the util method file(URL), but returns no classes.

Case 3: WAR deployed directly
========================

Step (1): rootUrlEnumeration returns 
vfszip:/C:/_server/jboss-eap-5.1/jboss-as/server/MyServer/deploy/MyWeb.war/WEB-INF/classes
 and normalized as "file" protocol. 
file:/C:/_server/jboss-eap-5.1/jboss-as/server/MyServer/deploy/MyWeb.war.
Step (2): Same as Case 1.
Step (3): As the protocol is "file", it checks if the file is a JAR and 
JarURLConnection.getJarFile() gets the JAR file without any 
FileNotFoundException. The util jar(URL) returns all the class names in the WAR 
file!

Summary:
========
The issue in Case 1 when compared with Case 3 is the "vfsfile" protocol of the 
WAR. 
The issue in Case 2 when compared with Case 3 is the FileNotFoundException 
while referencing to the WAR inside an EAR archive in the file system.

I think both the issues need to be addressed for the bug to be resolved.

Please correct me if my assumptions about the source code are wrong.

> The plugin can't find the actions if the war embeded in an ear.
> ---------------------------------------------------------------
>
>                 Key: WW-3487
>                 URL: https://issues.apache.org/jira/browse/WW-3487
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Convention
>    Affects Versions: 2.2.1
>         Environment: JBoss 5.1
>            Reporter: Böszörményi Péter
>         Attachments: struts2-src.tar.gz, struts2.ear
>
>
> If I deploy an ear that contains a war, the plugin can't find the actions 
> under JBoss 5.1. If I only deploy the war everything is fine. Tha actions 
> defined in struts.xml works perfectly in both cases. I did some 
> investigation, and i think the problem is in the method 
> org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to