[jboss-user] [JBoss Web Services] - Web Service annotated with @PostConstruct - wrong order w.r.t Listener
Mike Norman
do-not-reply at jboss.com
Mon Jun 28 15:19:28 EDT 2010
Mike Norman [http://community.jboss.org/people/mwnorman] created the discussion
"Web Service annotated with @PostConstruct - wrong order w.r.t Listener"
To view the discussion, visit: http://community.jboss.org/message/550061#550061
--------------------------------------------------------------
I have a Web Service:
//javase imports
import java.io.InputStream;
import java.io.StringReader;
import org.xml.sax.InputSource;
//java eXtension imports
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.servlet.ServletContext;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.dom.DOMSource;
import javax.xml.ws.Provider;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
import javax.xml.ws.soap.SOAPFaultException;
import static javax.xml.ws.Service.Mode.MESSAGE;@WebServiceProvider(
wsdlLocation = "WEB-INF/wsdl/eclipselink-dbws.wsdl",
serviceName = "simpleService",
portName = "simpleServicePort",
targetNamespace = "urn:simpleService"
)
@ServiceMode(MESSAGE)
public class SimpleProvider implements Provider<SOAPMessage> {
@PostConstruct
public void init() {
System.out.println("*****************init");
ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader();
InputStream eclipseLinkStream = parentClassLoader.getResourceAsStream(
"/META-INF/eclipselink-dbws-or.xml");
if (eclipseLinkStream != null) {
System.out.println("/META-INF/eclipselink-dbws-or.xml = " +
eclipseLinkStream.toString());
}
ServletContext sc = ProviderListener.SC;
if (sc == null) {
System.out.println("servlet context is null");
}
else {
InputStream schemaStream =
sc.getResourceAsStream("/WEB-INF/wsdl/eclipselink-dbws-schema.xsd");
System.out.println("WEB-INF/wsdl/eclipselink-dbws-schema.xsd = " +
schemaStream.toString());
}
}
...
I also have a ServletContextListener:
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class ProviderListener implements ServletContextListener {
public static ServletContext SC = null;
public ProviderListener() {
super();
}
public void contextInitialized(ServletContextEvent sce) {
System.out.println("*****************ServletContext initialized");
SC = sce.getServletContext();
}
public void contextDestroyed(ServletContextEvent sce) {
// no-op }
}
When I deploy to Glassfish, WebLogic and WebSphere, the order of execution is: Listener, then @PostConstruct
However, when I deploy to JBoss 5.10 (w Metro), the order is @PostConstruct then Listener.
Is this a known issue, or is there a workaround?
Thanks in advance,
Mike Norman
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/550061#550061]
Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100628/58c586aa/attachment-0001.html
More information about the jboss-user
mailing list