0

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

Ascendant
  • 827
  • 2
  • 16
  • 34
  • Are you trying to access the classes, or the source files used to build them? – Romski Feb 06 '13 at 02:41
  • @Romski I mean both. When I build my own web app and when it's deployed. – Ascendant Feb 06 '13 at 02:57
  • the Sleeping Dragon may find a better answer with a more illuminating question. what is it exactly that you are trying to achieve (not accessing the same classes, but for what purpose)? – rees Feb 06 '13 at 02:57
  • read here too http://stackoverflow.com/questions/4132545/how-does-class-loading-work-when-the-same-class-exists-in-different-applications – rees Feb 06 '13 at 03:25
  • @rees I want to have just one business logic that does the job. I don't want to put the two web apps in the same directory as one app. – Ascendant Feb 06 '13 at 03:38

2 Answers2

1

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).

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
0

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.

EdH
  • 4,918
  • 4
  • 24
  • 34
  • Wow you've got a point. but then, would I have to jar them every time there is a change in the source code of the first app ? – Ascendant Feb 06 '13 at 04:22
  • You'd only need to jar them if the classes in the JAR change. I guess I'm not understanding what you're packaging. But the contents of the JAR file should be code which is applicable in BOTH applications. Anything unique to each app should remain in the WAR as classes. – EdH Feb 06 '13 at 04:29
  • @PerfectGundam No, you'd jar them up every time there's a change in the business logic, and both applications would have the correct, current business logic implementation--which is what you'd want. – Dave Newton Feb 06 '13 at 04:30
  • Yes, that's correct. It does mean you start thinking about core, or common, or shared code which is used by more than one application. Which is not a bad thing. – EdH Feb 06 '13 at 04:51