views:

82

answers:

1

Hi,

I use a library which includes, among other things, a servlet. I've fetched the source for this lib to a dynamic web project and it works fine.

I'd like to make an example dynamic web application in another project which would just reference to the classes of this library. Is it possible to do it this way in Eclipse Galileo and deploy to Tomcat.

This I like to do, so that in the library source project I have only the libs own code and my modifications to it and my example app would be a totally another app.

In Eclipse I've referenced my example app project to the lib project and it works fine when coding, but when I try to access the example app URL it throws a ServletException because it can't find the Servlet. The libs own web page works fine.

+1  A: 

Can you not just create a JAR containing the classes you which to share and then reference this JAR in each project?

I would recommend staying away from IDE features like the ones in Eclipse that try to bundle up your app and deploy it for you - I find it helps much more to control this yourself, with your own build scripts, app server setup, etc.

This way you aren't stuck wondering why a certain nuance of the IDE works the way it does (such as, why is Eclipse not deploying the output of a project I've added as a "reference" along with this project?) - you can completely control your own environment. It's more valuable to know how to bundle up and deploy things on your own anyway (since it works the same regardless of whatever IDE you are using), and the tools behind it are a lot more powerful than any "press this shiny button and everything gets deployed and launched" feature in your IDE.

matt b
I agree that creating a commonly shared JAR would be the smartest thing in general. In this case, however, I'd like to avoid that. I like to have the lib source separate as-is and provided, so I can quickly generate patches and make changes to it efter SVN updates. The whole lib can be (and is) compiled to a JAR with a build script, but the problem is it takes 9 minutes, and I'd like the changes to be more snappy.
Jonas G