i get this error while using jetty:run plugin on a ZK web project , i am using a zk archetype version 7.0.0.
[ERROR] failed org.mortbay.jetty.plugin.Jetty6PluginWebAppContext#a925d{/InTouchF,G:\workspace\InTouchF\src\main\webapp}
java.lang.NoClassDefFoundError
at org.mortbay.jetty.plus.webapp.EnvConfiguration.class$(EnvConfiguration.java:163)
this is my jetty configuration :
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Try adding this to your dependencies :
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-plus</artifactId>
<version>6.1.10</version>
</dependency>
i resolved the problem by using the version 7.0.0pre2 of jetty-maven-plugin and jsp-2.1 as follow :
<properties>
<jetty.version>7.0.0pre2</jetty.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>${jetty.version}</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>${jetty.version}</version>
........
Related
So I have an application that uses both, Java and Kotlin sourcefiles (all placed in the /src/main/kotlin directory because we eventually want to migrate to kotlin anyway) and that generates an hibernate metamodel.
So our maven compile plugins look like this:
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--COMPILATION-->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>kapt</id>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/kotlin</sourceDir>
</sourceDirs>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</execution>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
<compilerPlugins>
<plugin>all-open</plugin>
<plugin>jpa</plugin>
<plugin>spring</plugin>
<plugin>no-arg</plugin>
</compilerPlugins>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<pluginOptions>
<!-- Each annotation is placed on its own line -->
<option>all-open:annotation=javax.ejb.Stateless</option>
<option>no-arg:annotation=javax.ejb.Stateless</option>
<option>all-open:annotation=javax.ws.rs.ext.Provider</option>
<option>no-arg:annotation=javax.ws.rs.ext.Provider</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<!-- Check https://kotlinlang.org/docs/reference/using-maven.html#compiling-kotlin-and-java-sources -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals> <goal>compile</goal> </goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals> <goal>testCompile</goal> </goals>
</execution>
</executions>
</plugin>
<!--END COMPILATION-->
<!-- ... -->
</plugins>
</build>
this results in
[WARNING] Duplicate source root: /home/cypherk/code/myapp/target/generated-sources/kapt/compile
[WARNING] Duplicate source root: /home/cypherk/code/myapp/target/generated-sources/kaptKotlin/compile
which I have no idea why but may be related.
If I do not declare a dependency to
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</dependency>
under <dependencies>, that's alright, everything gets generated the way it's supposed to get generated in /target/generated-sources/kapt/compile/. (/target/generated-sources-kaptKotlin/compile gets generated but remains empty).
However, if I do declare the dependency under <dependencies>, the java (but not kotlin) entities will get generated a second time in /target/generated-sources/annotations/, which will trigger a compilation error because all Java-based generated classes have a duplicate class in the kapt folder.
I'm no expert on Maven, I just use it because that's what we are supposed to use for the project. As such, I find simply declaring a dependency having such an effect exceedingly unintuitive.
Could anybody explain to me why this is happening?
I don't know why, but when you change the compile execution to:
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
It should work. Same with test-compile.
I am trying to reference a Java class from a Kotlin file, but the problem is that I cannot reference the package containing the Java sources.
What I am trying:
fun main.dmla.java.parser.DMLAParser.parseDmla(source: Source): Any {
val lexer = DMLALexer(CharStreams.fromString(source.characters.toString()))
val parser = DMLAParser(CommonTokenStream(lexer))
val walker = DmlaWalker()
return walker.visit(parser.model())
}
I cannot reference the main.dmla.java package for some reason, therefore I cannot reach the DMLAParser class.
The Maven pom.xml looks like this:
<parent>
<groupId>DMLAGraalVM</groupId>
<artifactId>DMLA-parent</artifactId>
<version>0.0.1</version>
</parent>
<artifactId>language</artifactId>
<properties>
<java.version>1.8</java.version>
<kotlin.version>1.3.21</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-dsl-processor</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-tck</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/dmla/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/dmla/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>dmla</finalName>
<artifactSet>
<excludes>
<exclude>org.graalvm.truffle:truffle-api</exclude>
<exclude>org.graalvm.truffle:truffle-dsl-processor</exclude>
<exclude>org.graalvm.truffle:truffle-tck</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
What am I doing wrong?
I have added a custom PMD rule using official documentation (http://pmd.sourceforge.net/pmd-5.1.0/howtowritearule.html)
Rule:
package com.comp.www.lty.awards.service.pmd;
import net.sourceforge.pmd.lang.ast.*;
import net.sourceforge.pmd.lang.java.ast.*;
import net.sourceforge.pmd.lang.java.rule.*;
public class WhileLoopsMustUseBracesRule extends AbstractJavaRule {
public Object visit(ASTWhileStatement node, Object data) {
Node firstStmt = node.jjtGetChild(1);
if (!hasBlockAsFirstChild(firstStmt)) {
addViolation(data, node);
}
return super.visit(node,data);
}
private boolean hasBlockAsFirstChild(Node node) {
return (node.jjtGetNumChildren() != 0 && (node.jjtGetChild(0) instanceof ASTBlock));
}
}
This is my ruleset xml file:
<?xml version="1.0"?>
<ruleset name="My custom rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>While loop desc</description>
<rule name="WhileLoopsMustUseBracesRule"
message="Avoid using 'while' statements without curly braces"
class="com.comp.www.lty.awards.service.pmd.WhileLoopsMustUseBracesRule">
<description>
Avoid using 'while' statements without using curly braces
</description>
<priority>3</priority>
<example>
<![CDATA[
public void doSomething() {
while (true)
x++;
}
]]>
</example>
</rule>
</ruleset>
I am using mvn to run these pmd rules. Works fine when I try to use existing rules from pmd jar, but whenever I try to use my above custom rule, I am getting ClassNotFoundException.
Stacktrace:
java.lang.ClassNotFoundException: com.comp.www.lty.awards.service.pmd.WhileLoopsMustUseBracesRule
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at net.sourceforge.pmd.RuleSetFactory.parseSingleRuleNode(RuleSetFactory.java:377)
at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:291)
at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.java:242)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:176)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:171)
at net.sourceforge.pmd.RuleSetFactory.parseRuleSetReferenceNode(RuleSetFactory.java:331)
at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:289)
at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.java:242)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:176)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:171)
at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:135)
at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:119)
at net.sourceforge.pmd.RulesetsFactoryUtils.getRuleSets(RulesetsFactoryUtils.java:31)
at net.sourceforge.pmd.processor.AbstractPMDProcessor.createRuleSets(AbstractPMDProcessor.java:54)
at net.sourceforge.pmd.processor.MultiThreadProcessor.processFiles(MultiThreadProcessor.java:38)
at net.sourceforge.pmd.PMD.processFiles(PMD.java:352)
at org.apache.maven.plugin.pmd.PmdReport.executePmd(PmdReport.java:377)
at org.apache.maven.plugin.pmd.PmdReport.executePmdWithClassloader(PmdReport.java:280)
at org.apache.maven.plugin.pmd.PmdReport.canGenerateReport(PmdReport.java:254)
at org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:119)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:365)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Although not an ideal solution, but even I spent time to include this custom rule class file in the pmd jar (Custom Java PMD rule: Can't find the class CustomRule), but that didn't help either.
pom.xml:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
1.4.0.RELEASE
lty-awards-service
com.comp.www
war
lty-awards-service
Spring Boot Service Sample
1.0-SNAPSHOT
http://maven.apache.org
1.8
<findbugs-maven-plugin.version>3.0.3</findbugs-maven-plugin.version>
<findbugs.include.filter.location>buildtools/findbugs/include.xml</findbugs.include.filter.location>
<findbugs.exclude.filter.location>buildtools/findbugs/exclude.xml</findbugs.exclude.filter.location>
<maven-pmd-plugin.version>3.5</maven-pmd-plugin.version>
<pmd.version>5.3.2</pmd.version>
<pmdRule.version>5.1.0</pmdRule.version>
<pmd.ruleset.location>buildtools/pmd-rules/ltyawardsservicepmd.xml</pmd.ruleset.location>
<pmd.skip>false</pmd.skip>
<pmd.typeResolution>true</pmd.typeResolution>
<!-- spring boot -->
<debug.port>5000</debug.port>
<run.jvmArguments>-Dspring.profiles.active=dev -Dapplication.home=. -Dapplication.name=${project.name}
-Dapplication.environment=dev -Dproject.name=${project.name} -Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${debug.port}
</run.jvmArguments>
<error-inspector.version>0.1.9</error-inspector.version>
<platform-diagnostics.version>0.0.43</platform-diagnostics.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>${pmdRule.version}</version>
<scope>system</scope>
<systemPath>/Users/babu/.m2/repository/net/sourceforge/pmd/pmd/5.1.0/test.jar</systemPath>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.comp.prime.errorcatalog</groupId>
<artifactId>error-inspector</artifactId>
<version>${error-inspector.version}</version>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/error-inspect</outputDirectory>
<destFileName>inspect.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>com.comp.www.platform</groupId>
<artifactId>platform-diagnostics-main</artifactId>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/error-inspect/lib</outputDirectory>
<destFileName>platform-diagnostics-main.jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<message>.*** ERROR: Detected Maven version ${maven.version}, We need Maven 3.0.3 or
higher ***.
</message>
<version>[3.0.3,)</version>
</requireMavenVersion>
<requireJavaVersion>
<message>.*** ERROR: Detected JDK version ${java.version}, We need JDK
${project.jdk.version} or higher ***.
</message>
<version>${project.jdk.version}</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
<execution>
<id>enforce-dont-exist</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireFilesDontExist>
<files>
<file>${project.basedir}/src/main/scala</file>
</files>
</requireFilesDontExist>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${project.jdk.version}</source>
<target>${project.jdk.version}</target>
<encoding>UTF-8</encoding>
</configuration>
<version>3.3</version>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin.version}</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaCompatVersion>${scala.major.minor.version}</scalaCompatVersion>
<jvmArgs>
<jvmArg>-Xms512m</jvmArg>
<jvmArg>-Xmx2048m</jvmArg>
</jvmArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>${pmd.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${pmd.version}</version>
</dependency>
<dependency>
<groupId>WhileLoopsMustUseBracesRule</groupId>
<artifactId>pmd.ruleset</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>/Users/babu/Downloads/cache.jar</systemPath>
</dependency>
<dependency>
<groupId>com.comp.www.platform</groupId>
<artifactId>platform-build-tools</artifactId>
<version>${platform-build-tools.version}</version>
</dependency>
</dependencies>
<configuration>
<targetJdk>${project.jdk.version}</targetJdk>
<includeTests>true</includeTests>
<skip>${pmd.skip}</skip>
<sourceEncoding>${project.sourceEncoding}</sourceEncoding>
<rulesets>
<ruleset>${pmd.ruleset.location}</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<id>cpd-report</id>
<phase>test-compile</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
<goal>pmd</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!--<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>-->
Here test.jar is my jar bundled (i.e. pmd jar unbundled, added class file & ruleset and again bundled it as test.jar). Although this is not how I want to use the rule. But if there is a better way to use pmd jar as it is & add a mvn dependency for new rule that is the ideal solution I'm looking for. Thanks!
You need to add your custom rule jar to the classpath when PMD runs. You should bundle your custom PMD rule in its own Maven dependency, then you can include it in the PMD plugin classpath by adding a dependency to your plugin configuration like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.7</version>
<dependencies>
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>my-custom-pmd-rule</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
...
</plugin>
See this page for more information about plugin classloading. See how it says:
Please note that the plugin classloader does neither contain the dependencies of the current project nor its build output
Try changing your pom.xml file to the following. Notice I moved your test.jar dependency to the plugin dependencies so that it'll be loaded on the plugin's classpath. Note that you don't have to bundle your rules with PMD. You just need to package your rules in its own jar and include it in the plugin dependencies section.
<findbugs-maven-plugin.version>3.0.3</findbugs-maven-plugin.version>
<findbugs.include.filter.location>buildtools/findbugs/include.xml</findbugs.include.filter.location>
<findbugs.exclude.filter.location>buildtools/findbugs/exclude.xml</findbugs.exclude.filter.location>
<maven-pmd-plugin.version>3.5</maven-pmd-plugin.version>
<pmd.version>5.3.2</pmd.version>
<pmdRule.version>5.1.0</pmdRule.version>
<pmd.ruleset.location>buildtools/pmd-rules/ltyawardsservicepmd.xml</pmd.ruleset.location>
<pmd.skip>false</pmd.skip>
<pmd.typeResolution>true</pmd.typeResolution>
<!-- spring boot -->
<debug.port>5000</debug.port>
<run.jvmArguments>-Dspring.profiles.active=dev -Dapplication.home=. -Dapplication.name=${project.name}
-Dapplication.environment=dev -Dproject.name=${project.name} -Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${debug.port}
</run.jvmArguments>
<error-inspector.version>0.1.9</error-inspector.version>
<platform-diagnostics.version>0.0.43</platform-diagnostics.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.comp.prime.errorcatalog</groupId>
<artifactId>error-inspector</artifactId>
<version>${error-inspector.version}</version>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/error-inspect</outputDirectory>
<destFileName>inspect.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>com.comp.www.platform</groupId>
<artifactId>platform-diagnostics-main</artifactId>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/error-inspect/lib</outputDirectory>
<destFileName>platform-diagnostics-main.jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<message>.*** ERROR: Detected Maven version ${maven.version}, We need Maven 3.0.3 or
higher ***.
</message>
<version>[3.0.3,)</version>
</requireMavenVersion>
<requireJavaVersion>
<message>.*** ERROR: Detected JDK version ${java.version}, We need JDK
${project.jdk.version} or higher ***.
</message>
<version>${project.jdk.version}</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
<execution>
<id>enforce-dont-exist</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireFilesDontExist>
<files>
<file>${project.basedir}/src/main/scala</file>
</files>
</requireFilesDontExist>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${project.jdk.version}</source>
<target>${project.jdk.version}</target>
<encoding>UTF-8</encoding>
</configuration>
<version>3.3</version>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin.version}</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaCompatVersion>${scala.major.minor.version}</scalaCompatVersion>
<jvmArgs>
<jvmArg>-Xms512m</jvmArg>
<jvmArg>-Xmx2048m</jvmArg>
</jvmArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>${pmd.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${pmd.version}</version>
</dependency>
<dependency>
<groupId>WhileLoopsMustUseBracesRule</groupId>
<artifactId>pmd.ruleset</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope><systemPath>/Users/babu/Downloads/cache.jar</systemPath>
</dependency>
<dependency>
<groupId>com.comp.www.platform</groupId>
<artifactId>platform-build-tools</artifactId>
<version>${platform-build-tools.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>${pmdRule.version}</version>
<scope>system</scope>
<systemPath>/Users/babu/.m2/repository/net/sourceforge/pmd/pmd/5.1.0/test.jar</systemPath>
</dependency>
</dependencies>
<configuration>
<targetJdk>${project.jdk.version}</targetJdk>
<includeTests>true</includeTests>
<skip>${pmd.skip}</skip>
<sourceEncoding>${project.sourceEncoding}</sourceEncoding>
<rulesets>
<ruleset>${pmd.ruleset.location}</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<id>cpd-report</id>
<phase>test-compile</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
<goal>pmd</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!--<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>-->
I am trying to use moskito-inspect tool in embedded mode, here is my pom.xml
<properties>
<moskito.version>2.5.5</moskito.version>
<moskito-central.version>1.1.0</moskito-central.version>
</properties>
...
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
<groupId>net.anotheria</groupId>
<artifactId>moskito-aop</artifactId>
</aspectLibrary>
</aspectLibraries>
<complianceLevel>1.7</complianceLevel>
<source>1.7</source>
<target>1.7</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<artifactItems><artifactItem>
<groupId>net.anotheria</groupId>
<artifactId>moskito-webui</artifactId>
<version>${moskito.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/tmp</outputDirectory>
<includes>moskito/**,**/*.jsp</includes>
</artifactItem></artifactItems>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}/tmp</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
...
<dependencies>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-core</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-aop</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-web</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-webui</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-inspect-embedded</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-inspect-jersey</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>org.moskito</groupId>
<artifactId>moskito-central-embedded-connector</artifactId>
<version>${moskito-central.version}</version>
</dependency>
<dependency>
<groupId>org.moskito</groupId>
<artifactId>moskito-central-storages</artifactId>
<version>${moskito-central.version}</version>
</dependency>
</dependencies>
When I am running maven clean install I am getting war-file, which has the next inner structure:
When I deploy this war-file in tomcat, I can access my application by this URL:
http://localhost:8080/ada
(where ada - application name)
so I have tried to access moskito-inspect webui by this URLs:
http://localhost:8080/ada/moskito
http://localhost:8080/moskito
http://localhost:8080/ada/mui
http://localhost:8080/mui
However, tomcat response for all these links in 404 [Not found].
What am I doing wrong, may be someone faced the same problem?
Thanks in advance
I have figure out that you should add to your web.xml Moskito filters configuration - like in this article.
But author also said in this article that
With version 2.4.0 and servlet spec 3.0 no changes of the web.xml are
needed.
That's why I ignored that guide - very misleading advice!
No matter how much I do mvn clean install even with -U this dependency (along with some other) is not being coped into the target\app-1.0-SNAPSHOT\WEB-INF\lib folder:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
Not sure why this happens now, when in the pom.xml there is the <packaging>war</packaging>
build
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.version}</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Copies static web files from src/main/webapp to target/${webappDirectory} -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<!-- the exploded goal gets executed during compile phase -->
<phase>compile</phase>
<goals>
<goal>exploded</goal>
<goal>war</goal>
</goals>
</execution>
</executions>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${project.artifactId}</warName>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>