<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    JBoss 7 AS RESTEasy issue with generic type arguments
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/jantimw">Jan Tim</a> in <i>JBoss Tools</i> - <a href="http://community.jboss.org/message/617055#617055">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Before I recently migrated from JBoss 6 to 7, I was using JAX-RS for my RESTful services and everything was went fine. Now that I am working with JBoss 7 I noticed that I can use the build in RESTEasy for my purposes. But unfortunately there seems to be an issue with generic types when used in annotated POST or PUT methods.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To make things clear, I created a small and easy example of what was working for me before but no longer does: </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">@Path(<font color="red">"/g"</font>) 
<font color="navy"><b>public</b></font> <font color="navy"><b>abstract</b></font> <font color="navy"><b>class</b></font> GenericResource&lt;T <font color="navy"><b>extends</b></font> Person&gt; <font color="navy">{</font> 
&#160;&#160;&#160;&#160; 
&#160;&#160;&#160; @POST 
&#160;&#160;&#160; @Path(<font color="red">"/add"</font>) 
&#160;&#160;&#160; @Consumes(<font color="red">"application/json"</font>) 
&#160;&#160;&#160; @Produces(<font color="red">"application/json"</font>) 
&#160;&#160;&#160; <font color="navy"><b>public</b></font> String doPost(T person) <font color="navy">{</font>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">// The use of a generic type as argument causes an error</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> <font color="red">"success"</font>; 
&#160;&#160;&#160; <font color="navy">}</font> 
&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160; 
&#160;&#160;&#160; @GET 
&#160;&#160;&#160; @Produces(<font color="red">"application/json"</font>) 
&#160;&#160;&#160; <font color="navy"><b>public</b></font> T doGet() <font color="navy">{</font> 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; @SuppressWarnings(<font color="red">"unchecked"</font>) 
&#160;&#160;&#160;&#160;&#160;&#160;&#160; T p = (T) <font color="navy"><b>new</b></font> PersonImpl(<font color="red">"TestPerson"</font>);&#160; 
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> p; 
&#160;&#160;&#160; <font color="navy">}</font> 
&#160;&#160;&#160;&#160; 
<font color="navy">}</font>
&#160;&#160;&#160;&#160; 
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>As you can see, I just build an abstract class with a generic type T and annotated two methods, one with "POST" and one with "GET". This example worked fine with JBoss 6 and JAX-RS, but now I get the following error on sending any request (get or post) through RESTEeasy to this class:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">Allocate exception for servlet javax.ws.rs.core.Application: java.lang.RuntimeException: Unable to determine value of type parameter T 
&#160;&#160;&#160; at org.jboss.resteasy.util.Types.getActualValueOfTypeVariable(Types.java:319) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.core.MethodInjectorImpl.&lt;init&gt;(MethodInjectorImpl.java:65) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.core.InjectorFactoryImpl.createMethodInjector(InjectorFactoryImpl.java:55) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.core.ResourceMethod.&lt;init&gt;(ResourceMethod.java:71) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:178) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:123) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:106) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:83) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:72) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:367) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:225) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) [resteasy-jaxrs-2.2.1.GA.jar:] 
&#160;&#160;&#160; at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final] 
&#160;&#160;&#160; at java.lang.Thread.run(Thread.java:662) [:1.6.0_26] 
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If I remove the POST-method, at least the GET-request ist working correctly. Although changing the argument to a type that is not generic fixes the error but that is no long term solution for my problem. Am I doing something wrong or is it a bug that is already known?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Best Regards</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/617055#617055">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Tools at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>