Details
-
Bug
-
Resolution: Obsolete
-
Major
-
None
-
2.0.1.GA
-
None
Description
I have a multipartform POJO that I'm using to represent a form in my HTML page. One of the fields of this POJO is an Enum. For a simple Enum, everything works fine. However, when I use an Enum such as this:
public enum MyEnum {
FIELD_ONE("user friendly field 1"), FIELD_TWO("user friendly field 2");
private final String name;
RdfTypeEnum(String name)
{ this.name = name; } @Override
public String toString()
}
This works fine using my HTML page - the user enters the Enum variable (eg, FIELD_ONE), as I expect, since its using the enum's valueOf() method. However, using the client interface (example below) I get an exception (see below).
public class RestTest {
@Test
public void testPersistance() throws Exception
@Path("/rest")
public interface AdminIfc
}
The exception:
org.jboss.resteasy.spi.ReaderException: org.jboss.resteasy.core.ExceptionAdapter: : null
at org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:123)
at org.jboss.resteasy.client.core.BaseClientResponse.readFrom(BaseClientResponse.java:291)
at org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:255)
at org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:228)
at org.jboss.resteasy.client.core.extractors.BodyEntityExtractor.extractEntity(BodyEntityExtractor.java:56)
at org.jboss.resteasy.client.core.ClientInvoker.invoke(ClientInvoker.java:102)
at org.jboss.resteasy.client.core.ClientProxy.invoke(ClientProxy.java:72)
at $Proxy20.getQueries(Unknown Source)
at constellation.restful.services.RestTest.testRetrieval(RestTest.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.jboss.resteasy.core.ExceptionAdapter: : null
at org.jboss.resteasy.util.TypeConverter.getTypeViaValueOfMethod(TypeConverter.java:213)
at org.jboss.resteasy.util.TypeConverter.getType(TypeConverter.java:80)
at org.jboss.resteasy.plugins.providers.DefaultTextPlain.readFrom(DefaultTextPlain.java:38)
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$PartImpl.getBody(MultipartInputImpl.java:145)
at org.jboss.resteasy.plugins.providers.multipart.MultipartFormAnnotationReader.setFields(MultipartFormAnnotationReader.java:134)
at org.jboss.resteasy.plugins.providers.multipart.MultipartFormAnnotationReader.readFrom(MultipartFormAnnotationReader.java:74)
at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:105)
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.read(GZIPDecodingInterceptor.java:46)
at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108)
at org.jboss.resteasy.core.messagebody.ReaderUtility.doRead(ReaderUtility.java:111)
... 32 more
I suspect that what is happening is that the POJO's values are first unmarshalled as strings. In this case, the toString method on the enum returns "user friendly field 1" which is then added to the HTTP request. Since this string is not one of the enum variables, it throws that exception. What should happen is the POJO should invoke the valueOf method of the enum and use that value to serialize in the HTTP request. Currently, there's no way for me to test my rest call since the behavior of the rest client is different from what happens in a browser.