<!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;">
    Web Service annotated with @PostConstruct - wrong order w.r.t Listener
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/mwnorman">Mike Norman</a> in <i>JBoss Web Services</i> - <a href="http://community.jboss.org/message/550061#550061">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 a Web Service:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre style="color:#000000;background:#ffffff;"><span style="color:#3f7f59; ">//javase imports<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> java</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">io</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">InputStream</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> java</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">io</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">StringReader</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> org</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">sax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">InputSource</span><span style="color:#7f0055; ">;</span><br/><span style="color:#3f7f59; ">//java eXtension imports</span><span style="color:#7f0055; font-weight:bold; "><br/>import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">annotation</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">PostConstruct</span><span style="color:#7f0055; ">;</span><span style="color:#7f0055; font-weight:bold; "><br/>import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">annotation</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">PreDestroy</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">servlet</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ServletContext</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">namespace</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">QName</span><span style="color:#7f0055; ">;</span><span style="color:#7f0055; font-weight:bold; "><br/>import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">parsers</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">DocumentBuilder</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">parsers</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">DocumentBuilderFactory</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">soap</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">MessageFactory</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">soap</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">SOAPException</span><span style="color:#7f0055; ">;</span><span style="color:#7f0055; font-weight:bold; "><br/>import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">soap</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">SOAPFactory</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">soap</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">SOAPFault</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">soap</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">SOAPMessage</span><span style="color:#7f0055; ">;</span><span style="color:#7f0055; font-weight:bold; "><br/>import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">soap</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">SOAPPart</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">transform</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">dom</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">DOMSource</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ws</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">Provider</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ws</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ServiceMode</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ws</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">WebServiceProvider</span><span style="color:#7f0055; ">;</span><span style="color:#7f0055; font-weight:bold; "><br/>import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ws</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">soap</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">SOAPFaultException</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> static javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">xml</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ws</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">Service</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">Mode</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">MESSAGE</span><span style="color:#7f0055; ">;</span>@WebServiceProvider(
&#160;&#160;&#160; wsdlLocation = "WEB-INF/wsdl/eclipselink-dbws.wsdl",
&#160;&#160;&#160; serviceName = "simpleService",
&#160;&#160;&#160; portName = "simpleServicePort",
&#160;&#160;&#160; targetNamespace = "urn:simpleService"
)
@ServiceMode(MESSAGE)
<span style="color:#7f0055; font-weight:bold; ">public</span> <span style="color:#7f0055; font-weight:bold; ">class</span> SimpleProvider <span style="color:#7f0055; font-weight:bold; ">implements</span> Provider&lt;SOAPMessage&gt; {

&#160;&#160;&#160; @PostConstruct
&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">public</span> <span style="color:#7f0055; font-weight:bold; ">void</span> init() {
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">System</span>.out.println(<span style="color:#2a00ff; ">"*****************init"</span>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">ClassLoader</span> parentClassLoader = <span style="color:#7f0055; font-weight:bold; ">Thread</span>.currentThread().getContextClassLoader();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">InputStream</span> eclipseLinkStream = parentClassLoader.getResourceAsStream(
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#2a00ff; ">"/META-INF/eclipselink-dbws-or.xml"</span>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">if</span> (eclipseLinkStream != <span style="color:#7f0055; font-weight:bold; ">null</span>) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">System</span>.out.println(<span style="color:#2a00ff; ">"/META-INF/eclipselink-dbws-or.xml = "</span> +
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; eclipseLinkStream.toString());
&#160;&#160;&#160;&#160;&#160;&#160;&#160; }
&#160;&#160;&#160;&#160;&#160;&#160;&#160; ServletContext sc = ProviderListener.SC;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">if</span> (sc == <span style="color:#7f0055; font-weight:bold; ">null</span>) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">System</span>.out.println(<span style="color:#2a00ff; ">"servlet context is null"</span>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; }
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">else</span> {
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">InputStream</span> schemaStream = 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sc.getResourceAsStream(<span style="color:#2a00ff; ">"/WEB-INF/wsdl/eclipselink-dbws-schema.xsd"</span>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">System</span>.out.println(<span style="color:#2a00ff; ">"WEB-INF/wsdl/eclipselink-dbws-schema.xsd = "</span> +
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; schemaStream.toString());
&#160;&#160;&#160;&#160;&#160;&#160;&#160; }
&#160;&#160;&#160; }<br/>...</pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I also have a ServletContextListener:</p><pre style="color:#000000;background:#ffffff;"><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">servlet</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ServletContext</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">servlet</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ServletContextEvent</span><span style="color:#7f0055; ">;<br/></span><span style="color:#7f0055; font-weight:bold; ">import</span><span style="color:#7f0055; "> javax</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">servlet</span><span style="color:#7f0055; ">.</span><span style="color:#7f0055; ">ServletContextListener</span><span style="color:#7f0055; ">;</span>
<br/><span style="color:#7f0055; font-weight:bold; ">public</span> <span style="color:#7f0055; font-weight:bold; ">class</span> ProviderListener <span style="color:#7f0055; font-weight:bold; ">implements</span> ServletContextListener {
&#160;&#160;&#160; 
&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">public</span> <span style="color:#7f0055; font-weight:bold; ">static</span> ServletContext SC = <span style="color:#7f0055; font-weight:bold; ">null</span>;
&#160;&#160;&#160; 
&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">public</span>&#160; ProviderListener() {
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">super</span>();
&#160;&#160;&#160; }

&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">public</span> <span style="color:#7f0055; font-weight:bold; ">void</span> contextInitialized(ServletContextEvent sce) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">System</span>.out.println(<span style="color:#2a00ff; ">"*****************ServletContext initialized"</span>);
&#160;&#160;&#160;&#160;&#160;&#160;&#160; SC = sce.getServletContext();
&#160;&#160;&#160; }

&#160;&#160;&#160; <span style="color:#7f0055; font-weight:bold; ">public</span> <span style="color:#7f0055; font-weight:bold; ">void</span> contextDestroyed(ServletContextEvent sce) {
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:#3f7f59; ">// no-op</span>&#160;&#160;&#160; }
}
</pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When I deploy to Glassfish, WebLogic and WebSphere, the order of execution is: Listener, then @PostConstruct</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>However, when I deploy to JBoss 5.10 (w Metro), the order is @PostConstruct then Listener.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Is this a known issue, or is there a workaround?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks in advance,</p><p>Mike Norman</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/550061#550061">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


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

</div>

</body>
</html>