<!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">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;">
    Annotation processing in war files too aggressive?
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/jaikiran">jaikiran pai</a> in <i>JBoss Web Development</i> - <a href="http://community.jboss.org/message/547701#547701">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p> I have got a simple war file which contains an EJB3 bean (testing against AS trunk). The bean looks like this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">@Stateless
<font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> SimpleSLSB <font color="navy"><b>extends</b></font> SimpleBase
<font color="navy">{</font>
...
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The SimpleBase class (from which this bean extends) looks like:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> SimpleBase
<font color="navy">{</font>
&#160;
&#160;&#160; @Resource
&#160;&#160; <font color="navy"><b>private</b></font> EJBContext ejbContext;
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So this base class is just a POJO with @Resource injection for EJBContext. During deployment of this .war on AS trunk, the web application deployer incorrectly starts processing this SimpleBase class and throws this exception:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">

14:32:31,422 ERROR [StandardContext] Context [/myapp] startup failed due to previous errors: java.lang.RuntimeException: mapped-name is required for org.myapp.ejb3.impl.SimpleBase/ejbContext of deployment myapp.war
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXmlResourceEnvRefs(WebResourceHandler.java:287) [:6.0.0-SNAPSHOT]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXml(WebResourceHandler.java:325) [:6.0.0-SNAPSHOT]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.tomcat.service.TomcatInjectionContainer.processMetadata(TomcatInjectionContainer.java:593) [:6.0.0-SNAPSHOT]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.tomcat.service.WebCtxLoader.start(WebCtxLoader.java:157) [:6.0.0-SNAPSHOT]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.apache.catalina.core.StandardContext.start(StandardContext.java:3737) [:]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:309) [:6.0.0-SNAPSHOT]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:144) [:6.0.0-SNAPSHOT]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461) [:6.0.0-SNAPSHOT]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.deployers.WebModule.startModule(WebModule.java:116) [:6.0.0-SNAPSHOT]
&#160;&#160;&#160;&#160;&#160;&#160;&#160; at org.jboss.web.deployers.WebModule.start(WebModule.java:95) [:6.0.0-SNAPSHOT]
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The real issue here is that the WarAnnotationDeployer picks up this SimpleBase class for annotation processing and creates metadata for @Resource and adds it to the WebAppMetaData (resourceEnvRefGroups).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Shouldn't the annotation deployer just pick up servlets (and maybe some additional classes for Servlet 3.0 spec?) for annotation processing? IMO, the SimpleBase class should have been completely skipped from annotation processing in the WarAnnotationDeployer.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</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/547701#547701">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2112">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


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

</div>

</body>
</html>