Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Projects dependencies, warnings Runtime ClassNotFoundExceptions may result, quick fixes
Projects dependencies, warnings Runtime ClassNotFoundExceptions may result, quick fixes [message #1820547] Wed, 22 January 2020 14:29 Go to next message
Léa Massiot is currently offline Léa MassiotFriend
Messages: 7
Registered: January 2020
Junior Member
Hello,

I am using Tomcat v9.0 and deploying war files to it.
I use Eclipse to develop the Webapps.

So, in Eclipse, I have two "Dynamic Web Projects" "dwp1" and "dwp2".
I have another Java project "jp".
Both classes of projects "dwp1" and "dwp2" need and use classes of project "jp".

For both projects "dwp1" and "dwp2", in Eclipse "Java Build Path -> Projects", I added the project "jp" under the "Classpath" section (there is also a "Modulepath" section which is empty) to declare that both projects depend on the "jp" project.

When I build "dwp1.war" and "dwp2.war", I can see, once deployed on Tomcat, under "WEB-INF/lib/" the jar file "jp.jar".
("jp.jar" once unjared, doesn't contain a "lib" directory with the jar file it depends on. Maybe it's normal, I don't know.)

Now, in Eclipse, I have two types of warnings:
WARNING_1 - Classpath entry /jp will not be exported or published. Runtime ClassNotFoundExceptions may result.
WARNING_2 - Classpath entry /jp/lib/xxx.jar will not be exported or published. Runtime ClassNotFoundExceptions may result.
where "xxx.jar" is a jar file in "jp/lib/".

WARNING_1
I saw, in Eclipse, that I could apply quick fixes, I selected this is one:
"Mark the associated raw classpath entry as a publish/export dependency"
It transforms "dwp1\.classpath"like this:
Before:
<classpathentry combineaccessrules="false" kind="src" path="/jp"/>
After:
<classpathentry combineaccessrules="false" kind="src" path="/jp">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>

WARNING_2
I saw, in Eclipse, that I could apply quick fixes, I selected this is one:
"Exclude the associated raw classpath entry from the set of potential publish/export dependencies"
It transforms "jp\.classpath" like this:
Before:
<classpathentry kind="lib" path="lib/xxx.jar"/>
After:
<classpathentry kind="lib" path="lib/xxx.jar">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>

The quick fixes make the warnings disappear but I don't understand what they do.
Shall I ignore these warnings, shall I apply the quick fixes or shall I do something else?

(I don't know for how long these warnings have been here but I used to ignore them and the Webapps worked correctly, they still do).

Thank you.
Best regards.
--
Léa
Re: Projects dependencies, warnings Runtime ClassNotFoundExceptions may result, quick fixes [message #1820548 is a reply to message #1820547] Wed, 22 January 2020 14:38 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4434
Registered: July 2009
Senior Member

Ideally you'll see the results in the Deployment Assembly property page for your web app projects. What it's done is alter the setup so that the output folders of "jp" are automatically used to create a jar in the web project's WEB-INF/lib directory, one that it will deploy with the web project and letting your classes from "jp" be found at runtime. If "jp" itself depends on a jar file, you might want to make sure jp's Java Build Path property page "exports" that dependency, or add it to the Deployment Assembly property page yourself.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Projects dependencies, warnings Runtime ClassNotFoundExceptions may result, quick fixes [message #1820579 is a reply to message #1820548] Thu, 23 January 2020 09:37 Go to previous messageGo to next message
Léa Massiot is currently offline Léa MassiotFriend
Messages: 7
Registered: January 2020
Junior Member
Nitin Dahyabhai wrote on Wed, 22 January 2020 14:38
Ideally you'll see the results in the Deployment Assembly property page for your web app projects.


For the web app project "dwp1", for example, below is what I can see in the "Deployment Assembly" property page:
-------------+------------------------
Source       | Deploy path
-------------+------------------------
/src         | WEB-INF/classes
/WebContent  | /
jp           | WEB-INF/lib/jp.jar
-------------+------------------------

Nitin Dahyabhai wrote on Wed, 22 January 2020 14:38
What it's done is alter the setup so that the output folders of "jp" are automatically used to create a jar in the web project's WEB-INF/lib directory, one that it will deploy with the web project and letting your classes from "jp" be found at runtime.


"jp" has one output folder, the default one: "jp/bin".

Nitin Dahyabhai wrote on Wed, 22 January 2020 14:38
If "jp" itself depends on a jar file, you might want to make sure jp's Java Build Path property page "exports" that dependency, or add it to the Deployment Assembly property page yourself.


Indeed, "jp" depends on several jar files.

For the "jp" project, here is what I can see in the "Deployment Assembly" property page:
-------------+------------------------
Source       | Deploy path
-------------+------------------------
/src         | /
-------------+------------------------


In "jp"'s Java Build Path property page, where should I check that the dependencies are exported?

Thank you.
Best regards.
Re: Projects dependencies, warnings Runtime ClassNotFoundExceptions may result, quick fixes [message #1820596 is a reply to message #1820579] Thu, 23 January 2020 16:22 Go to previous message
Léa Massiot is currently offline Léa MassiotFriend
Messages: 7
Registered: January 2020
Junior Member
Honestly, I don't know what to do.
I'm probably dumb.

At last, I stumbled on a "java.lang.NoClassDefFoundError: javax/activation/DataSource" error.
And indeed "activation.jar" is one of the jar files the "jp" project depends on.

I don't understand the quick fix messages I mentioned in my first post:
"Mark the associated raw classpath entry as a publish/export dependency"
"Exclude the associated raw classpath entry from the set of potential publish/export dependencies"
So I don't know if I should apply either of them.

In the "Java Build Path -> Order and export" tab of the "jp" project, I checked the check box in front of "activation.jar - jp/lib".
I still have the warning:
Classpath entry /jp/lib/activation.jar will not be exported or published. Runtime ClassNotFoundExceptions may result.

[Updated on: Thu, 23 January 2020 16:27]

Report message to a moderator

Previous Topic:Running Eclipse.exe as another Windows user
Next Topic:Yet another new install
Goto Forum:
  


Current Time: Sat Apr 20 02:53:13 GMT 2024

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

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

Back to the top