mace-opensaml-users - XMLConfigirator: Bug respecting JDK 1.6?
Subject: OpenSAML user discussion
List archive
- From: Xiang Yang <>
- To:
- Subject: XMLConfigirator: Bug respecting JDK 1.6?
- Date: Fri, 21 May 2010 09:32:14 +0200
Hi all,
According to the suggestion from Chad regarding my last email I've
created an extension to RequestAbstractType and other SAML objects. It
took a lot of time but was not so difficult as I had feared and I have a
clean code structure and my freedom now. The developer manual is great!
Now I put my SAML objects into the XMLTooling configuration file and use
following code to load the config file:
------------------
XMLConfigurator configurator = new XMLConfigurator();
File configFile = new File("/opt/config/saml/my-conf.xml");
configurator.load(configFile);
------------------
This works fine if I run it directly, for example in Eclipse. However,
if I run it as a tomcat webapp I got following exception:
---------------------------
DEBUG - 2010-05-21 01:01:47:615
[org.opensaml.xml.XMLConfigurator#initializeObjectProviders:230] ::
Initializing object provider {urn:dynfed:protocol}TDSRequest
ERROR - 2010-05-21 01:01:47:617
[org.opensaml.xml.XMLConfigurator#createClassInstance:358] :: Can not
create instance of de.mpg.dynfed.core.TDSRequestBuilder
java.lang.ClassNotFoundException: de.mpg.dynfed.core.TDSRequestBuilder
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
[na:1.6.0_18]
at java.security.AccessController.doPrivileged(Native Method)
[na:1.6.0_18]
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
[na:1.6.0_18]
at java.lang.ClassLoader.loadClass(ClassLoader.java:321) [na:1.6.0_18]
at java.lang.ClassLoader.loadClass(ClassLoader.java:266) [na:1.6.0_18]
at
org.opensaml.xml.XMLConfigurator.createClassInstance(XMLConfigurator.java:354)
[xmltooling-1.2.1.jar:1.2.1]
----------------------------
I found two bug reports at sun:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6500212
http://bugs.sun.com/view_bug.do?bug_id=6434149
It says following:
-------------------------
Generally speaking reflective loading of a class by name should be
accomplished by using this static method in java.lang.Class:
public static Class<?> forName(String name, boolean initialize, ClassLoader
loader)
throws ClassNotFoundException
The ClassLoader.loadClass() method is more typically used for class loader
delegation.
Invocation of Class.forName() may eventually invoke ClassLoader.loadClass()
after handling
VM name resolution. In particular, for array classes, this would involve
loading the array's
component type.
Thus, we highly recommend replacement of this code:
myClassLoader.loadClass(className);
With this code:
Class.forName(className,false,myClassLoader);
-----------------------------
Can that the reason of the ClassNotFoundException I got? The
XMLConfigurator uses exatly the loadClass method:
---------
353 ClassLoader classLoader = this.getClass().getClassLoader();
354 Class clazz = classLoader.loadClass(className);
355 Constructor constructor = clazz.getConstructor();
------------
But why is its behavior different in tomcat environment than in Eclipse? And
why it affects every class of
mine but in the sun bug report only array class is mentioned? Confusing ....
By the way, I have following java and tomcat environment:
java:
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK Client VM (build 14.0-b16, mixed mode, sharing)
tomcat is 6.0.24.
Many thanks in advance!
yang
- XMLConfigirator: Bug respecting JDK 1.6?, Xiang Yang, 05/21/2010
- Re: [OpenSAML] XMLConfigirator: Bug respecting JDK 1.6?, Yang Xiang, 05/21/2010
- Re: [OpenSAML] XMLConfigirator: Bug respecting JDK 1.6?, Brent Putman, 05/21/2010
- Re: [OpenSAML] XMLConfigirator: Bug respecting JDK 1.6?, Yang Xiang, 05/24/2010
- Re: [OpenSAML] XMLConfigirator: Bug respecting JDK 1.6?, Brent Putman, 05/24/2010
- Re: [OpenSAML] XMLConfigirator: Bug respecting JDK 1.6?, Yang Xiang, 05/24/2010
- Re: [OpenSAML] XMLConfigirator: Bug respecting JDK 1.6?, Brent Putman, 05/21/2010
- Re: [OpenSAML] XMLConfigirator: Bug respecting JDK 1.6?, Brent Putman, 05/21/2010
- Re: [OpenSAML] XMLConfigirator: Bug respecting JDK 1.6?, Yang Xiang, 05/21/2010
Archive powered by MHonArc 2.6.16.