Cannot run JAX-WS Java Web Service on Apache Tomcat

前端 未结 2 993
说谎
说谎 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条回答
  • 2021-01-19 03:52

    There is problem in deployment of your ws module. U have just copied the whole folder from the MKyoung sample. I doesn't work that way around.

    Not only that now display all the folders and files structure inside the ws module delete the rest of the modules from your post.I wanted only the structure of ws module.

    The module name has to sample instead of com.mkyoung.ws and the structure for it has to be

    **sample**
    ------WEB-INF
    ------index.jsp
    
    WEB-INF
    ----classes
    ----web.xml
    ----sun-jaxws.xml
    
    classes
    ----com
    --------mkyoung
    -----------ws
    ws
    -----Helloworld.class
    -----HeloworldIMPL.class
    
    0 讨论(0)
  • 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:

    <jar jarfile="${dist}/war/HelloWorld-${DSTAMP}.war" basedir="${dist}/war/build/"/>
    

    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! :-)

    0 讨论(0)
提交回复
热议问题