weird problems deserializing

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

weird problems deserializing

Jason Novotny-3
Hi,

I'm having an extreely strange problem where I run a unit test on my Mac
that works fine but the identical code on a linux server produces an
xstream related error:


testInrixAuthentication(XXXX.service.inrix.InrixServiceTest): Could not
read [class XXXX.service.inrix.auth.InrixGetSecurityTokenResponse];
nested exception is
org.springframework.oxm.UnmarshallingFailureException: XStream
unmarshalling exception; nested exception is
com.thoughtworks.xstream.mapper.CannotResolveClassException: Inrix

Basically I'm trying to serialize the XML into an Object and was using
annotations so the class looks like:

@XStreamAlias("Inrix")
public class InrixGetSecurityTokenResponse {

    @XStreamAlias("AuthResponse")
    private InrixAuthResponse authResponse;

    public InrixAuthResponse getAuthResponse() {
        return authResponse;
    }

    public void setAuthResponse(InrixAuthResponse authResponse) {
        this.authResponse = authResponse;
    }

}


I just can't understand why it works on one machine but not another-- I
do understand that in using maven to build, the class listed above is
contained in my project jar file, while the test that calls it lives in
test-classes directory, so maybe there is some issue with the
classloader of the test class needing the classloader of the jar
containing my annotated POJOs, but this doesn't seem to explain why it
works on one machine but not the other....

Any ideas on debugging this would be greatly helpful!

Thanks, Jason




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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: weird problems deserializing

Jason Novotny-3

Also, the full stack trace is:

org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class com.foo.service.inrix.auth.InrixGetSecurityTokenResponse]; nested exception is org.springframework.oxm.UnmarshallingFailureException: XStream unmarshalling exception; nested exception is com.thoughtworks.xstream.mapper.CannotResolveClassException: Inrix
	at org.springframework.http.converter.xml.MarshallingHttpMessageConverter.readFromSource(MarshallingHttpMessageConverter.java:135)
	at org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter.readInternal(AbstractXmlHttpMessageConverter.java:61)
	at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:158)
	at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:104)
	at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:773)
	at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:758)
	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:535)
	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:489)
	at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:250)
	at com.foo.service.inrix.InrixService.authenticate(InrixService.java:70)
	at com.foo.service.inrix.InrixServiceTest.testInrixAuthentication(InrixServiceTest.java:35)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)


On 1/24/14, 6:04 PM, Jason Novotny wrote:
Hi,

I'm having an extreely strange problem where I run a unit test on my Mac
that works fine but the identical code on a linux server produces an
xstream related error:


testInrixAuthentication(XXXX.service.inrix.InrixServiceTest): Could not
read [class XXXX.service.inrix.auth.InrixGetSecurityTokenResponse];
nested exception is
org.springframework.oxm.UnmarshallingFailureException: XStream
unmarshalling exception; nested exception is
com.thoughtworks.xstream.mapper.CannotResolveClassException: Inrix

Basically I'm trying to serialize the XML into an Object and was using
annotations so the class looks like:

@XStreamAlias("Inrix")
public class InrixGetSecurityTokenResponse {

    @XStreamAlias("AuthResponse")
    private InrixAuthResponse authResponse;

    public InrixAuthResponse getAuthResponse() {
        return authResponse;
    }

    public void setAuthResponse(InrixAuthResponse authResponse) {
        this.authResponse = authResponse;
    }

}


I just can't understand why it works on one machine but not another-- I
do understand that in using maven to build, the class listed above is
contained in my project jar file, while the test that calls it lives in
test-classes directory, so maybe there is some issue with the
classloader of the test class needing the classloader of the jar
containing my annotated POJOs, but this doesn't seem to explain why it
works on one machine but not the other....

Any ideas on debugging this would be greatly helpful!

Thanks, Jason




Reply | Threaded
Open this post in threaded view
|

Re: weird problems deserializing

Jason Novotny-3

I apologize for the spam, but using maven -X I get more details on the xstream classes responsible:


Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: Inrix
    at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:79)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:45)
    at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:133)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1156)
    at org.springframework.oxm.xstream.XStreamMarshaller.doUnmarshal(XStreamMarshaller.java:777)
    ... 50 more

Thanks, Jason

On 1/24/14, 6:12 PM, Jason Novotny wrote:

Also, the full stack trace is:

org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class com.foo.service.inrix.auth.InrixGetSecurityTokenResponse]; nested exception is org.springframework.oxm.UnmarshallingFailureException: XStream unmarshalling exception; nested exception is com.thoughtworks.xstream.mapper.CannotResolveClassException: Inrix
	at org.springframework.http.converter.xml.MarshallingHttpMessageConverter.readFromSource(MarshallingHttpMessageConverter.java:135)
	at org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter.readInternal(AbstractXmlHttpMessageConverter.java:61)
	at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:158)
	at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:104)
	at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:773)
	at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:758)
	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:535)
	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:489)
	at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:250)
	at com.foo.service.inrix.InrixService.authenticate(InrixService.java:70)
	at com.foo.service.inrix.InrixServiceTest.testInrixAuthentication(InrixServiceTest.java:35)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)


On 1/24/14, 6:04 PM, Jason Novotny wrote:
Hi,

I'm having an extreely strange problem where I run a unit test on my Mac
that works fine but the identical code on a linux server produces an
xstream related error:


testInrixAuthentication(XXXX.service.inrix.InrixServiceTest): Could not
read [class XXXX.service.inrix.auth.InrixGetSecurityTokenResponse];
nested exception is
org.springframework.oxm.UnmarshallingFailureException: XStream
unmarshalling exception; nested exception is
com.thoughtworks.xstream.mapper.CannotResolveClassException: Inrix

Basically I'm trying to serialize the XML into an Object and was using
annotations so the class looks like:

@XStreamAlias("Inrix")
public class InrixGetSecurityTokenResponse {

    @XStreamAlias("AuthResponse")
    private InrixAuthResponse authResponse;

    public InrixAuthResponse getAuthResponse() {
        return authResponse;
    }

    public void setAuthResponse(InrixAuthResponse authResponse) {
        this.authResponse = authResponse;
    }

}


I just can't understand why it works on one machine but not another-- I
do understand that in using maven to build, the class listed above is
contained in my project jar file, while the test that calls it lives in
test-classes directory, so maybe there is some issue with the
classloader of the test class needing the classloader of the jar
containing my annotated POJOs, but this doesn't seem to explain why it
works on one machine but not the other....

Any ideas on debugging this would be greatly helpful!

Thanks, Jason





Reply | Threaded
Open this post in threaded view
|

Re: weird problems deserializing

Jörg Schaible-2
In reply to this post by Jason Novotny-3
Hi Jason,

Jason Novotny wrote:

> Hi,
>
> I'm having an extreely strange problem where I run a unit test on my Mac
> that works fine but the identical code on a linux server produces an
> xstream related error:
>
>
> testInrixAuthentication(XXXX.service.inrix.InrixServiceTest): Could not
> read [class XXXX.service.inrix.auth.InrixGetSecurityTokenResponse];
> nested exception is
> org.springframework.oxm.UnmarshallingFailureException: XStream
> unmarshalling exception; nested exception is
> com.thoughtworks.xstream.mapper.CannotResolveClassException: Inrix

This simply tells you, that XStream cannot find any class named "Inrix" in
the default package.

> Basically I'm trying to serialize the XML into an Object and was using
> annotations so the class looks like:
>
> @XStreamAlias("Inrix")
> public class InrixGetSecurityTokenResponse {
>
>     @XStreamAlias("AuthResponse")
>     private InrixAuthResponse authResponse;
>
>     public InrixAuthResponse getAuthResponse() {
>         return authResponse;
>     }
>
>     public void setAuthResponse(InrixAuthResponse authResponse) {
>         this.authResponse = authResponse;
>     }
>
> }

It depends how your XStream was set up. By default, at deserialization time,
XStream simple gets an XML element "Inrix" - how should it know, that
there's somewhere a class with an alias annotation?

> I just can't understand why it works on one machine but not another-- I
> do understand that in using maven to build, the class listed above is
> contained in my project jar file, while the test that calls it lives in
> test-classes directory, so maybe there is some issue with the
> classloader of the test class needing the classloader of the jar
> containing my annotated POJOs, but this doesn't seem to explain why it
> works on one machine but not the other....
>
> Any ideas on debugging this would be greatly helpful!

Anything is explained here:
http://xstream.codehaus.org/annotations-tutorial.html#AutoDetect

Cheers,
Jörg


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: weird problems deserializing

Jason Novotny-3

Hi Jorg,

Thanks a lot-- that helped!

Just for reference I fixed my problem by not using auto-detect mode, and
explicitly calling processAnnotations.

Jason

On 1/25/14, 7:06 AM, Jörg Schaible wrote:

> Hi Jason,
>
> Jason Novotny wrote:
>
>> Hi,
>>
>> I'm having an extreely strange problem where I run a unit test on my Mac
>> that works fine but the identical code on a linux server produces an
>> xstream related error:
>>
>>
>> testInrixAuthentication(XXXX.service.inrix.InrixServiceTest): Could not
>> read [class XXXX.service.inrix.auth.InrixGetSecurityTokenResponse];
>> nested exception is
>> org.springframework.oxm.UnmarshallingFailureException: XStream
>> unmarshalling exception; nested exception is
>> com.thoughtworks.xstream.mapper.CannotResolveClassException: Inrix
> This simply tells you, that XStream cannot find any class named "Inrix" in
> the default package.
>
>> Basically I'm trying to serialize the XML into an Object and was using
>> annotations so the class looks like:
>>
>> @XStreamAlias("Inrix")
>> public class InrixGetSecurityTokenResponse {
>>
>>     @XStreamAlias("AuthResponse")
>>     private InrixAuthResponse authResponse;
>>
>>     public InrixAuthResponse getAuthResponse() {
>>         return authResponse;
>>     }
>>
>>     public void setAuthResponse(InrixAuthResponse authResponse) {
>>         this.authResponse = authResponse;
>>     }
>>
>> }
> It depends how your XStream was set up. By default, at deserialization time,
> XStream simple gets an XML element "Inrix" - how should it know, that
> there's somewhere a class with an alias annotation?
>
>> I just can't understand why it works on one machine but not another-- I
>> do understand that in using maven to build, the class listed above is
>> contained in my project jar file, while the test that calls it lives in
>> test-classes directory, so maybe there is some issue with the
>> classloader of the test class needing the classloader of the jar
>> containing my annotated POJOs, but this doesn't seem to explain why it
>> works on one machine but not the other....
>>
>> Any ideas on debugging this would be greatly helpful!
> Anything is explained here:
> http://xstream.codehaus.org/annotations-tutorial.html#AutoDetect
>
> Cheers,
> Jörg
>
>
> ---------------------------------------------------------------------
> 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