maven sonar problem - maven-2

I want to use sonar for analysis but i can't get any data in localhost:9000
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>KIS</artifactId>
<groupId>KIS</groupId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<tasks>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<ant antfile="${basedir}/build.xml">
<target name="maven-compile"/>
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
output when running sonar: jar file is empty
[INFO] Executed tasks
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory J:\ostalo_6i\KIS deploy\ANT\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [jar:jar {execution: default-jar}]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: J:\ostalo_6i\KIS deploy\ANT\target\KIS-1.0.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing J:\ostalo_6i\KIS deploy\ANT\target\KIS-1.0.jar to C:\Documents and Settings\MitjaG\.m2\repository\KIS\KIS\1.0\KIS-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - KIS:KIS:jar:1.0
[INFO] task-segment: [sonar:sonar] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [sonar:sonar {execution: default-cli}]
[INFO] Sonar host: http://localhost:9000
[INFO] Sonar version: 2.1.2
[INFO] [sonar-core:internal {execution: default-internal}]
[INFO] Database dialect class org.sonar.api.database.dialect.Oracle
[INFO] ------------- Analyzing Unnamed - KIS:KIS:jar:1.0
[INFO] Selected quality profile : KIS, language=java
[INFO] Configure maven plugins...
[INFO] Sensor SquidSensor...
[INFO] Sensor SquidSensor done: 16 ms
[INFO] Sensor JavaSourceImporter...
[INFO] Sensor JavaSourceImporter done: 0 ms
[INFO] Sensor AsynchronousMeasuresSensor...
[INFO] Sensor AsynchronousMeasuresSensor done: 15 ms
[INFO] Sensor SurefireSensor...
[INFO] parsing J:\ostalo_6i\KIS deploy\ANT\target\surefire-reports
[INFO] Sensor SurefireSensor done: 47 ms
[INFO] Sensor ProfileSensor...
[INFO] Sensor ProfileSensor done: 16 ms
[INFO] Sensor ProjectLinksSensor...
[INFO] Sensor ProjectLinksSensor done: 0 ms
[INFO] Sensor VersionEventsSensor...
[INFO] Sensor VersionEventsSensor done: 31 ms
[INFO] Sensor CpdSensor...
[INFO] Sensor CpdSensor done: 0 ms
[INFO] Sensor Maven dependencies...
[INFO] Sensor Maven dependencies done: 16 ms
[INFO] Execute decorators...
[INFO] ANALYSIS SUCCESSFUL, you can browse http://localhost:9000
[INFO] Database optimization...
[INFO] Database optimization done: 172 ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 minutes 16 seconds
[INFO] Finished at: Fri Jun 11 08:28:26 CEST 2010
[INFO] Final Memory: 24M/43M
[INFO] ------------------------------------------------------------------------
any idea why, i successfully compile with maven ant plugin java project.

Maven doesn't compile anything and is building an empty jar here (No sources to compile, No tests to run, JAR will be empty - no content was marked for inclusion!) so, while Sonar is processing it, there is actually nothing to analyze.
Actually, I don't think that wrapping an Ant build into a Maven project is enough for Sonar, Sonar won't discover your source and output directory. According to Non-Maven projects (sonar light mode), you'll have to declare the source and output directory in a minimal pom.xml (and build your project prior to running Sonar).

http://jira.codehaus.org/browse/SONAR-178
This will help u..

Are you sure you started the sonar server? You might check if it is still running.
I also see little correlation between the POM and the question and the runtimes in the output suggest that you have either an exceptionally fast computer or it is not doing anything.
I would first make sure you have some classes and unit tests which compile/test/install normally, before trying to get something into/from Sonar.

Related

activejdbc migrator force to create `schema_version` table if it exits

Today I am going to setup another development env by dumping the demo data from one server and restoring to another one. Also I copy the code base to the development server. When I run mvn validate which will invoke migration, it outputs
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.ft:xjobs-server >-----------------------
[INFO] Building API server for xJobs service 0.2-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- db-migrator-maven-plugin:2.5-j8:migrate (dev_migrations) # xjobs-server ---
[INFO] Sourcing database configuration from file: /srv/apps/xjobs-server/src/main/resources/database.properties
[INFO] Environment: development
[INFO] Migrating jdbc:postgresql://localhost:5432/xjobs_deve using migrations at /srv/apps/xjobs-server/src/migrations/
[INFO] Creating schema version table for POSTGRESQL DB
[INFO] Executing: create table schema_version (version varchar(32) not null unique, applied_on timestamp not null, duration int not null)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.864 s
[INFO] Finished at: 2021-07-26T00:42:50+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.javalite:db-migrator-maven-plugin:2.5-j8:migrate (dev_migrations) on project xjobs-server: Execution dev_migrations of goal org.javalite:db-migrator-maven-plugin:2.5-j8:migrate failed: org.javalite.activejdbc.DBException: org.postgresql.util.PSQLException: ERROR: relation "schema_version" already exists, query: create table schema_version (version varchar(32) not null unique, applied_on timestamp not null, duration int not null) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
And the javalite version
<javalite.version>2.5-j8</javalite.version>
I have checked schema_version table, it does exist, and it contains all migration sequence numbers. I don't understand why the migrator still needs to create the table again.
-- UPDATE
some config in pom.xml
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<javalite.version>2.5-j8</javalite.version>
<jetty.version>9.4.24.v20191120</jetty.version>
<environments>development</environments>
</properties>
...
<plugin>
<groupId>org.javalite</groupId>
<artifactId>db-migrator-maven-plugin</artifactId>
<version>${javalite.version}</version>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.18</version>
</dependency>
</dependencies>
<configuration>
<configFile>${project.basedir}/src/main/resources/database.properties</configFile>
<environments>${environments}</environments>
</configuration>
<executions>
<execution>
<id>dev_migrations</id>
<phase>validate</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
</executions>
</plugin>
I created an example to test exactly the scenario you have. Fortunately, the JavaLite Migrator is working as expected.
Here is the link to the example: https://github.com/javalite/javalite-examples/tree/master/postgresql-example
No matter how many times you run the migrator, it works as expected every time:
[INFO] --- db-migrator-maven-plugin:2.5-j8:migrate (dev_migrations) # postgresql-example ---
[INFO] Sourcing database configuration from file: /home/igor/projects/javalite/javalite-examples/postgresql-example/src/main/resources/database.properties
[INFO] Environment: development.test
[INFO] Migrating jdbc:postgresql://localhost/postgres using migrations at /home/igor/projects/javalite/javalite-examples/postgresql-example/src/migrations/
[INFO] Trying migrations at: /home/igor/projects/javalite/javalite-examples/postgresql-example/src/migrations
[INFO] No new migrations are found
[INFO] Environment: development
[INFO] Migrating jdbc:postgresql://localhost/postgres using migrations at /home/igor/projects/javalite/javalite-examples/postgresql-example/src/migrations/
[INFO] Trying migrations at: /home/igor/projects/javalite/javalite-examples/postgresql-example/src/migrations
[INFO] No new migrations are found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.460 s
[INFO] Finished at: 2021-07-26T12:39:06-05:00
So, why are you having an issue? It is possible that you have multiple schemas in the database, and improperly configured visibility, such that under one condition, you see the schema_version table and under another, you do not. There have been reported similar cases before for Oracle, and the fix was related to eliminating leaking table visibility under different users. This is where you need to focus to fix the issue.

exec-maven-plugin goal is not started during build

Hallo,
I try to run a main method during my maven build process. Hence, I added the exec-maven-plugin and the following snippet to my pom.xml
<plugin>
<!-- http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>compile-reports</id>
<phase>compile</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>at.xyz.dls.util.JasperReportCompiler</mainClass>
</configuration>
</execution>
</executions>
</plugin>
The main class exists and is also executed, when I call it out of the command line:
mvn exec:java -Dexec.mainClass="at.xyz.dls.util.JasperReportCompiler"
I also tried to create a empty new project to test, if an other depencency in the pom causes the problem, but had no success. In the maven settings.xml in the ~/.m2 folder, there is only the entry for an mirror, but no profiles, or anything else, which could cause a problem.
It just does not start it. When I deleted all my artifacts in my repo under org.codehouse, it did not download the exec-maven-plugin. Only when I did the command line call.
Any hints? Thanks in advance!
edit: I forgot to mention I have used "mvn clean install". so it should have passed the compile phase...
edit:
up to now, I could not solve the problem. Thanks for your answers so far! I will try to give all information once again, and hope, one of you guys, find's the fishy part. I have no idea anymore....
What I did:
Delete the folder org/codehouse/mojo in my maven proxy. just to show, when the dependencies are loaded.
show some java and maven version information
build the project with: mvn -clean install (which should pass the test phase to execute my main method)
execute the main method to show, the exec-maven-plugin is loaded only afterwards and works
As far as I understood, calling "mvn clean install" should pass the test phase (the tests are executed...), hence the exec-maven-plugin should be called, which should execute the main method. Am I right?
D:\Eclipse-3.6.1-JSF\ws\exec-test>java -version java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)
D:\Eclipse-3.6.1-JSF\ws\exec-test>mvn -version Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200) Java version: 1.6.0_21 Java home: C:\Programme\Java\jdk1.6.0_21\jre Default locale: de_AT, platform encoding: Cp1252 OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows" D:\Eclipse-3.6.1-JSF\ws\exec-test>mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - at.test:exec-test:jar:0.0.1-SNAPSHOT
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory D:\Eclipse-3.6.1-JSF\ws\exec-test\target
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to D:\Eclipse-3.6.1-JSF\ws\exec-test\target\classes
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 1 source file to D:\Eclipse-3.6.1-JSF\ws\exec-test\target\test-classes
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: D:\Eclipse-3.6.1-JSF\ws\exec-test\target\surefire-reports
T E S T S
Running at.test.ExecTestTest JUnit Test call: end of junit test.
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: D:\Eclipse-3.6.1-JSF\ws\exec-test\target\exec-test.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing D:\Eclipse-3.6.1-JSF\ws\exec-test\target\exec-test.jar to D:\maven.m2\repository\at\test\exec-test\0.0.1-SNAPSHOT\exec-test-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Thu Mar 10 12:07:08 CET 2011
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------ D:\Eclipse-3.6.1-JSF\ws\exec-test>mvn exec:java -Dexec.mainClass="at.test.ExecTest"
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'. Downloading: http://pced06.vab.sozvers.at:8080/artifactory/repo/org/codehaus/mojo/exec-maven-plugin/1.2/exec-maven-plugin-1.2.pom 6K downloaded (exec-maven-plugin-1.2.pom) Downloading: http://pced06.vab.sozvers.at:8080/artifactory/repo/org/codehaus/mojo/exec-maven-plugin/1.2/exec-maven-plugin-1.2.jar 35K downloaded (exec-maven-plugin-1.2.jar)
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - at.test:exec-test:jar:0.0.1-SNAPSHOT
[INFO] task-segment: [exec:java]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing exec:java [WARNING] Removing: java from forked lifecycle, to prevent recursive invocation.
[INFO] No goals needed for project - skipping
[INFO] [exec:java {execution: default-cli}]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Thu Mar 10 12:07:20 CET 2011
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
D:\Eclipse-3.6.1-JSF\ws\exec-test>
now again the modified pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>at.test</groupId>
<artifactId>exec-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>exec-test</finalName>
<defaultGoal>install</defaultGoal>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<!-- http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>compile-reports</id>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>at.test.ExecTest</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
</dependencies>
The main class:
package at.test;
public class ExecTest {
/**
* #param args
*/
public static void main(String[] args) {
System.out.println("##################################");
}
}
And the JUnit Test Class:
package at.test;
import org.junit.Test;
import at.test.ExecTest;
public class ExecTestTest {
#Test
public void testTestTest() {
System.err.println("JUnit Test call:");
ExecTest.main(null);
System.err.println("end of junit test.");
}
}
Finally I found the problem. Was quite a stupid mistake:
In the pom.xml I used the <pluginManagement> around the <plugins> node.
Maven did not complain, but ignored all plugin configurations.
Maybe someone can use this information...
Thanks for your help!
Compile phase may not be appropriate, have you tried
<phase>test</phase>
If you set it on phase compile then you do have to tell maven that is needs to run compile when running. You don't pass any phase with your maven command. You should have mvn compile exec:java ... or higher (test, install, ...).
This is my usage of the exec maven plugin (with mvn clean package):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.xxx.LanguageGenerator</mainClass>
<arguments>
<argument>${project.build.outputDirectory}/build/PMLanguage.xls</argument>
<argument>PM${project.version}</argument>
<argument>${project.build.outputDirectory}/com/laco/projectmaster/props/resources</argument>
<argument>Created during maven build (POM Version:
${project.version})</argument>
</arguments>
</configuration>
</plugin>

maven-jetty-plugin question

I need to start jetty before module tests. Example:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jetty-test</groupId>
<artifactId>jetty-test</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>Hello world!</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<executions>
<execution>
<id>start-webapp-for-module-tests</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>stop-webapp-for-module-tests</id>
<phase>prepare-package</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<daemon>true</daemon>
<stopPort>8181</stopPort>
<stopKey>stop-webapp</stopKey>
</configuration>
</plugin>
</plugins>
</build>
</project>
Everything works, but maven-antrun-plugin (or any other plugin before test-compile phase) begins to run two times. I tried to use run-war, run-exploaded or deploy-war goals. Result is the same.
Maven output:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - jetty-test:jetty-test:war:1.0
[INFO] task-segment: [deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/chardex/projects/untitled/jetty-test/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/chardex/projects/untitled/jetty-test/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [antrun:run {execution: test-compile}]
[INFO] Executing tasks
main:
**[echo] Hello world!**
[INFO] Executed tasks
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] Preparing jetty:run
[WARNING] Removing: run from forked lifecycle, to prevent recursive invocation.
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/chardex/projects/untitled/jetty-test/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/chardex/projects/untitled/jetty-test/src/test/resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [antrun:run {execution: test-compile}]
[INFO] Executing tasks
main:
**[echo] Hello world!**
[INFO] Executed tasks
[INFO] [jetty:run {execution: start-webapp-for-module-tests}]
[INFO] Configuring Jetty for project: Unnamed - jetty-test:jetty-test:war:1.0
[INFO] Webapp source directory = /home/chardex/projects/untitled/jetty-test/src/main/webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes directory /home/chardex/projects/untitled/jetty-test/target/classes does not exist
2010-12-24 16:50:17.254:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
[INFO] Context path = /jetty-test
[INFO] Tmp directory = determined at runtime
[INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = /home/chardex/projects/untitled/jetty-test/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = /home/chardex/projects/untitled/jetty-test/src/main/webapp
[INFO] Starting jetty 6.1.26 ...
2010-12-24 16:50:17.316:INFO::jetty-6.1.26
2010-12-24 16:50:17.416:INFO::No Transaction manager found - if your webapp requires one, please configure one.
[INFO] Started Jetty Server
[INFO] [jetty:stop {execution: stop-webapp-for-module-tests}]
2010-12-24 16:50:17.603:INFO::Started SelectChannelConnector#0.0.0.0:8080
[INFO] Stopping server 0
2010-12-24 16:50:17.637:INFO::Stopped SelectChannelConnector#0.0.0.0:8080
[INFO] [war:war {execution: default-war}]
[INFO] Packaging webapp
[INFO] Assembling webapp[jetty-test] in [/home/chardex/projects/untitled/jetty-test/target/jetty-test-1.0]
[INFO] Processing war project
[INFO] Copying webapp resources[/home/chardex/projects/untitled/jetty-test/src/main/webapp]
[INFO] Webapp assembled in[25 msecs]
[INFO] Building war: /home/chardex/projects/untitled/jetty-test/target/jetty-test-1.0.war
[INFO] [install:install {execution: default-install}]
...
Where I'm wrong?
Thanks.
According to the documentation, for mvn jetty:run,
This goal is used in-situ on a Maven
project without first requiring that
the project is assembled into a war,
saving time during the development
cycle. The plugin forks a parallel
lifecycle to ensure that the "compile"
phase has been completed before
invoking Jetty. This means that you do
not need to explicity execute a "mvn
compile" first. It also means that a
"mvn clean jetty:run" will ensure that
a full fresh compile is done before
invoking Jetty.
This explains the behavior.
There should be a separate goal which does the same thing but does not fork the lifecycle. It's impossible not to execute the compile phase and all other phases when the plugin is run as a step in the build lifecycle, so everything is run twice. Bug created: http://jira.codehaus.org/browse/JETTY-1365. Bug moved as a duplicate to https://jira.codehaus.org/browse/JETTY-1405. They said they couldn't reproduce the problem and need a specific test case. Not sure when I can get to this, but if someone has a simple war project using the maven-jetty-plugin which demonstrates the issue, can they please upload it to the JIRA ticket.

emma not generating reports but cobertura does?

basic reason to put the comparison question between these 2 is I am able to generate the reports in site directory(for cobertura) after putting the following plug in information in build section of my pom. But same would not happening with emma. I checked documentation in codehause mojo its almost same for both. My configuration is :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>emma</goal>
</goals>
</execution>
</executions>
</plugin>
but it dont generate reports as expected in site directory but I can see coverage.em generated and classes instrumented every time. am I missing any configuration ?
I can't reproduce your problem. I copied and pasted your configuration snippet into a random pom.xml and running any phase posterior to process-classes triggers emma:emma and the coverage report is generated as expected:
$ mvn clean process-classes
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Project
[INFO] task-segment: [clean, process-classes]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory /home/pascal/tmp/test-project/target
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to /home/pascal/tmp/test-project/target/classes
[INFO] Preparing emma:emma
...
EMMA: runtime coverage data merged into [/home/pascal/tmp/test-project/coverage.ec] {in 93 ms}
[INFO] [emma:emma {execution: default}]
processing input files ...
2 file(s) read and merged in 3 ms
writing [xml] report to [/home/pascal/tmp/test-project/target/site/emma/coverage.xml] ...
writing [html] report to [/home/pascal/tmp/test-project/target/site/emma/index.html] ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
Do you have unit tests in your project? Is the coverage.em file non empty? What happens if you run emma:emma on the command line? Does running mvn with the -X option give you any hint? Can you post some traces that would be helpful?
As a side note, I wouldn't run emma:emma as part of the regular build personally. I would either run the emma:emma goal from the command line or configure the plugin and the reporting section as suggested in the Usage page. But that's another story and doesn't answer the question.
this is really strange: corrected plugin entry is : see the output directory
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<inherited>true</inherited>
<executions>
<execution>
<id>emma</id>
<phase>process-classes</phase>
<goals>
<goal>emma</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</plugin>
emma even does not accept ${project.build.directory}/emma.
conclusion : emma not generated reports when you add any sub-directory to ${project.build.directory} e.g. ${project.build.directory}/emma-reports.

Maven webstart plugin not finding dependencies

Hoping someone can help me with this strange one. I’m trying to run the webstart plugin but it doesn’t seem to be able to find the main class within the jar being produce. The pom is as simple as it can get, and the class Test exists, and is being compiled and placed in the jar. Can someone please point me in the right direction?
<project>
<modelVersion>4.0.0</modelVersion>
<name>Desktop Components</name>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo.webstart</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>jnlp-download-servlet</goal>
</goals>
</execution>
</executions>
<configuration>
<jnlpFiles>
<jnlpFile>
<jarResources>
<jarResource>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<mainClass>Test</mainClass>
</jarResource>
</jarResources>
</jnlpFile>
</jnlpFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
Here is the Maven trace:
C:\TEMP\webstart-test>mvn webstart:jnlp –e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Desktop Components
[INFO] task-segment: [webstart:jnlp] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing webstart:jnlp
[INFO] ------------------------------------------------------------------------
[INFO] Building Desktop Components
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\TEMP\webstart-test\src\main\resources
[INFO] [webstart:jnlp-download-servlet {execution: default}]
[INFO] No templateFilename found for launch2.jnlp. Will use the default template.
[INFO] No resources found in C:\TEMP\webstart-test\src\main\jnlp\resources
Downloading: http://repo1.maven.org/maven2/com/test/test/1.0/test-1.0.pom
[INFO] Unable to find resource 'com.test:test:pom:1.0' in repository central (http://repo1.maven.org/maven2)
No template specified Using default one.
***** Webstart JAR URL: jar:file:/C:/apache-maven-2.2.1/repo/org/codehaus/mojo/webstart/webstart-maven-plugin/1.0-alpha-2/webstart-maven-plugin-1.0-alpha-2.jar!
/
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\TEMP\webstart-test\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: C:\TEMP\webstart-test\target\test-1.0.jar
[INFO] [webstart:jnlp {execution: default-cli}]
[INFO] No resources found in C:\TEMP\webstart-test\src\main\jnlp\resources
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failure to run the plugin:
[INFO] ------------------------------------------------------------------------
[INFO] Trace
The trace follows
org.apache.maven.lifecycle.LifecycleExecutionException: Failure to run the plugin:
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
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)
Now the Caused by trace
Caused by: org.apache.maven.plugin.MojoExecutionException: Failure to run the plugin:
at org.codehaus.mojo.webstart.AbstractJnlpMojo.execute(AbstractJnlpMojo.java:289)
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 org.codehaus.mojo.webstart.AbstractJnlpMojo.execute(AbstractJnlpMojo.java:214)
... 19 more
And the final Maven trace
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Fri Nov 13 11:16:54 GMT 2009
[INFO] Final Memory: 12M/22M
[INFO] ------------------------------------------------------------------------
This is problem with mainClass for JNLP
You need something like this
<configuration>
<jnlp>
<mainClass>com.test.Test</mainClass>
</jnlp>
<configuration>
I'm sure this is no longer a problem for you, as the question is a year old. However, for the sake of completeness...
I've edited the question to make it readable. This shows us the error is on line 214 of AbstractJnlpMojo. Looking at the latest version source code on line 214 (the root cause above), we can see this is because you have not specified the main method for the JNLP file.
The JNLP doesn't need the main method class just specified in the jar resources. It also needs it in the JNLP tag, like this.
<configuration>
<jnlp>
<mainClass>com.test.Test</mainClass>
</jnlp>
</configuration>
As the code has changed, if you did this today, you would get the following Exception (a bit more readable):
org.apache.maven.plugin.MojoExecutionException:
didn't find artifact with main class: null. Did you specify it?
For solving this issue:
didn't find artifact with main class: null. Did you specify it?
I had to create a multi-module maven project as follows:
base-project
main-app
webstart
Then inside webstart's pom file I included main-app as a dependency. Finally, run mvn webstart:jnlp from within webstart directory.
I don't think its your dependencies that are not found, but rather some files in C:\TEMP\webstart-test\src\main\jnlp\resources, such as the Velocity template for your jnlp file maybe?