Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » How to reference a project as an dependency for Dynamic web project(How to reference a project as an dependency for Dynamic web project)
icon5.gif  How to reference a project as an dependency for Dynamic web project [message #549275] Mon, 26 July 2010 11:04 Go to next message
J. N. is currently offline J. N.Friend
Messages: 11
Registered: July 2010
Junior Member
Hi all,

My problem is, that I have a Dynamic web project (P1) and a separate java project (P2) used as a dependency for P1.

My question is how to configure P1 to see and deploy content of P2 with libraries necessary for P2.

I want to run P1 in eclipse on Tomcat server and benefit of being able to change sources of P1 or P2 without necessity of restarting the server.

If you know about some tutorial please post it in.

I'm using J2EE Helios build x64

Thanks

J.
Re: How to reference a project as an dependency for Dynamic web project [message #549460 is a reply to message #549275] Mon, 26 July 2010 16:53 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 7/26/2010 7:04 AM, J. N. wrote:
> Hi all,
>
> My problem is, that I have a Dynamic web project (P1) and a separate
> java project (P2) used as a dependency for P1.
>
> My question is how to configure P1 to see and deploy content of P2 with
> libraries necessary for P2.
>
> I want to run P1 in eclipse on Tomcat server and benefit of being able
> to change sources of P1 or P2 without necessity of restarting the server.
>
> If you know about some tutorial please post it in.
> I'm using J2EE Helios build x64
>
> Thanks
>
> J.

In the Deployment Assembly page of P1's project Properties dialog, you
can add the dependency to the P2 project. Select Add -> Project and
choose P2, making sure the "Web Library Reference" option is checked.
The Java content from P2 will be built into a jar and included in P1's
WEB-INF/lib. As to whether the Tomcat server will need restarting will
depend on what you change. JSP and other static content can be updated
without restarting. Class changes will tend to require a restart unless
you are running in debug mode and the change is supported by hot code
replacement.

Cheers,
Larry
Re: How to reference a project as an dependency for Dynamic web project [message #549487 is a reply to message #549460] Mon, 26 July 2010 20:01 Go to previous messageGo to next message
J. N. is currently offline J. N.Friend
Messages: 11
Registered: July 2010
Junior Member
Hi Larry,

thanks for your response.

I did as you said. Actually, I tried that even before, but it didn't work and I wasn't sure I'm doing right thing.

In P1 project under Java Build Path -> Libraries -> Web App Libraries I can see my project P2, but I'm still getting this exception (what means my P2 classes was not loaded):

Caused by: java.lang.ClassNotFoundException: sk.rightSolutions.magicWand.InitializeSpring

I'm printing the content of P1 files :
org.eclipse.wst.common.component
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="MagicWand">
<wb-resource deploy-path="/" source-path="/WebContent"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<dependent-module archiveName="server.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/server/server">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="MagicWand"/>
<property name="java-output-path" value="/MagicWand/WebContent/WEB-INF/classes"/>
</wb-module>
</project-modules>


org.eclipse.wst.common.project.facet.core.xml
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.6"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.web" version="2.5"/>
</faceted-project>

Do you have any idea what can be wrong ?

I'm using this build :

Eclipse Java EE IDE for Web Developers.

Version: Helios Release
Build id: 20100617-1415

Thanks

J.
Re: How to reference a project as an dependency for Dynamic web project [message #549495 is a reply to message #549460] Mon, 26 July 2010 21:02 Go to previous messageGo to next message
J. N. is currently offline J. N.Friend
Messages: 11
Registered: July 2010
Junior Member
All right, have started again from scratch with two very simple projects.

P1 dynamic project
P2 dependency

Classes inside P2 compiles correctly and are accessible from P1 JSPs what is a good sign.

But, libraries from P2 are still not picked up by P1. Checkbox on Deployment Assembly was checked when adding P2 project. Any idea ?

Cheers

J.
Re: How to reference a project as an dependency for Dynamic web project [message #549647 is a reply to message #549495] Tue, 27 July 2010 13:05 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 7/26/2010 3:02 PM, J. N. wrote:
> All right, have started again from scratch with two very simple projects.
> P1 dynamic project
> P2 dependency
>
> Classes inside P2 compiles correctly and are accessible from P1 JSPs
> what is a good sign.
>
> But, libraries from P2 are still not picked up by P1. Checkbox on
> Deployment Assembly was checked when adding P2 project. Any idea ?
>
> Cheers
>
> J.

There are different ways of consuming a library in one project from
another. I have used an ant script at the root of the library project(s)
to build the project and copy the resulting JAR to the consuming project.

Maven is even better for this.

Larry may come back and tell us all how it's really done (and I'm keen
to hear that 'cause even after a few years using Eclipse, I still learn
new things all the time).

Best,

Russ
Re: How to reference a project as an dependency for Dynamic web project [message #549651 is a reply to message #549647] Tue, 27 July 2010 13:24 Go to previous messageGo to next message
J. N. is currently offline J. N.Friend
Messages: 11
Registered: July 2010
Junior Member
Hi Russ,

well, actually I'm using maven in my project, but what I want to achieve is to use maven for building final distribution (deploying on a production server), and have a development set up where I do not need to build all dependent jars myself before running the server and I want all libraries from dependent projects to be in a classpath as well.

btw : Is there any way how to create eclipse projects automatically from maven ? I tried that some time ago (mvn eclipse:eclipse), but it never created a proper dynamic web project when packaging was set to war in maven all project was just simple java projects.

Thanks

J.
Re: How to reference a project as an dependency for Dynamic web project [message #549675 is a reply to message #549495] Tue, 27 July 2010 13:56 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 7/26/2010 5:02 PM, J. N. wrote:
> All right, have started again from scratch with two very simple projects.
> P1 dynamic project
> P2 dependency
>
> Classes inside P2 compiles correctly and are accessible from P1 JSPs
> what is a good sign.
>
> But, libraries from P2 are still not picked up by P1. Checkbox on
> Deployment Assembly was checked when adding P2 project. Any idea ?
>
> Cheers
>
> J.

I had meant to cover this, but forgot. If P2 has runtime dependencies
on some of the libraries in it's build path, I recommend marking the
libraries for inclusion in WEB-INF/lib via P2's classpath. To do this
you will need to export the library jar(s) in the Order and Export tab
of the Java Build Path dialog for P2. Then open the Problems view. You
should see a warning like the following:

Classpath entry <some jar> will not be exported or published. Runtime
ClassNotFoundExceptions may result.

Right-click on the warning and select Quick Fix. The library jar(s)
should be included in what gets copied to WEB-INF/lib. If you forget to
export the jar, then the warning above gets replaced by one indicating
the jar isn't exported.

Cheers,
Larry
Re: How to reference a project as an dependency for Dynamic web project [message #549676 is a reply to message #549675] Tue, 27 July 2010 14:08 Go to previous messageGo to next message
J. N. is currently offline J. N.Friend
Messages: 11
Registered: July 2010
Junior Member
thanks, will try it at home and let you know the result.

Cheers

J.
Re: How to reference a project as an dependency for Dynamic web project [message #549776 is a reply to message #549675] Tue, 27 July 2010 22:26 Go to previous messageGo to next message
J. N. is currently offline J. N.Friend
Messages: 11
Registered: July 2010
Junior Member
Perfect, worked like a charm. Thanks a million.

Last question would be about fixing that warning. What exactly happened in background or in other words where can I see a result of that fix ... some property page with libraries for export.

One suggestion if I may ; would be great for you to have a few more complex totorials about how to use WTP. In our work we still use Sysdeo tomcat plugin, but we could benefit from WTP features. I was not allowed to migrate to Dynamic project because a lack of documentation opn the net. I found few tutorials, but all of them are very basic and does not explain things (there are just steps do this to that) with complex projects you need to know more about what happens in background. Is there any good resource / documentation about all the features of WTP ?

Thanks and wish you a good luck with this project looks awesome so far Smile

J.
Re: How to reference a project as an dependency for Dynamic web project [message #549931 is a reply to message #549776] Wed, 28 July 2010 13:43 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 7/27/2010 6:26 PM, J. N. wrote:
> Perfect, worked like a charm. Thanks a million.
> Last question would be about fixing that warning. What exactly happened
> in background or in other words where can I see a result of that fix ...
> some property page with libraries for export.

If you go to the Libraries tab on the Java Build Path page and expand a
jar that is marked for inclusion in WEB-INF/lib, you will see a child
item that says "Publish/export dependency: Added to parent module". You
can select this item and click "Remove" to "un-mark" the jar for inclusion.

You can also mark jars for inclusion using the "Referenced Projects
Classpath Entries" type in the Deployment Assembly page. However, this
can be somewhat confusing as it currently offers to mark for inclusion
all jars in all projects, not just the projects your current web project
depends on. Also, it's not clear that with the Deployment Assembly
approach, if you mark a jar for inclusion that is in a web project, you
are marking it so an EAR project will know that this web application
depends on this jar. It does not mark jars in web projects in a way
that includes it in the web project's WEB-INF/lib.
The Problems view approach works for marking dependent jars in both web
projects and utility projects. The Problems view approach also offers
the possibility to explicitly exclude the jar and make the warning go
away without including the jar.

> One suggestion if I may ; would be great for you to have a few more
> complex totorials about how to use WTP. In our work we still use Sysdeo
> tomcat plugin, but we could benefit from WTP features. I was not allowed
> to migrate to Dynamic project because a lack of documentation opn the
> net. I found few tutorials, but all of them are very basic and does not
> explain things (there are just steps do this to that) with complex
> projects you need to know more about what happens in background. Is
> there any good resource / documentation about all the features of WTP ?

The problem here is "easier said than done". I know in my case, I have
a limited number of cycles to devote to the Tomcat plug-ins in Eclipse.
Devoting them to working on the code tends to take priority over
working on documentation. The problem with documenting the migration of
external projects to WTP is that the starting point for those external
projects is just too varied. It would take a book, or a huge
programming effort, to deal all the different possibilities. To make
documenting practical, you would have to make a bunch of simplifying
assumptions. Unfortunately that makes it likely that not all migration
issues will be addressed for many external projects. It's better to say
to create a new Dynamic Web Project and port the content from the
external project to the Dynamic Web Project. When porting the content,
you have the responsibility to know if that content has special issues
or dependencies that must be addressed.

Cheers,
Larry

> Thanks and wish you a good luck with this project looks awesome so far :)
>
> J.
Re: How to reference a project as an dependency for Dynamic web project [message #549934 is a reply to message #549931] Wed, 28 July 2010 13:53 Go to previous message
J. N. is currently offline J. N.Friend
Messages: 11
Registered: July 2010
Junior Member
Grand thanks for explanations !

Cheers

J.
Previous Topic:WTP: packaging possible like war/ear?
Next Topic:how to create App Server specific deployment descriptors with WTP
Goto Forum:
  


Current Time: Thu Mar 28 16:57:24 GMT 2024

Powered by FUDForum. Page generated in 0.04381 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top