Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 803
Spring Avatar asked May 16 '11 12:05

Spring


People also ask

What is the difference between WAR and JAR files?

JAR files allow us to package multiple files in order to use it as a library, plugin, or any kind of application. On the other hand, WAR files are used only for web applications. The structure of the archives is also different. We can create a JAR with any desired structure.

Is a WAR file a JAR file?

A JAR file is a file with Java classes, associated metadata and resources such as text, images aggregated into one file. A WAR file is a file that is used to distribute a collection of JAR files, JSP, Servlet, XML files, static web pages like HTML and other resources that constitute a web application.

What is difference between WAR and JAR and ear files?

Usage. JAR file allows Java Runtime Environment (JRE) to deploy an entire application including the classes and related resources in a single request. WAR file allows testing and deploying web applications easily while EAR file allows deploying different modules onto an application server simultaneously.

Can I convert WAR to JAR?

It is impossible. Diferent platform have diferent formats for executables.


1 Answers

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.

like image 89
Johan Sjöberg Avatar answered Oct 26 '22 10:10

Johan Sjöberg