简体   繁体   中英

NullPointerException when building Liferay projects with Maven

I'm creating Liferay plugins using Maven instead of Ant.

The problem is that in some development environments I was getting the following exception when I tried to run mvn clean package :

[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException
    at com.liferay.maven.plugins.AbstractLiferayMojo.execute(AbstractLiferayMojo.java:88)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Caused by: java.lang.NullPointerException
    at com.liferay.maven.plugins.AbstractLiferayMojo.getProjectClassPath(AbstractLiferayMojo.java:268)
    at com.liferay.maven.plugins.AbstractLiferayMojo.getProjectClassLoader(AbstractLiferayMojo.java:255)
    at com.liferay.maven.plugins.SassToCssBuilderMojo.doExecute(SassToCssBuilderMojo.java:90)
    at com.liferay.maven.plugins.AbstractLiferayMojo.execute(AbstractLiferayMojo.java:81)
    ... 19 more

I already have the answer for this problem, and I'm just adding this question to share that knowledge; I couldn't find this error anywhere.

The error doesn't have anything to do with the plugin itself but with Maven's version. The error is thrown when you try to build your Liferay project using an old version of Maven.

When we updated Maven to v3.0.5, the error when away and the project is building correctly.

Have you tried running:

clean package liferay:deploy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM