On Oct 20, 2009, at 6:14 PM, Marc Johnen wrote:
>
> Hi Paul,
>
> I think I forgot to mention one important detail:
> I'm using the jersey client only, so there's no
> web.xml to configure.
>
OK, you need to register the ContextResolver class as follows:
DefaultClientConfig cc = new DefaultClientConfig();
cc.getClasses().add(MyObjectFactoryExResolver.class);
Client client = Client.create(cc);
Paul.
> I'm trying to do something like this:
>
> Contact response = null;
> WebResource r = client.resource(url);
> response = r.type(MediaType.APPLICATION_XML).post(Contact.class,
> contact);
>
> Where Contact is extending the Class OrgOpencrxKernelAccount1Contact
> which is generated by JAXB (which contains all the annotations).
> Using it just like this gives me a ClassCastException. So I need to
> find a
> way to make the WebResource use a different ObjectFactory, I guess.
>
> Thank you and greetings
> Marc
>
>
>
>
>
> Paul Sandoz wrote:
>>
>> On Oct 15, 2009, at 6:04 PM, Marc Johnen wrote:
>>
>>>
>>> Hi Paul,
>>>
>>> thank you for the answer. I didn't really understand how to
>>> register the MyObjectFactoryExResolver, though.
>>>
>>
>> How do you register your root resource classes?
>>
>> If you are using a web.xml the recommended way, when getting started,
>> is to declare the package names where root resource and provider
>> classes may reside:
>>
>>
>> https://jersey.dev.java.net/nonav/documentation/1.1.3-ea/user-guide.html
>> #d4e217
>>
>> Otherwise if you are registering an instance of
>> javax.ws.rs.core.Application or ResourceConfig you can add the
>> MyObjectFactoryExResolver class to the set of classes using:
>>
>>
>> https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/core/Application.html
>> #getClasses%28%29
>>
>> Jersey will log output listing the root resource and provider classes
>> it has found.
>>
>>
>>> Sorry for double posting, I didn't register befor my first post
>>> and thought it didn't go through.
>>>
>>
>> Np.
>> Paul.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>>
>
> --
> View this message in context: http://n2.nabble.com/How-to-use-Jersey-with-an-extended-JAXB-class-tp3828837p3859585.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>