Author: musachy
Date: Wed Aug 12 00:28:59 2009
New Revision: 803335
URL: http://svn.apache.org/viewvc?rev=803335&view=rev
Log:
WW-3121 IllegalArgumentException using struts2-convention-plugin-2.1.6.jar on
JBoss
Modified:
struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml
Modified:
struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java?rev=803335&r1=803334&r2=803335&view=diff
==============================================================================
---
struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
(original)
+++
struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
Wed Aug 12 00:28:59 2009
@@ -100,6 +100,7 @@
private boolean reload;
private Set<String> fileProtocols;
private boolean alwaysMapExecute;
+ private boolean excludeParentClassLoader;
private static final String DEFAULT_METHOD = "execute";
@@ -151,6 +152,14 @@
}
/**
+ * Exclude URLs found by the parent class loader. Defaults to "true", set
to true for JBoss
+ */
+ @Inject("struts.convention.exclude.parentClassLoader")
+ public void setExcludeParentClassLoader(String exclude) {
+ this.excludeParentClassLoader = "true".equals(exclude);
+ }
+
+ /**
* If this constant is true, and there is an "execute" method(not
annotated), a mapping will be added
* pointing to it, even if there are other mapping in the class
*/
@@ -370,25 +379,30 @@
ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
UrlSet urlSet = new UrlSet(classLoaderInterface, this.fileProtocols);
- //exclude parent of classloaders
- ClassLoaderInterface parent = classLoaderInterface.getParent();
- //if reload is enabled, we need to step up one level, otherwise the
UrlSet will be empty
- //this happens because the parent of the realoding class loader is the
web app classloader
- if (parent != null && isReloadEnabled())
- parent = parent.getParent();
-
- if (parent != null)
- urlSet = urlSet.exclude(parent);
+ //excluding the urls found by the parent class loader is desired, but
fails in JBoss (all urls are removed)
+ if (excludeParentClassLoader) {
+ //exclude parent of classloaders
+ ClassLoaderInterface parent = classLoaderInterface.getParent();
+ //if reload is enabled, we need to step up one level, otherwise
the UrlSet will be empty
+ //this happens because the parent of the realoding class loader is
the web app classloader
+ if (parent != null && isReloadEnabled())
+ parent = parent.getParent();
- try {
- // This may fail in some sandboxes, ie GAE
- ClassLoader systemClassLoader =
ClassLoader.getSystemClassLoader();
- urlSet = urlSet.exclude(new
ClassLoaderInterfaceDelegate(systemClassLoader.getParent()));
-
- } catch (SecurityException e) {
- if (LOG.isWarnEnabled())
- LOG.warn("Could not get the system classloader due to
security constraints, there may be improper urls left to scan");
+ if (parent != null)
+ urlSet = urlSet.exclude(parent);
+
+ try {
+ // This may fail in some sandboxes, ie GAE
+ ClassLoader systemClassLoader =
ClassLoader.getSystemClassLoader();
+ urlSet = urlSet.exclude(new
ClassLoaderInterfaceDelegate(systemClassLoader.getParent()));
+
+ } catch (SecurityException e) {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Could not get the system classloader due to
security constraints, there may be improper urls left to scan");
+ }
}
+
+
urlSet = urlSet.excludeJavaExtDirs();
urlSet = urlSet.excludeJavaEndorsedDirs();
try {
@@ -402,7 +416,7 @@
urlSet = urlSet.exclude(".*/JavaVM.framework/.*");
if (includeJars == null) {
- urlSet = urlSet.exclude(".*?jar(!/)?");
+ urlSet = urlSet.exclude(".*?\\.jar(!/|/)?");
} else {
//jar urls regexes were specified
List<URL> rawIncludedUrls = urlSet.getUrls();
Modified:
struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml?rev=803335&r1=803334&r2=803335&view=diff
==============================================================================
---
struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml
(original)
+++
struts/struts2/trunk/plugins/convention/src/main/resources/struts-plugin.xml
Wed Aug 12 00:28:59 2009
@@ -64,7 +64,9 @@
<!-- <constant name="struts.convention.action.includeJars" /> -->
<constant name="struts.convention.action.fileProtocols" value="jar" />
- <constant name="struts.convention.classes.reload" value="false" />
+ <constant name="struts.convention.classes.reload" value="false" />
+
+ <constant name="struts.convention.exclude.parentClassLoader" value="true" />
<package name="convention-default" extends="struts-default">
</package>