Maven plugin builds but can't execute due to j

2019-08-06 03:50发布

问题:

I am using the maven-jspc-plugin in my pom.xml.

When i try to execute the jsp-compile goal (which executes the plugin) I get:

Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 
at org.apache.juli.logging.Slf4jLog.<init>(Slf4jLog.java:29) 
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:54)    
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:35) 
at org.apache.sling.scripting.jsp.jasper.compiler.OriginalTldLocationsCache.<init>(OriginalTldLocationsCache.java:81) 
at org.apache.sling.maven.jspc.JspcMojo.initServletContext(JspcMojo.java:426) 

I've tried downloading the (open) source for the maven-jspc-plugin and i am able to easily "mvn install" -- I don't get any build issues, however when i use that build in my project pom it still crashes and tells me it can't find LoggerFactory.

I've logged an issue with the Apache Sling project but am not making much headway. https://issues.apache.org/jira/browse/SLING-2350 This link includes some more troubleshooting info as well as a simple maven project that uses the maven plugin. downloading the jspc-test.zip and "mvn install"ing will result in the error I've mentioned.

Also, i took a peak at the org.apache.juli pom.xml and it doesnt appear to list any dependencies at all.

Any thoughts on how to resolve would be appreciated.

Thanks!

回答1:

Plugin dependencies are supplied in a different part of the POM:

<project>
    <dependencies>
         <!-- dependencies defined here don't get included for plugins -->
    ... 
    </dependencies>
    <build>
         <plugins>
              <plugin>
                .... jspc plugin section ....
                 <dependencies>
                      <dependency>  
                      <!-- Try adding slf4j here --->

Though it does sounds like their POM is invalid if it doesn't already specify slf4j.