Hello, I'm having difficulty setting up an embedded Jetty instance to create
a JUnit test case for my DoubleIt[1] web service example. The test cases
themselves run fine when I use the Endpoint interface to activate the web
service, it's just when I switch to embedded Jetty do problems occur.
Using the Maven standard directory layout, this is my file structure:
service-war
src
main
java
resources
webapp
WEB-INF
test
java
{several directories down} DoubleItPortTypeImplTest.java
resources
Within DoubleItPortTypeImplTest, this is my setup code:
server = new Server();
Connector connector = new SelectChannelConnector();
connector.setPort(9000);
server.setConnectors(new Connector[] {connector});
WebAppContext wactx = new WebAppContext();
wactx.setContextPath("/doubleit");
wactx.setWar("src/main/webapp");
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {wactx, new DefaultHandler()});
server.setHandler(handlers);
try {
server.start();
System.out.println("Service started!")
} catch (Exception e) {
e.printStackTrace();
}
The "Service started!" message appears when I run the test case, which
indicates at least that Jetty was able to run without an exception on the
server.start() call.
Here is the error message I'm getting when trying to run a test case:
Caused by: org.apache.cxf.service.factory.ServiceConstructionException:
Failed to create service.
at
org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:83)
at
org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:140)
... 30 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR:
Problem parsing
'http://localhost:9000/doubleit/services/DoubleItPortType?wsdl'.:
java.io.FileNotFoundException:
http://localhost:9000/doubleit/services/DoubleItPortType?wsdl
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at
org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:212)
... 32 more
Caused by: java.io.FileNotFoundException:
http://localhost:9000/doubleit/services/DoubleItPortType?wsdl
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1239)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
What I'm not sure about are what the values of wactx.setContextPath() and
wactx.setWar() above should be, or if that is my problem. Is the war path
"src/main/webapp" correct? Possibly, to test this, I used a nonexistent war
path "srczzz/main/webapp" and got a slightly different error message:
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR:
Problem parsing
'http://localhost:9000/doubleit/services/DoubleItPortType?wsdl'.:
java.io.IOException: Server returned HTTP response code: 503 for URL:
http://localhost:9000/doubleit/services/DoubleItPortType?wsdl
Can anyone see what the problem is?
Thanks,
Glen
[1] http://www.jroller.com/gmazza/date/20080417
--
View this message in context:
http://www.nabble.com/Problem-using-embedded-Jetty-in-Maven-JUnit-testcase-tp19216916p19216916.html
Sent from the cxf-user mailing list archive at Nabble.com.