Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse and IvyDE warning: Classpath Dependency Validator Message

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?

like image 765
Philipi Willemann Avatar asked Jul 17 '13 01:07

Philipi Willemann


1 Answers

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.

like image 185
gamerson Avatar answered Sep 22 '22 05:09

gamerson