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

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.

Related

Trying to run a pack of selenium tests written in java using Jenkins

After reading nearly all the posts that it suggests under "Questions with similar titles" (I will continue reading after sending this post) and reading
centripetal.ca/blog/2011/02/07/getting-started-with-selenium-and-jenkins/
oliverpolden.com/content/setting-automated-selenium-testing-jenkinshudson
and some other posts (I note these two because I think they may be useful to someone) I haven't found an answer to what I need. And now I get to that:
I'm working in a company that uses Jenkins for CI and maven. They have three types of tests ran for the sotware: junit, cactus and selenium. Jenkins has a job to run junit tests. Now they've decided to run the other two types of tests (Cactus and Selenium) using Jenkins. And that's my task. Cactus would be another question I'll ask later (have been banging my head with that one for too long right now). The Selenium tests are written in java and there's a java file that has all the tests as it follows:
package com.mycompany.test.dailySanity;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
#RunWith(Suite.class)
#Suite.SuiteClasses({
Test1.class,
Test2.class,
Test3.class,
})
public class AllTests {
/**
* This is just a place holder.
* Add All your TestClass one to the list above.
* NOTE, the TestClasses should be "," separated
*/
}
All the information I've found talks about an htmlsuite, but nothing about if the tests are in java (no, exporting them to HTML is not an option). I've tried
export DISPLAY=":99" && java -jar /path/to/selenium-server.jar
-browserSessionReuse -htmlSuite *firefox http://localhost
/path/to/my/testsfile/AllTests.java
/path/to/my/logfile/SeleniumLog.html
as an "Execute Shell" in "Build" step in Jenkins job, but it just stays trying something.
Console output
09:29:48.508 INFO - Java: Sun Microsystems Inc. 14.2-b01
09:29:48.518 INFO - OS: Linux 2.6.18.8-xenU amd64
09:29:48.654 INFO - v2.4.0, with Core v2.4.0. Built from revision 13337
09:29:49.263 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
09:29:49.264 INFO - Version Jetty/5.1.x
09:29:49.269 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
09:29:49.271 INFO - Started HttpContext[/selenium-server,/selenium-server]
09:29:49.271 INFO - Started HttpContext[/,/]
09:29:49.337 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#7a187814
09:29:49.337 INFO - Started HttpContext[/wd,/wd]
09:29:49.343 INFO - Started SocketListener on 0.0.0.0:4444
09:29:49.343 INFO - Started org.openqa.jetty.jetty.Server#67ad77a7
10:51:00.038 INFO - Shutting down...
10:51:00.040 INFO - Stopping Acceptor ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=4444]
I assume it does nothing else (waited for 2 hours before aboting it) beacause it's a java file and it requires an html file (-htmlsuite is a clue).
To sum up: I need a way to run Selenium tests written in Java and packaged in a java suite on Jenkins.
EDITING
Ok, I'm not getting anywhere and running out of time. I'm adding more information just in case someone can give me a hand (not that I'm not thankful to Ross). Here goes my selenium_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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.company</groupId>
<artifactId>selenium-test</artifactId>
<version>0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium.client-drivers</groupId>
<artifactId>selenium-java-client-driver</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Skip the normal tests, we'll run them in the integration-test phase -->
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>/path/to/my/tests/AllTests.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I run
mvn -f selenium_pom.xml integration-test
I get the following output
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.kana.sem:selenium-test:jar:0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. # line 44, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building selenium-test 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # selenium-test ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /path/to/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # selenium-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) # selenium-test ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /path/to/resources/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # selenium-test ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) # selenium-test ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) # selenium-test ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO]
[INFO] --- selenium-maven-plugin:2.1:start-server (default) # selenium-test ---
Launching Selenium Server
Waiting for Selenium Server...
[WARNING] OS appears to be Unix and no DISPLAY environment variable has been detected. Browser maybe unable to function correctly. Consider using the selenium:xvfb goal to enable headless operation.
[INFO] User extensions: /localhome/kana/p4/dev/BOT/target/selenium/user-extensions.js
08:05:07,166 INFO [org.openqa.selenium.server.SeleniumServer] Java: IBM Corporation 2.3
08:05:07,173 INFO [org.openqa.selenium.server.SeleniumServer] OS: Linux 2.6.18.8-xenU x86
08:05:07,184 INFO [org.openqa.selenium.server.SeleniumServer] v2.9.0, with Core v2.9.0. Built from revision 14289
08:05:07,273 INFO [org.openqa.selenium.server.SeleniumServer] RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
08:05:07,277 INFO [org.openqa.jetty.http.HttpServer] Version Jetty/5.1.x
08:05:07,686 INFO [org.openqa.jetty.util.Container] Started org.openqa.jetty.jetty.servlet.ServletHandler#51fe51fe
08:05:07,687 INFO [org.openqa.jetty.util.Container] Started HttpContext[/wd,/wd]
08:05:07,687 INFO [org.openqa.jetty.util.Container] Started HttpContext[/,/]
08:05:07,688 INFO [org.openqa.jetty.util.Container] Started HttpContext[/selenium-server,/selenium-server]
08:05:07,689 INFO [org.openqa.jetty.util.Container] Started HttpContext[/selenium-server/driver,/selenium-server/driver]
08:05:07,705 INFO [org.openqa.jetty.http.SocketListener] Started SocketListener on 0.0.0.0:4444
08:05:07,705 INFO [org.openqa.jetty.util.Container] Started org.openqa.jetty.jetty.Server#40e640e6
08:05:07.916 INFO - Checking Resource aliases
Selenium Server started
[INFO]
[INFO] --- maven-surefire-plugin:2.7.2:test (default) # selenium-test ---
[INFO] No tests to run.
[INFO] Surefire report directory: /path/to/surefire-reports/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.387s
[INFO] Finished at: Fri Jan 13 08:05:08 CST 2012
[INFO] Final Memory: 12M/30M
[INFO] ------------------------------------------------------------------------
I'm using perforce, Jenkins, maven3 and Red Hat Enterprise Linux Server release 5.5 (Tikanga). I'm sure my pom is one of the problems, but got it from internet samples...
Thanks (and congratulations to all that have finished reading this post!)
PS: If you also know how to get a report from the Selenium tests that would be great.
The -htmlsuite option is for something completely different from what you're trying to do. Don't let it distract you :-)
Your Java code appears to be written so that the tests are executed via JUnit. That's a very common technique. I expect all you need to do is make sure the Selenium RC server is running before the tests begin. Just java -jar /path/to/selenium-server.jar and leave it running until at least the end of the last test. Your tests will contact the server by creating a connection to it, probably by calling new DefaultSelenium(...).
Jenkins is very well integrated with Maven, so I suggest you concentrate on running the tests using Maven rather than Jenkins. You can use the failsafe plugin to run integration tests such as your selenium tests. Jenkins will automatically find the failsafe reports and show a pretty HTML summary. Also, you can test this more easily on your local machine.
Please can you update your post to clarify whether you're using Selenium 1 or 2. RemoteWebDriver looks like v2, but your POM shows selenium-java-client-driver from 1.0

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 sonar problem

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.

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?