Cannot run JAX-WS Java Web Service on Apache Tomcat

前端 未结 2 994
说谎
说谎 2021-01-19 03:11

Summary

I\'ve been tasked to write a Java web service to integrate two disparate systems in our enterprise environment. Since I\'m actually an experienced C#.NET

2条回答
  •  -上瘾入骨i
    2021-01-19 03:54

    @NIKETBHANDARY helped me understand what was wrong and how to quickly correct it. I'd also like to post exactly what I did wrong and how I fixed it permanently so that future coders can benefit from my five-day experience. :-)

    When I originally built the tutorial using Netbeans, I used the Java Web --> Web Application template (which is available after installing the Java EE Base plugin accessible through Netbeans --> Tools --> Plugins):

    I built all the files exactly per the tutorial, but I failed to really read through step #5, especially this line:

    
    

    After further review, I found that the build script was producing a WAR file called HelloWorld.war. Then, when that file was deployed to Tomcat, the web application was called HelloWorld in the Tomcat Manager. That's why the service endpoint was set to http://localhost:8080/HelloWorld/hello. The "HelloWorld" is literally the name of the Tomcat application, and the "/hello" part corresponds with the endpoint from the sun-jaxws.xml file. (Looking back, it makes total sense given typical web hosting organization. IIS pretty much works the same way.)

    So, to fix the problem, I needed to modify the Netbeans project to produce a WAR file named HelloWorld.war. In the tutorial, he includes an actual Ant build script. In this case, I needed to take these steps:

    1. Right-click on the project in the Netbeans Project Explorer.
    2. Choose Properties.
    3. Click on the Build --> Packaging category.
    4. Set the WAR file field to HelloWorld.war.

    Here is a screenshot:

    Once that was done, I created a new build, deployed to my local Tomcat server, and everything worked as expected. I was also able to deploy the WAR file to my Linux server and test it successfully. Problem solved! :-)

提交回复
热议问题