James-Jesse Drinkard
James-Jesse Drinkard

Reputation: 15703

How do I run a war as a web service locally using java and tomcat?

I have some java client code that is making a connection to a web service in a war sitting on a remote server. I'm using myeclipse 10.0, java 1.6, cxf 2.2, the embedded tomcat 6 localhost server and I'm running tomcat 6 off the command line, both tomcats are running on the same machine.

When my wsdl file points to the service on the remote server everything works fine, however, when I set up everything on my one machine, I get a java.io exception when I try to reach the service.

I setup both instances of tomcat on different ports, I can see everything loads up fine with ProcessExplorer and using netstat I can see that the ports are working with their listeners with no conflicts. I used the information from this link to setup tomcat instances. I then copied the war file over to the webapps directory and I saw that tomcat exploded the classes and loaded them. We are also using a cacerts file for ssl authentication and I verified that it is in the correct location in the jvm.

Here is the error: Caused by: java.io.IOException: // at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2071) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2022) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1947) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:472) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:302) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254) at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:123) at $Proxy71.get(Unknown Source)

I'm using this url to hit the webservice endpoint:

http://localhost:7070/<root context>/<serviceName>

Any ideas why this isn't working or if there is a better way to do this?

Aftermath:

The war file I'm using was from a repo and added the date to it's name when I downloaded it. I changed the name of the war to match the context root by stripping off the date, redeployed it and everything started working.

Upvotes: 0

Views: 1999

Answers (2)

James-Jesse Drinkard
James-Jesse Drinkard

Reputation: 15703

The war file I'm using was from a repo which added the date to it's name when I downloaded it. When I revisited what I had done, I realized this issue, so I changed the name of the war to match the context root by stripping off the date, redeployed it and everything started working.

Upvotes: 1

Asker
Asker

Reputation: 11

Just copy the war file in the tomcat webapps directory and then Restart Tomcat. The war file will automatically be converted into the app folder

Upvotes: 0

Related Questions