Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Problems including dependent projects in Dynamic Web Projects(Neither Tomcat nor Eclipse's local server can run my JSP, presumably due to lack of a dependency)
Problems including dependent projects in Dynamic Web Projects [message #693600] Wed, 06 July 2011 20:34 Go to next message
Mike Spreitzer is currently offline Mike SpreitzerFriend
Messages: 4
Registered: July 2011
Junior Member
I created a Dynamic Web Project, call it A. In it I put a JSP and a Java class, call it AC; the JSP instantiates and uses AC. That Java class extends one from another project, say class BC from project B; project B is an ordinary Java project (which, in turn, depends on some other ordinary Java projects, and so on). When I select my JSP in the Package Explorer and do "Debug As ... > Debug on Server", using "J2EE Preview at localhost" as the server, it fails with the following complaint (in the "Variables" tab in the Debug perspective):

org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
The type BC cannot be resolved. It is indirectly referenced from required .class files

I have futzed with various project properties, such that now when I ask Eclipse to generate a WAR for project A, its WEB-INF/lib/ includes a virtual JAR from project B. The first step in that was to open the project properties for A, and include B in the Web Deployment Assembly. That was not sufficient. I then checked the check-box for B in the listing in the "Order and Export" tab of the Java Build Path section of the project properties. That may or may not have been sufficient. Then I created an unrelated EAR project and deleted it. Now WAR export of project A works as you would expect.

I might not have all the projects transitively required at runtime in both the Web Deployment Assembly and checked in the Order and Export list of project A. But the complaint given mentions only the class I am calling BC --- which extends java.lang.Object.

What is going wrong, and/or how can I find out more details about it for myself? How do I fix it?

BTW, when I export a WAR from project A and try to run it in Tomcat 7.0.16, it fails in the JSP compliation step. However, Tomcat only tells me that the compilation failed on the JSP line that instantiates class AC; it does not give any more details.

I am using Eclipse Helios Service Release 2 (Build id: 20110218-0911) on MacOS 10.6.8 on a MacBook Pro (Intel), with

$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)
Re: Problems including dependent projects in Dynamic Web Projects [message #693923 is a reply to message #693600] Thu, 07 July 2011 13:44 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 7/6/2011 4:34 PM, Mike Spreitzer wrote:
> I created a Dynamic Web Project, call it A. In it I put a JSP and a Java
> class, call it AC; the JSP instantiates and uses AC. That Java class
> extends one from another project, say class BC from project B; project B
> is an ordinary Java project (which, in turn, depends on some other
> ordinary Java projects, and so on). When I select my JSP in the Package
> Explorer and do "Debug As ... > Debug on Server", using "J2EE Preview at
> localhost" as the server, it fails with the following complaint (in the
> "Variables" tab in the Debug perspective):
>
> org.apache.jasper.JasperException: Unable to compile class for JSP
>
> Generated servlet error:
> The type BC cannot be resolved. It is indirectly referenced from
> required .class files
>
> I have futzed with various project properties, such that now when I ask
> Eclipse to generate a WAR for project A, its WEB-INF/lib/ includes a
> virtual JAR from project B. The first step in that was to open the
> project properties for A, and include B in the Web Deployment Assembly.
> That was not sufficient. I then checked the check-box for B in the
> listing in the "Order and Export" tab of the Java Build Path section of
> the project properties. That may or may not have been sufficient. Then I
> created an unrelated EAR project and deleted it. Now WAR export of
> project A works as you would expect.
>
> I might not have all the projects transitively required at runtime in
> both the Web Deployment Assembly and checked in the Order and Export
> list of project A. But the complaint given mentions only the class I am
> calling BC --- which extends java.lang.Object.
>
> What is going wrong, and/or how can I find out more details about it for
> myself? How do I fix it?
>
> BTW, when I export a WAR from project A and try to run it in Tomcat
> 7.0.16, it fails in the JSP compliation step. However, Tomcat only tells
> me that the compilation failed on the JSP line that instantiates class
> AC; it does not give any more details.
>
> I am using Eclipse Helios Service Release 2 (Build id: 20110218-0911) on
> MacOS 10.6.8 on a MacBook Pro (Intel), with
>
> $ java -version
> java version "1.6.0_26"
> Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
> Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)
>

I don't think WTP is able to handle dependencies of dependencies. So
adding B as a dependent project of A in Deployment Assembly was correct,
but you will also need to add the Java projects that B depends on. Jar
dependencies can be added to the Java Build Path of project A. In the
Markers view a warning will appear under the Classpath Dependency
Validator Message group. The Quick Fix for that warning can "mark" that
Jar for inclusion in "WEB-INF/lib".

For additional details about the WTP Tomcat support see the Tomcat FAQ[1].

Cheers,
Larry

[1] http://wiki.eclipse.org/WTP_Tomcat_FAQ
Re: Problems including dependent projects in Dynamic Web Projects [message #694034 is a reply to message #693923] Thu, 07 July 2011 16:59 Go to previous messageGo to next message
Mike Spreitzer is currently offline Mike SpreitzerFriend
Messages: 4
Registered: July 2011
Junior Member
There is indeed one case of a JAR that is needed from a distant dependency (a project named guava-r09) (all the other transitive dependencies come from sources managed by Eclipse), and indeed the Markers view had a warning. It read:

Classpath entry /guava-r09/guava-r09.jar will not be exported or published. Runtime ClassNotFoundExceptions may result.

There were two quick fixes offered, which I quote here:

1. Mark the associated raw classpath entry as a publish/export dependency.

2. Exclude the associated raw classpath entry from the set of potential publish/export dependencies.

I picked 1. That lead to a new warning:

Projects must be referenced by an EAR or a WAR to use classpath publish/export dependencies whose runtime path (../) maps into the parent component.

So I opened the properties sheet of my Dynamic Web Project and went to the Project References section. I saw that guava-r09 was not among the checked projects, so I checked it. The warning remains.
(no subject) [message #694036 is a reply to message #693923] Thu, 07 July 2011 16:59 Go to previous messageGo to next message
Mike Spreitzer is currently offline Mike SpreitzerFriend
Messages: 4
Registered: July 2011
Junior Member
There is indeed one case of a JAR that is needed from a distant dependency (a project named guava-r09) (all the other transitive dependencies come from sources managed by Eclipse), and indeed the Markers view had a warning. It read:

Classpath entry /guava-r09/guava-r09.jar will not be exported or published. Runtime ClassNotFoundExceptions may result.

There were two quick fixes offered, which I quote here:

1. Mark the associated raw classpath entry as a publish/export dependency.

2. Exclude the associated raw classpath entry from the set of potential publish/export dependencies.

I picked 1. That lead to a new warning:

Projects must be referenced by an EAR or a WAR to use classpath publish/export dependencies whose runtime path (../) maps into the parent component.

So I opened the properties sheet of my Dynamic Web Project and went to the Project References section. I saw that guava-r09 was not among the checked projects, so I checked it. The warning remains.
Re: Problems including dependent projects in Dynamic Web Projects [message #694106 is a reply to message #694034] Thu, 07 July 2011 20:05 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 7/7/2011 12:59 PM, Mike Spreitzer wrote:
> There is indeed one case of a JAR that is needed from a distant
> dependency (a project named guava-r09) (all the other transitive
> dependencies come from sources managed by Eclipse), and indeed the
> Markers view had a warning. It read:
>
> Classpath entry /guava-r09/guava-r09.jar will not be exported or
> published. Runtime ClassNotFoundExceptions may result.
>
> There were two quick fixes offered, which I quote here:
>
> 1. Mark the associated raw classpath entry as a publish/export dependency.
>
> 2. Exclude the associated raw classpath entry from the set of potential
> publish/export dependencies.
>
> I picked 1. That lead to a new warning:
>
> Projects must be referenced by an EAR or a WAR to use classpath
> publish/export dependencies whose runtime path (../) maps into the
> parent component.
>
> So I opened the properties sheet of my Dynamic Web Project and went to
> the Project References section. I saw that guava-r09 was not among the
> checked projects, so I checked it. The warning remains.

Not knowing your exact project "layout" I can't say for sure, but I
believe the new warning implies that you added the jar dependency to a
Java project and not the web project. I don't know if the experiment
with the EAR file could be having a leftover impact if you added the jar
to the webapp.

All the runtime dependencies need to be added to the web project
(assuming you are not deploying using an EAR). For jars added to the
web project, the "org.eclipse.jst.component.dependency" attribute added
in the web project's ".classpath" file needs to have a value of
"/WEB-INF/lib" and not "../".

Since guava-r09 is a Java project, you could instead add it as a project
dependency in the web project using Deployment Assembly. This assumes
you are not using something like Maven to build extra "stuff" into
guava-r09.jar that the Eclipse build isn't including the project's
output folder.

Checking projects in the Project References of the Java Build Path of
the web project won't help with runtime dependencies. The Eclipse Java
support for this form of build dependency doesn't provide a way for WTP
to mark it for inclusion in WEB-INF/lib.

Cheers,
Larry
Re: Problems including dependent projects in Dynamic Web Projects [message #694223 is a reply to message #693600] Fri, 08 July 2011 06:35 Go to previous messageGo to next message
Mike Spreitzer is currently offline Mike SpreitzerFriend
Messages: 4
Registered: July 2011
Junior Member
I actually suspect this guava business is a distraction from my main problem, read the second half of this post.

Like I said, it was in the Dynamic Web Project (which I am calling A here) that I opened the properties sheet and added a Project Reference to guava-r09.

Since reading you latest post, I also made three more changes. First, I opened the properties sheet of Dynamic Web Project A again, went to the Java Build Path section, the Libraries tab, clicked "Add JARs...", navigated to the guava-r09.jar in the guava-r09 project, and added it. Then I went to the Order and Export tab and saw that the guava-r09.jar was now listed there but not checked, so I checked it. After OKing the changes I noticed I now had two markers --- the one I last complained about and also another copy of the one I first mentioned (for which I then did the same QuickFix as before). Now I only have the marker whose properties sheet says

Description: Projects must be referenced by an EAR or a WAR to use classpath publish/export dependencies whose runtime path (../) maps into the parent component.

On element: guava-r09

I really am having trouble seeing what more I can do to Dynamic Web Project A to make guava-r09 happy. Here is the .classpath that I now have for A:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/B"/>
... the deeper Java project dependencies ...
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/guava-r09"/>
<classpathentry exported="true" kind="lib" path="/guava-r09/guava-r09.jar" sourcepath="/guava-r09/guava-src-r09.zip">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/guava-r09/guava-javadoc-r09.zip!/"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="build/classes"/>
</classpath>

and here is what A's .project has to say about its natures:

<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>

and, while we're at it, here is the .classpath of guava-r09:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="guava-r09.jar" sourcepath="guava-src-r09.zip">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/guava-r09/guava-javadoc-r09.zip!/"/>
<attribute name="org.eclipse.jst.component.dependency" value="../"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>



Having reorganized the code a bit, I again tried to debug my Dynamic Web Project using Eclipse's J2EE preview server. When the JSP was visited by a browser it returned a page that started with the following complaint and continued with stack traces.


HTTP ERROR 500

Problem accessing /A/maker.jsp. Reason:

java.lang.NoClassDefFoundError: B/BC
Re: Problems including dependent projects in Dynamic Web Projects [message #694411 is a reply to message #694223] Fri, 08 July 2011 14:04 Go to previous message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 7/8/2011 2:35 AM, Mike Spreitzer wrote:
> I actually suspect this guava business is a distraction from my main
> problem, read the second half of this post.
>
> Like I said, it was in the Dynamic Web Project (which I am calling A
> here) that I opened the properties sheet and added a Project Reference
> to guava-r09.
>
> Since reading you latest post, I also made three more changes. First, I
> opened the properties sheet of Dynamic Web Project A again, went to the
> Java Build Path section, the Libraries tab, clicked "Add JARs...",
> navigated to the guava-r09.jar in the guava-r09 project, and added it.
> Then I went to the Order and Export tab and saw that the guava-r09.jar
> was now listed there but not checked, so I checked it. After OKing the
> changes I noticed I now had two markers --- the one I last complained
> about and also another copy of the one I first mentioned (for which I
> then did the same QuickFix as before). Now I only have the marker whose
> properties sheet says
>
> Description: Projects must be referenced by an EAR or a WAR to use
> classpath publish/export dependencies whose runtime path (../) maps into
> the parent component.
>
> On element: guava-r09
>
> I really am having trouble seeing what more I can do to Dynamic Web
> Project A to make guava-r09 happy. Here is the .classpath that I now
> have for A:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <classpath>
> <classpathentry kind="src" path="src"/>
> <classpathentry kind="con"
> path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
>
> <attributes>
> <attribute name="owner.project.facets" value="java"/>
> </attributes>
> </classpathentry>
> <classpathentry kind="con"
> path="org.eclipse.jst.j2ee.internal.web.container"/>
> <classpathentry kind="con"
> path="org.eclipse.jst.j2ee.internal.module.container"/>
> <classpathentry combineaccessrules="false" exported="true" kind="src"
> path="/B"/>
> ... the deeper Java project dependencies ...
> <classpathentry combineaccessrules="false" exported="true" kind="src"
> path="/guava-r09"/>
> <classpathentry exported="true" kind="lib"
> path="/guava-r09/guava-r09.jar" sourcepath="/guava-r09/guava-src-r09.zip">
> <attributes>
> <attribute name="javadoc_location"
> value="jar:platform:/resource/guava-r09/guava-javadoc-r09.zip!/"/>
> <attribute name="org.eclipse.jst.component.dependency"
> value="/WEB-INF/lib"/>
> </attributes>
> </classpathentry>
> <classpathentry kind="output" path="build/classes"/>
> </classpath>
>
> and here is what A's .project has to say about its natures:
>
> <natures>
> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
> <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
> <nature>org.eclipse.jdt.core.javanature</nature>
> <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
> </natures>
>
> and, while we're at it, here is the .classpath of guava-r09:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <classpath>
> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
> <classpathentry exported="true" kind="lib" path="guava-r09.jar"
> sourcepath="guava-src-r09.zip">
> <attributes>
> <attribute name="javadoc_location"
> value="jar:platform:/resource/guava-r09/guava-javadoc-r09.zip!/"/>
> <attribute name="org.eclipse.jst.component.dependency" value="../"/>
> </attributes>
> </classpathentry>
> <classpathentry kind="con"
> path="org.eclipse.jst.j2ee.internal.module.container"/>
> <classpathentry kind="output" path="build/classes"/>
> </classpath>
>
>
>
> Having reorganized the code a bit, I again tried to debug my Dynamic Web
> Project using Eclipse's J2EE preview server. When the JSP was visited by
> a browser it returned a page that started with the following complaint
> and continued with stack traces.
>
>
> HTTP ERROR 500
>
> Problem accessing /A/maker.jsp. Reason:
>
> java.lang.NoClassDefFoundError: B/BC
>

My guess at this point is that the problems may be stemming from the
guava-r09 project. Given that the ".classpath" file contains no "src"
<classpathentry>, it suggests that this project simply "holds" the
guava-r09.jar. The presence of the
"org.eclipse.jst.j2ee.internal.module.container" <classpathentry>
indicates the guava-r09 project has been upgraded to be the JavaEE type
project, which WTP supports. I believe that WTP expects its JavaEE
project to actually build something (internally referred to as a
"module"). I'm not sure if "jar holder" projects will work correctly
with WTP. If "guava-r09" is actually a "jar holder" project, then it
would be better if no other project directly referenced this project,
but instead, directly referenced the jar it contains.

If the guava-r09 project is more than just a jar holder, please provide
details about how it was created and what this project is supposed to
create.

Regardless, the "org.eclipse.jst.component.dependency" attribute should
not be present in the guava-r09 ".classpath" file. It's the one
causing the warning. I believe it would only be useful if this project
were directly referenced (via Deployment Assembly) in an EAR project.

Cheers,
Larry

P.S. For testing with Tomcat, you can use the WTP Tomcat FAQ mentioned
earlier to determine where the webapp is being published to see what
Tomcat is actually trying to run. If what you need isn't being
assembled there correctly, it obviously won't work the way you expect.
I'm not sure what is ending up there for guava-r09, if anything.
Previous Topic:Search inside Content Outline
Next Topic:Java EE Module Configuration Editors Proposal Posted
Goto Forum:
  


Current Time: Tue Apr 23 07:17:09 GMT 2024

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

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

Back to the top