Ascendant
Ascendant

Reputation: 827

Access classes in another web application

I've got two web applications.

The first one is already up and running and the second one
is what I need to develop.

I cannot modify the first web application in any way but these web apps are going to be
on the same machine.

Q : Is there any way I can import the classes in the first web app into any of my classes?

I've googled a bit. So far it seems I could do it by using MENIFEST.MF.
I tried but could not get this working.

I also tried including the first web application into the build path of the second web app
in eclipse.

You might wonder here, if you can include the first web apps' classes into the second's
in eclipse, then you have access to the source files of the first web app ?

True but I connot modify them in anyway nor other deployment descriptor nor spring xml configuration files.

I'm thinking I could get this done in sheer Java classpath-ish manner since those two
web apps are going to be on the same machine but I don't have any useful idea on how exactly
get it working.

Thank you : )

Edit I'll try and clarify more as much as I can.
Some other guy built a mobile web service and it's running(the first web app).
I need to add in 'desktop web service'.
Both services share the same business logic.
So I'm trying to receive a http request from the client who's using PC,
and in my own service layer, it will make instances of the mobile web servies' business logic classes, invoke methods on them, get results and show them to the client.
Both services will have its own domain name.


Edit II

The business logic is here

webapps/shop/WEB-INF/classes

My web app will be here

webapps/web

I want my classes under

webapps/web/WEB-INF/classes

be able to instantiate and invoke methods from the objects
defined in /webapps/shop/WEB-INF/classes


Hope this helps understand my question better : )

Upvotes: 0

Views: 782

Answers (2)

EdH
EdH

Reputation: 5003

Why not simply move the code which is to be used by both applications in a single JAR. Manage it as a separate project/module/whatever you would like to call it. Each Web application would simply include the JAR file in it's list of dependencies and both have access to the common code.

Upvotes: 0

Dave Newton
Dave Newton

Reputation: 160251

The business logic should live in its own jar file and be used by both web apps by putting it in each app's WEB-INF/lib directory.

You only have access to the source files of the first app if you have the source files of the first app; they're not automagically deployed in a war file (and in general, wouldn't be).

Upvotes: 1

Related Questions