Hi Werner,

Here is the patch (file is : castor-X.Y.Z/src/main/java/org/exolab/castor/xml/UnmarshalHandler.java)
(of course you will need to recompile castor ... : 'ant clean' followed by 'ant jar' will do the job)

==============================================================
    /**
     * Loads and returns the class with the given class name using the
     * given loader.
     * @param className the name of the class to load
     * @param loader the ClassLoader to use, this may be null.
     * *********************************************************************
     * PATCH : C.Assemat - 11/05/2007 due to the bug of loadClass in JDK 1.6
     * *********************************************************************
    **/
    private Class loadClass(String className, ClassLoader loader)
        throws ClassNotFoundException
    {
    // -- patch only if jdk 1.6 AND 'array class'
    if ( className.startsWith("[") )
        return Class.forName(className);
        //-- use passed in loader
    else if ( loader != null )
        return loader.loadClass(className);
    //-- use internal loader
    else if (_loader != null)
        return _loader.loadClass(className);
    //-- no loader available use Class.forName
    return Class.forName(className);
    } //-- loadClass
==============================================================

Cheers,

C.Assemat

PS: if someone here is more aware of the Castor's codebase and procedures, he could enter
the bug in some bug's repository and register the patch.

Werner Guttmann wrote:
Thanks a lot for reporting this (re)solution back to us.

Werner

Christophe Assemat wrote:
  
Hi Werner,

I think i have found the problem... it's a bug of jdk 1.6 ... (here the
example is with an array of String but it's the same
with any array) :

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6434149


================================================================================
Bug ID:        6434149
Votes     45
Synopsis     (cl) ClassLoader.loadClass() throws
java.lang.ClassNotFoundException: [Ljava.lang.String; in JDK 6.0
Category     java:classes_lang
Reported Against    
Release Fixed    
State     In progress, bug
Related Bugs     6446627 , 6466061 , 6500212 , 6516909 , 6518862
Submit Date     05-JUN-2006
Description    

Consider this simple test program:

  public class test {

      public static void main(String[] args) throws Exception {

          String[] s = new String[] { "123" };
          String clName = s.getClass().getName();
          test.class.getClassLoader().loadClass(clName);
      }
  }

This runs fine on JDK 1.5, but throws this exception on JDK 6.0:

Exception in thread "main" java.lang.ClassNotFoundException:
[Ljava.lang.String;
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at test.main(test.java:7)
Posted Date : 2006-06-05 21:54:58.0
 

Submitted On 08-MAY-2007
Sean.Ho

This bug is very severe. We need it to be fixed ASAP.

Submitted On 10-MAY-2007

Fix it soon...........
================================================================================

Strangely the bug was posted in June 2006 ... one year ago !
Thanks for the help

Chris

PS: I'm looking for a workaround until the bug is fixed by Sun. I'll let
you know what i have found.

Werner Guttmann wrote:
    
Not really, to be honest, ut maybe somebody else can provide his
(historical) views. Personally, I would be very surprised to find
Java-specific notations in an xsi:type attribute ….. what surprises me
is that it seems to work.

 

Werner

 

------------------------------------------------------------------------

*Von:* Christophe Assemat [mailto:[EMAIL PROTECTED]]
*Gesendet:* Donnerstag, 10. Mai 2007 12:34
*An:* [email protected]
*Betreff:* Re: AW: [castor-user] [XML] unable to instantiate [I;
java.lang.ClassNotFoundException: [I

 

Hi Werner,

I'm indeed using a mapping file (i can extract from it mapping
information related to the xml showned in my email). But first, could
you tell
me if the 'xsi:type="java:[I"' notation found in the xml is (seems)
correct ?

Thanks,

Chris

Werner Guttmann wrote:

That's truly an odd one .. ;-). A few random questions, just to establish a context for me. Are you using a mapping file ? If not, is this discussion based upon Java classes that have been generated from an XML schema ? Or are you using Castor XML without a mapping file, relying on default introspection ? 
 
Werner
 
  
      
-----Ursprüngliche Nachricht-----
Von: Christophe Assemat [mailto:[EMAIL PROTECTED]]
Gesendet: Donnerstag, 10. Mai 2007 11:34
An: [email protected] <mailto:[email protected]>
Betreff: [castor-user] [XML] unable to instantiate [I;
java.lang.ClassNotFoundException: [I
 
Hi,
 
I have an application running perfectly with jre 1.5.xx but which fails
when i try to use
jre 1.6. While trying to 'unmarshal' an xml previously marshalled
object, it fails :
 
unable to instantiate [I; java.lang.ClassNotFoundException: [I
...
 
Part of the xml concerned looks like :
 
<targetmap internalkey="33">
<range xsi:type="java:[I">
 <integer>12345</integer>
 <integer>34567</integer>
</range>
<range ...>
...
</range>
...
</targetmap>
 
I'm still using 'castor-1.0.2' version and i'm planning to move to
'castor-1.1.1' but anyhow i would like to understand why
this problem arises.
 
Cheers
 
C.ASSEMAT
GenomeQuest Inc.
 
 
 
---------------------------------------------------------------------
To unsubscribe from this list please visit:
 
    http://xircles.codehaus.org/manage_email
    
        
 
 
---------------------------------------------------------------------
To unsubscribe from this list please visit:
 
    http://xircles.codehaus.org/manage_email
 
 
  

 

---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email 
      
--------------------------------------------------------------------- To
unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
    


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


  

--------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

Reply via email to