Web service as a JAR file, or WAR inside another WAR?

12,209

I would recommend that you make a JAR out of your webservice and put that in the lib folder. The good thing about java is that it doesn't matter where your code is located as long as you load it right.

I don't think you can have WAR inside WAR. You can however merge two WAR projects into one (which can be performed e.g., by the maven build system). Still, merging WARs is a copy-paste-overwrite operation which leaves alot to desire.

Share:
12,209
Spring
Author by

Spring

Updated on July 19, 2022

Comments

  • Spring
    Spring almost 2 years

    I have a SOAP web service running on Tomcat 6 (using Spring Web Services, Java)

    Now I want to merge this webservice into another big web application (uses Spring, Java and not a web service) and use the web service as kinda plugin for the main web app. I mean when I run my main app my web service will also start to run. And they will use the same resources.

    The main web app already has several plugins which are JAR files in its WEB-INF/LIB folder. But my web service is a WAR file so can I use a web application (WAR file) inside another web applications WEB-INF/LIB folder?

    If I can not do that is that possible to remove the WEB-INF folder of my web service and make my web service a JAR file and put it under my main apps WEB-INf/LIB folder? I am not sure that I can serve a web service as a JAR file.

    Which approach do you think is better or do you have other suggestions?

    Thanks

  • Spring
    Spring almost 13 years
    Could you tell me a bit more how can I make a jar out of a spring-ws soap web service?
  • Johan Sjöberg
    Johan Sjöberg almost 13 years
    Just create a regular jar-project using your favourite IDE, or create it manually from your java-files following Oracle's guide. This webservice jar-file needs to be no different from any other jar. Just remember to include spring-ws dependencies as jar-files too in your WAR project.
  • Spring
    Spring almost 13 years
    Thanks, So I will only remove the WEB-INF folder of my webservice(because I want to use the main apps web-inf folder) and add everything to the jar file including all my xmlconfiguration files (spring.wsdl, applicationcontext.xml..etx) and it will work?
  • Johan Sjöberg
    Johan Sjöberg almost 13 years
    You can store e.g., config files in a jar but you must make sure you load it from the jar too! I would recommend putting configuration (spring.wsdl, applicationcontext.xml, etc.,) in your WAR project which imports the webservice jar.
  • Spring
    Spring almost 13 years
    in this case how can I have access from my webservice to WAR files web-infs folder? if I directly write schemaLocation="/WEB-INF/schemas/Response.xsd"/> will it refer to WAR files WEB-INF folder?