Not sure about this one, but it looks like we need the ability to allow
setting a ClassLoader on the XMLContext instance before adding mappings.

Regards
Werner

Marko Kurm wrote:
> Indeed there is a "setClassLoader(ClassLoader)" in Unmarshaller. Now i tried 
> using it like this:
> 
> ----------------------------------------------------------------------
> XMLContext xmlContextObject = new XMLContext();
> xmlContextObject.addMapping(mapping);
>                       
> Unmarshaller unmarshaller = xmlContextObject.createUnmarshaller();
> unmarshaller.setClassLoader(classLoader);
> Marshaller marshaller = xmlContextObject.createMarshaller();
> ----------------------------------------------------------------------
> 
> But it still throws the same error stack:
> 
> java.lang.NullPointerException
>       at 
> org.castor.core.util.Configuration.getObjectArray(Configuration.java:677)
>       at 
> org.castor.mapping.MappingLoaderRegistry.<init>(MappingLoaderRegistry.java:54)
>       at 
> org.castor.mapping.MappingUnmarshaller.<init>(MappingUnmarshaller.java:80)
>       at org.exolab.castor.xml.XMLContext.addMapping(XMLContext.java:79)
> 
> 
> Am i setting the classloader correctly?
> 
> Marko Kurm
> 
> 
> -----Original Message-----
> From: Werner Guttmann [mailto:[email protected]] 
> Sent: Wednesday, April 29, 2009 12:53 PM
> To: [email protected]
> Subject: Re: [castor-user] Castor ClassLoader problems
> 
> Hi Marko,
> 
> yes, you are right, both XMLContext and Marshaller do not expose such
> methods (directly). In other words, thou shall not quote top of one's
> head .. ;-).
> 
> But Unmarshaller exposes Unmarshaller.setClassLoader(ClassLoader) which
> should enable you to get past your problems.
> 
> Werner
> 
> Marko Kurm wrote:
>> Thank You for the reply!
>>
>> I can't find the method "setClassLoader(ClassLoader)" on the
>> Marshaller/Unmarshaller classes nor the XMLContext class. I am using
>> Castor 1.2. I only see a "setClassLoader(ClassLoader)" on
>> "Marshaller.getInternalContext().setClassLoader()...". Am i missing
>> something?
>>
>>
>>
>>
>> Marko Kurm tarkvara tehniline konsultant (Livelink) MicroLink Eesti
>> AS mob:  +372 53497718 faks: +372 650 1751 [email protected]
>>
>>
>>
>>
>> MicroLinki klienditeenindus: 800 99 44 [email protected] |
>> www.microlink.ee -----Original Message----- From: Werner Guttmann
>> [mailto:[email protected]] Sent: Tuesday, April 28, 2009 8:30 PM 
>> To: [email protected] Subject: Re: [castor-user] Castor
>> ClassLoader problems
>>
>> Hi Marko,
>>
>> you have mentioned that your plugin uses its own classloader to load 
>> your domain classes, correct. If that's the case, you can always pass
>>  this classloader to Castor's Unmarshaller, Marshaller and
>> XMLContext() classes by using the corresponding
>> setClassLoader(ClassLoader) methods.
>>
>> I suppose that should make a difference in your case.
>>
>> Cheers Werner
>>
>> Marko Kurm wrote:
>>> Hi,
>>>
>>> It has been a while, but the problem persists. So i thought i'd
>>> pick it up again.
>>>
>>> Werner, i have not set the custom classloader for Castor in any
>>> way. How can i do that?
>>>
>>> Marko Kurm tarkvara tehniline konsultant (Livelink) MicroLink Eesti
>>> AS mob:  +372 53497718 faks: +372 650 1751 [email protected]
>>>
>>>
>>>
>>>
>>> MicroLinki klienditeenindus: 800 99 44 [email protected] |
>>> www.microlink.ee
>>>
>>> -----Original Message----- From: Werner Guttmann
>>> [mailto:[email protected]] Sent: Thursday, February 12, 2009
>>> 4:45 PM To: [email protected] Subject: Re: [castor-user]
>>> Castor ClassLoader problems
>>>
>>> Hi,
>>>
>>> are you setting the custom ClassLoader on Castor in any way ?
>>>
>>> Werner
>>>
>>> Marko Kurm wrote:
>>>> Hi,
>>>>
>>>> Im developed a litte  java plugin that uses castor to Access a
>>>> web-service. It worked perfectly.
>>>>
>>>> Now i’m trying to incorporate that plugin into an application
>>>> that uses it’s own custom classLoader and i keep getting the
>>>> following error:
>>>>
>>>> org.castor.core.util.Configuration.getObjectArray(Configuration.java:677)
>>>> java.lang.NullPointerException 
>>>> org.castor.mapping.MappingLoaderRegistry.<init>(MappingLoaderRegistry.java:54)
>>>>  
>>>> org.castor.mapping.MappingUnmarshaller.<init>(MappingUnmarshaller.java:80)
>>>>  
>>>> org.exolab.castor.xml.Unmarshaller.setMapping(Unmarshaller.java:540)
>>>>  
>>>> ee.microlink.livelink.mobilesign.util.XmlUtil.configure(XmlUtil.java:87)
>>>>  
>>>> ee.microlink.livelink.mobilesign.util.XmlUtil.<init>(XmlUtil.java:102)
>>>>  
>>>> ee.microlink.livelink.mobilesign.MobileSignImpl.prepareMobileSign(MobileSignImpl.java:122)
>>>>
>>>>
>>>> It seems that the NullPointerException is caused because the
>>>> „getClass().getClassLoader());“ returns null:
>>>>
>>>> public MappingLoaderRegistry(final Configuration config) { 
>>>> Object[] objects = config.getObjectArray( 
>>>> CoreConfiguration.MAPPING_LOADER_FACTORIES,
>>>> getClass().getClassLoader()); for (int i = 0; i < objects.length;
>>>> i++) { _mappingLoaderFactories.add(objects[i]); } }
>>>>
>>>> Anyone have any suggestions on how to resolve this problem?
>>>>
>>>> Best Regards! Marko Kurm
>>> ---------------------------------------------------------------------
>>>  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