]
Anindhya Sharma commented on WFLY-4374:
---------------------------------------
Thanks for your response.
The Java EE 6 specification, section 8.2 Library Support and in it sub section 8.2.1
Bundled Libraries clearly states a JAR file may reference another JAR file using the
Class-Path header in the manifest.
The above is what we have done in previous versions too of JBoss and other vendor products
and it works as noted.
Here is an excerpt from the Wildfly documentation from the Developer's Guide, section
on "Class Loading in Wildfly",
"If the ear-subdeployments-isolated is set to true then no automatic module
dependencies between the sub-deployments are set up. User must manually setup the
dependency with Class-Path entries, or by setting up explicit module dependencies."
Further it goes on to state
"
Portability
The Java EE specification says that portable applications should not rely on sub
deployments having access to other sub deployments unless an explicit Class-Path entry is
set in the MANIFEST.MF. So portable applications should always use Class-Path entry to
explicitly state their dependencies.
"
So I am not sure how for Wildfly it can be stated that it meets EE specs (and your own
documentation).
java.lang.IllegalAccessError and other classloader issues
---------------------------------------------------------
Key: WFLY-4374
URL:
https://issues.jboss.org/browse/WFLY-4374
Project: WildFly
Issue Type: Bug
Components: Class Loading
Affects Versions: 8.2.0.Final, 9.0.0.Beta2
Environment: Windows 7/Java 7 update 67
Reporter: John Sipher
Assignee: David Lloyd
Attachments: problem-demo.zip
Update 4/1/2015: I have verified that 9.0.0.Beta2 fixes the IllegalAccessError and the
war file in problem-demo.zip/hello-world6/target now duplicates the original problem. The
order of the jar files in the classpath should be
WEB-INF/lib/patch/patch2.jar
WEB-INF/lib/patch/patch1.jar
WEB-INF/lib/base/helloworld-sans-cdi.jar
org.jboss.as.quickstarts.helloworld.HelloService exists in both patch2.jar and
helloworld-sans-cdi.jar. The version from patch2.jar should be used because it is first in
the classpath, but the classloader is picking up the original class from
helloworld-sans-cdi.jar instead.
Original problem description follows:
We use manifest-only jar files in our WAR and EAR files to control the order that jar
files are searched for classes. When we issue patches, we put the modified class(es) in a
separate jar file, add that jar file to the affected EAR or WAR file, and update the
classpath in our manifest-only jar file to put the new patch at the beginning of the class
path so that it will be used in place of the original class (which is still in the
original jar file).
For example, WEB-INF/lib will contain a single jar file named manifest.jar and
sub-folders named 3rdparty, base, patch, and custom. The Class-Path entry in
WEB-INF/lib/manifest.jar|META-INF/MANIFEST.MF looks like this:
Class-Path: 3rdparty/manifest.jar patch/manifest.jar base/manifest.jar
custom/manifest.jar
When we publish a patch, the patch jar file is added to WEB-INF/lib/patch and to the
front of the classpath in WEB-INF/lib/patch/manifest.jar's MANIFEST.MF.
This worked fine for us for years with JBoss 4.2.3.GA, 5.1.0.GA, 7.1.2.Final, and
7.2.0.Final, but it's broken in WildFly 8.2.0.Final.
When I run it in debug I can see where the problem shows up in this section of
org.jboss.modules.Module (lines 562 - 573).
final String path = pathOfClass(className);
final Map<String, List<LocalLoader>> paths = getPathsUnchecked();
final List<LocalLoader> loaders = paths.get(path);
if (loaders != null) {
Class<?> clazz;
for (LocalLoader loader : loaders) {
clazz = loader.loadClassLocal(className, resolve);
if (clazz != null) {
return clazz;
}
}
}
The modules in the loaders list at line 565 are
* deployment.service.ear.lib/base/shared.jar:main
* deployment.service.ear.lib/base/deployment.jar:main
* deployment.service.ear.lib/patch/patch.jar:main
The last one should actually be the first in the list. I haven't been able to track
down the actual source of the error yet.
I've been trying to create a simple example based on the helloworld quickstart to
reproduce the problem, but I haven't been successful yet because of other classloader
errors that I've run into. I decided to go ahead and open this issue and document the
things I am able to reproduce. Those are:
1. CDI injection doesn't work when the annotated classes are in jar files under
WEB-INF/lib instead of unpacked in WEB-INF/classes.
2. WildFly doesn't process the javax.servlet.annotation.WebServlet annotation if the
jar file containing the annotated class is in a sub-folder of WEB-INF/lib.
3. WildFly throws a java.lang.IllegalAccessError trying to load a "patched"
class.
The first problem exists in both 7.2.0.Final and 8.2.0.Final. The other two problems are
new in 8.2.0.Final.