Another idea....
I have 3 lots of descriptors:
com.kirona.mitie.model.web.client.concept.descriptors
com.kirona.mitie.model.web.client.security.descriptors
com.kirona.mitie.model.web.client.security.types.descriptors
...but I have to set the package descriptors without the descriptors
folder...
<bean id="castorMarshaller"
class="com.kirona.concept.web.service.client.marshaller.CastorMarshallerWith
XMLContext">
<property name="packageDescriptors">
<list>
<value>com.kirona.mitie.model.web.client.concept</value>
<value>com.kirona.mitie.model.web.client.security</value>
<value>com.kirona.mitie.model.web.client.security.types</value>
</list>
</property>
</bean>
>From your code snippet below this maybe your problem??
We are using Spring 2.5.6 and Castor 1.3.1 so I'm sure we can get to the
bottom of your problem.
P
-----Original Message-----
From: sric1 [mailto:[email protected]]
Sent: 28 July 2010 21:38
To: [email protected]
Subject: RE: [castor-user] castor generated descriptors with Spring
Thanks paul. But it dint solve my problem. my code is below.
<code>
public class CustomCastorMarshaller extends CastorMarshaller {
private String[] packageDescriptors;
public void setPackageDescriptors(String[] packages) {
this.packageDescriptors = packages;
}
@Override
protected XMLContext createXMLContext(Resource[] arg0, Class arg1)
throws MappingException, IOException,
ResolverException {
XMLContext context = super.createXMLContext(arg0, arg1);
context.getInternalContext().setClassLoader(
TestResponse.class.getClassLoader());
if (packageDescriptors != null) {
context.addPackages(packageDescriptors);
}
return context;
}
}
<bean id="marshaller" class="org.test.CustomCastorMarshaller" >
<property name="packageDescriptors"
value="org.oxm.castor.descriptors" />
</bean>
</code>
org.oxm.castor.descriptors package contains 8 descriptor classes. I need all
of them in the class path.
Thanks!
Paul French-3 wrote:
>
> Could be same problem I hit a while back, a class loader issue. A fix was
> put in so you can set the class loader the marshaller uses.
>
> As a temp fix I did:
>
> public class CastorMarshallerWithXMLContext extends CastorMarshaller
> {
> private String[] packageDescriptors;
>
> public void setPackageDescriptors(String[] packages)
> {
> this.packageDescriptors = packages;
> }
>
> @Override
> protected XMLContext createXMLContext(Resource[] arg0, Class arg1)
> throws
> MappingException, IOException, ResolverException
> {
> XMLContext context = super.createXMLContext(arg0,arg1);
>
>
context.getInternalContext().setClassLoader(AcceptQuote.class.getClassLoader
> ());
>
> if (packageDescriptors != null)
> {
> context.addPackages(packageDescriptors);
> }
> return context;
> }
>
> }
>
>
> Note I am using a castor generated class AcceptQuote to set the class
> loader.
>
> It's a horrible hack but it works.
>
> Hope it helps,
>
> Paul
>
-----Original Message-----
From: sric1 [mailto:[email protected]]
Sent: 27 July 2010 21:29
To: [email protected]
Subject: [castor-user] castor generated descriptors with Spring
Hello,
I am using Spring2.5.6 and Castor 1.3.1 for my webservice. I have used
Source generator to generate my java classes from XSD. Everything is working
fine in the local server(WAS on RAD). But when i deploy it on the server, It
is complaining that it cannot find castor generated classes. I am not sure
what is wrong. I am using Maven to manage dependencies from a repository of
jars.
<code>
<bean id="webServiceTemplate"
class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory" />
<property name="defaultUri" value="${uri}" />
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
</bean>
<bean id="marshaller"
class="org.springframework.oxm.castor.CastorMarshaller" />
</code>
Then i wrote a class to extend CastorMarshaller as below. This class adds
the castor generated descriptor package to the XMLContext. But i still get
the same problem. After receiving XML message, when castor tries to convert
it to java object, it throws an exception saying castor generated classes
cannot be found.
<code>
public class CustomCastorMarshaller extends CastorMarshaller {
protected XMLContext createXMLContext(Resource[] mappingLocations,
Class targetClass) throws MappingException,
IOException,
ResolverException {
XMLContext context = new XMLContext();
logger.debug("Adding org.aamc.amspullservice.oxm.castor
package to
XMLContext");
context.addPackages(new String[] {
"org.test.oxm.castor.descriptors" });
if (!ObjectUtils.isEmpty(mappingLocations)) {
Mapping mapping = new Mapping();
for (int i = 0; i < mappingLocations.length; i++) {
mapping.loadMapping(SaxUtils
.createInputSource(mappingLocations[i]));
}
context.addMapping(mapping);
}
if (targetClass != null) {
context.addClass(targetClass);
}
return context;
}
}
</code>
<code>
<bean id="marshaller" class="org.test.CustomCastorMarshaller " />
</code>
Note: i have .castor.cdr file in my castor generated package. Any help would
be greatly appreciated.
--
View this message in context:
http://old.nabble.com/castor-generated-descriptors-with-Spring-tp29280360p29
280360.html
Sent from the Castor - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
__________ NOD32 5318 (20100727) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
--
View this message in context:
http://old.nabble.com/castor-generated-descriptors-with-Spring-tp29280360p29
290654.html
Sent from the Castor - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
__________ NOD32 5321 (20100728) Information __________
This message was checked by NOD32 antivirus system.
http://www.eset.com
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email