Hi Jorg,


Thanks for your reply. Format of the CATEGORY_MAP_FILE has not changed. After 
debugging the issue I found that the below code is unable to load my class:



public class CompositeClassLoader extends ClassLoader {

...



public Class loadClass(String name) throws ClassNotFoundException {

        for (Iterator iterator = classLoaders.iterator(); iterator.hasNext();) {

            ClassLoader classLoader = (ClassLoader) iterator.next();

            try {

                return classLoader.loadClass(name);

            } catch (ClassNotFoundException notFound) {

                // ok.. try another one

            }

        }

        // One last try - the context class loader associated with the current 
thread. Often used in j2ee servers.

        // Note: The contextClassLoader cannot be added to the classLoaders 
list up front as the thread that constructs

        // XStream is potentially different to thread that uses it.

        ClassLoader contextClassLoader = 
Thread.currentThread().getContextClassLoader();

        if (contextClassLoader != null) {

            return contextClassLoader.loadClass(name);

        } else {

            throw new ClassNotFoundException(name);

        }

    }



Any clue?







-----Original Message-----
From: Jörg Schaible [mailto:[email protected]]
Sent: Wednesday, May 23, 2012 10:54 PM
To: [email protected]
Subject: [xstream-user] Re: Getting CannotResolveClassException



Hi,



Anshuma Ashok Goyal wrote:



> Hi Guys,

>

> I am using com.thoughtworks.xstream v1.3.1.  And trying to load XML file

> to java object.

>

> While doing so getting CannotResolveClassException error for the class

> CategoryRuleMap which is present at the required location.

>

> This functionality was working with Sonar plugin api - 1.10. I have

> upgraded Sonar plugin api to 3.0 and this has stopped working. Any clue

> what could be the issue.



The format of the CATEGORY_MAP_FILE has changed?



> Below is the code snippet I have:

>

>         InputStream input =

>         getClass().getResourceAsStream(CATEGORY_MAP_FILE);

>     categoryRuleMap = new CategoryRuleMap();

>

>     XStream xstream = new XStream();

>     xstream.alias("CategoryRuleMap", CategoryRuleMap.class);

>     xstream.alias("category", CategoryMap.class);

>     xstream.aliasAttribute(CategoryMap.class, "name", "name");

>     xstream.alias("rule", String.class);

>     xstream.addImplicitCollection(CategoryRuleMap.class, "categories");

>

>     xstream.fromXML(input, categoryRuleMap);

>

> Error trace:

>

>  [INFO] Trace

> com.thoughtworks.xstream.mapper.CannotResolveClassException:

> abc.def.CategoryRuleMap : abc.def.CategoryRuleMap

>         at



[snip]



> Please help.



Sorry, this is way too unspecific to say something else.



- Jörg





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

To unsubscribe from this list, please visit:



    http://xircles.codehaus.org/manage_email





**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not 
to copy, disclose, or distribute this e-mail or its contents to any other 
person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken 
every reasonable precaution to minimize this risk, but is not liable for any 
damage 
you may sustain as a result of any virus in this e-mail. You should carry out 
your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this 
e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Reply via email to