Eclipse and IvyDE warning: Classpath Dependency Validator Message
Asked Answered
A

1

9

I created a new Dynamic Web Project in Eclipse Kepler, and as it's my first time using IvyDE, I put some dependencies to test it out. here is my ivy.xml:

<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
    <info
        organisation="net.myorg"
        module="mymodule"
        status="integration">
    </info>
    <dependencies>
       <dependency org="org.hibernate" name="hibernate-entitymanager" rev="4.2.3.Final"></dependency>
       <dependency name="log4j" rev="1.2.17" org="log4j"></dependency>
    </dependencies>
</ivy-module>

The dependencies where resolved and I can see them in the project libraries.

But after this, my project started giving this warning:

Description Resource    Path    Location    Type
Classpath entry org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=myproject&ivyXmlPath=ivy.xml&confs=*&acceptedTypes=jar%2Cbundle%2Cejb%2Cmaven-plugin&alphaOrder=false&resolveInWorkspace=true&retrievedClasspath=true&retrievedClasspathPattern=lib%2F%5Btype%5Ds%2F%5Bartifact%5D-%5Brevision%5D.%5Bext%5D&retrievedClasspathSync=true&retrievedClasspathTypes=* will not be exported or published. Runtime ClassNotFoundExceptions may result.      myproject       P/myproject Classpath Dependency Validator Message

So if I am understanding it right, Eclipse is warning me that the IvyDE entry in the classpath don't correspond to a resource that will be in the builded project. I suppose this is the expected behavior, if so, is there a way to remove this warning from the project, without disabling every Classpath Dependency Validator Message?

Afterlife answered 17/7, 2013 at 1:42 Comment(0)
C
19

The reason for the warning message is that the Eclipse flexible project deployment mechanism doesn't know whether or not to deploy the libraries referenced by the Ivy container. So you need to explicitly tell it which you want to do, deploy the jars to WEB-INF/lib or not.

If you need this container deployed to WEB-INF/lib you need to:

  1. Right click project go to properties
  2. Select Deployment Assembly
  3. Click Add
  4. Select "Java build path entries"
  5. Select the Ivy container
  6. Click Finish
  7. Make sure the Deploy Path is set to "WEB-INF/lib"

Deployment Assembly setting

If you look into the .classpath settings file you will see this adds an entry like this:

<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=ivy-test-portlet&amp;ivyXmlPath=ivy.xml&amp;confs=*&amp;ivySettingsPath=%24%7Bliferay_sdk_dir%3Aivy-test-portlet%7D%2Fivy-settings.xml&amp;loadSettingsOnDemand=false&amp;ivyUserDir=%24%7Bliferay_sdk_dir%3Aivy-test-portlet%7D%2F.ivy&amp;propertyFiles=">
    <attributes>
        <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
    </attributes>
</classpathentry>

Notice the <attributes>...</attributes> element has been added. Also my Ivy container path will be different than yours as this is a Ivy container path for one of my own projects.

Now if you don't need to deploy these libraries contained in the Ivy container to your runtime, then you need to tell Eclipse that there is no dependency on these libraries at runtime. You can do that by adding the appropriate attributes in the .classpath file.

  1. Open .classpath file
  2. Find the entry for the Ivy container
  3. Manually add the following attributes element as a child element of the classpathentry

The final element will look something like this. Your path will have different options but the key part is the attributes child element:

<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=ivy-test-portlet&amp;ivyXmlPath=ivy.xml&amp;confs=*&amp;ivySettingsPath=%24%7Bliferay_sdk_dir%3Aivy-test-portlet%7D%2Fivy-settings.xml&amp;loadSettingsOnDemand=false&amp;ivyUserDir=%24%7Bliferay_sdk_dir%3Aivy-test-portlet%7D%2F.ivy&amp;propertyFiles=">
    <attributes>
        <attribute name="org.eclipse.jst.component.nondependency" value=""/>
    </attributes>
</classpathentry>

Either one that you choose, you have explicitly told Eclipse how to handle this library container dependency during deployment. So now you can re-validate the project (right click project and choose "Validate") and you should see the error go away.

Copyboy answered 23/7, 2013 at 11:56 Comment(2)
It is worth noting that Eclipse's "Quick Fix" tool can do both procedures you describe automatically.Holcman
What should I do if the warning remains? I have checked the Deploy Path is set to WEB-INF/lib and .classpath has the classpathentry: <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=Document+Manager&amp;ivyXmlPath=ivy.xml&amp;confs=default&amp;ivySettingsPath=%24%7Bworkspace_loc%3ADocument+Manager%2Fivysettings.xml%7D&amp;loadSettingsOnDemand=false&amp;ivyUserDir=&amp;propertyFiles="> <attributes> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> </attributes> </classpathentry>Elva

© 2022 - 2024 — McMap. All rights reserved.