0
votes

I have a liferay portlet. I've added some external libraries using maven. In ide no errors, it can recognize, but when deploying with ant , it says no such package and class

import pack.SomeClass;
The import pack cannot be resolved

code:

import pack.SomeClass;
public class MainPortlet extends MVCPortlet {
    public void doView(RenderRequest renderRequest,RenderResponse renderResponse) {
        SomeClass a = new SomeClass();
    }
}
1
What does this have to do with Maven? How do you build the Classpath for deployment? - user1907906
You wrote that you add Maven dependency but you are deploying with Ant. It seems awkward. Does your Ant script knows about Maven dependencies? Are you using Ivy? - Grzegorz Żur
If the dependency is a liferay jar, like the util-taglib.jar then use liferay-plugin-package.properties to define the dependency and if it is not a liferay jar or custom jar then I suppose you would need to put it in the WEB-INF/lib, check if the deployed WAR file has the dependency jars in WEB-INF/lib if not then ANT does not recognize the maven dependency so either make ANT know or use Maven to build the WAR file. - Prakash K

1 Answers

0
votes

If you are using maven and you have defined your dependency with scope as system or provided likeSystem or provided> then it will not be included in war file generated on deployment or package.

If you have third party jar on local and you want to include them in your war file then install that jar file to your local repository and remove scope from pom.xml then while package maven will include that jar file to your war and you not get any error on deployment

Command to install jar in your local repository

mvn install:install-file -Dfile=c:\kaptcha-{version}.jar -DgroupId=com.google.code 
-DartifactId=kaptcha -Dversion={version} -Dpackaging=jar

Hope it helps!!