Please, someone help me, I'm desperate. I've been trying all night. The problem I have is this: Weird NoClassDef-s with Eclipse Jetty's Maven plugin
Basically: I can't make recent versions of the Jetty plug-in to work properly in an integration test. Indeed, everything works fine until the Jetty's shutdown stage, when I'm told that org.eclipse.jetty.util.FutureCallback is missing.
I've included the dependencies told in the link above. Initially they were ignored, then I've added them in project/build/extensions. Now I've several other ClassNotFoundExceptions and I can't fix that.
This is what I have in my POM:
<plugins>
<!-- This is activated before tests and uses the overlay import mechanism -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<systemProperties>
<!-- Triggers test data creation in uk.ac.ebi.fg.myequivalents.webservices.server.test.WebTestDataInitializer -->
<systemProperty>
<name>uk.ac.ebi.fg.myequivalents.test_flag</name>
<value>true</value>
</systemProperty>
</systemProperties>
<scanIntervalSeconds>10</scanIntervalSeconds>
<useTestScope>true</useTestScope>
<httpConnector>
<!-- 8080 is often busy on EBI hosts -->
<port>10973</port>
</httpConnector>
<stopPort>10974</stopPort>
<stopKey>KILL</stopKey>
</configuration>
<executions>
<!--
starts jetty before tests and stops it afterwards. Note that no stop goal is needed, it magically stops
after tests
-->
<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>
And these are the extesions I've set up:
<extensions>
<extension>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
</extension>
<extension>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>${jetty.version}</version>
</extension>
<extension>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<version>${jetty.version}</version>
</extension>
<extension>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jaspi</artifactId>
<version>${jetty.version}</version>
</extension>
</extensions>
${jetty.version} is defined in the parent and = 9.1.3.v20140225, but I've tried many, down to 7.x
Moreover, Maven is 3.2.1, Java is 1.7.0_51, running on OS X 10.9.2
Thank you in advance for any help for this nasty issue.
I've found it!!! Apparently, the problem is the 'stop' goal is (rightly) attached to the 'post-integration-test' phase. So, if you issue 'mvn integration-test', such phase, as far as I understand, is not reached (http://tinyurl.com/omwulm5). By just giving 'mvn verify' or 'install', and without adding any Jetty-related dependency to the POM (everything needed should now be included in 9.1.x), Maven completed without any complaint (hooray!).
This might look silly to readers smarter than me, I'm reporting it nonetheless, just in case you're struggling as much as I've just done for hours.
You should not be using the "run" goal with an execution binding. Instead, you should be using the "start" goal. See the documentation here: http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#jetty-start-goal
The difference is that the "run" goal will run a fresh build up until the "test-compile" phase. The "start" goal does not invoke a parallel build and simply runs at whatever phase it is bound to.
Jan
Just try to add <stopWait>10</stopWait> to plugin configuration.
Full configuration you can see in this answer.
Related
Recently I started working on a maven based Struts project using JSP and Java 7.
I see the dependency in pom as following.
<plugin>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<directory>${basedir}/src/main/webapp/</directory>
<includes>
<include>**/*.jsp</include>
</includes>
</sources>
<includeInProject>false</includeInProject>
<validateXml>false</validateXml>
</configuration>
<dependencies>
<dependency>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-compiler-tomcat8</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.5.3</version>
</dependency>
</dependencies>
</plugin>
I removed it and build project successfully. The UI of application works fine.
Can someone please help me in understanding the usage of this plugin?
JSP pre-compilers avoid a JSP compilation delay when a JSP page is first hit.
It is an optimization that may or may not be actually worth it, but for high-page-count high-usage sites that use server-side HTML generation it may be worth it.
For example, see https://www.mulesoft.com/tcat/tomcat-jsp
Meta
Questions like this can be self-answered by searching the web. The first step is to identify what you're looking at, which it appears you did, since you identified the dependency as a JSP compiler.
Once you know what you're trying to look for, ask the web "why use a JSP compiler" or something similar. The reference I posted above was one of the early results when I searched for this.
The Console Launcher that comes with JUnit Platform (from JUnit 5) produces a quite nice summary view at the end. The Maven Surefire plugin, however, has a very simple output.
Is it possible to create with Surefire output similar to what the launches creates?
My current workaround is to disable surefire and use exec-maven-plugin to manually run ConsoleLauncher:
<!-- disable surefire -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version><!-- ... --></version>
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<!-- enable ConsoleLauncher -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version><!-- ... --></version>
<executions>
<execution>
<phase>test</phase>
<goals><goal>java</goal></goals>
<configuration>
<mainClass>org.junit.platform.console.ConsoleLauncher</mainClass>
<arguments>
<argument>--scan-class-path</argument>
<argument>${project.build.directory}/test-classes</argument>
</arguments>
<classpathScope>test</classpathScope>
</configuration>
</execution>
</executions>
</plugin>
<!-- ... -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-console-standalone</artifactId>
<version><!-- ... --></version>
<scope>test</scope>
</dependency>
I know it's an old topic, but this topic was the reason I've developed this extension 2 years ago: https://github.com/fabriciorby/maven-surefire-junit5-tree-reporter
Basically, to get your tree output, add this to your pom.xml:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<dependencies>
<dependency>
<groupId>me.fabriciorby</groupId>
<artifactId>maven-surefire-junit5-tree-reporter</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<configuration>
<reportFormat>plain</reportFormat>
<consoleOutputReporter>
<disable>true</disable>
</consoleOutputReporter>
<statelessTestsetInfoReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporterUnicode">
</statelessTestsetInfoReporter>
</configuration>
</plugin>
And the magic happens
Currently Surefire is developig extensions 1 for embedded Surefire features, and a standalone extension supporting JUnit5 DisplayName.
One of these extensions is a console logger of testset information. Very similar output to the console in 2 might be possible to support as well then.
The extensions is a set of Java abstractions and Surefire/Failsafe plugins will contain default implementations of these abstractions. The other progressive extension implementations, with the output like in 2, would kindly require users to support Surefire project to implement the extensions in their own GitHub repositories (not in ASF). Surefire is welcome to list all third party implementations of these extensions on the ASF Maven Surefire webpage.
This way (Open-Closed DP) we believe we would provide you with certain freedom to change the behavior of plugins without reporting real Jira issues and without waiting for a new feature release.
Sure.
Feel free to open a feature request to extend the current summary output at https://issues.apache.org/jira/projects/SUREFIRE/issue and perhaps a Pull Request against https://github.com/apache/maven-surefire ;-)
I am trying to execute hibernate4-maven-plugin with Oracle using the folowing configuration in my pom.xml :
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<phase>process-test-resources</phase>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<outputFile>${project.build.directory}/test-classes/schema.sql</outputFile>
<format>true</format>
<force>true</force>
<delimiter>;</delimiter>
<type>CREATE</type>
<target>SCRIPT</target>
<driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>
<hibernateDialect>org.hibernate.dialect.Oracle10gDialect
</hibernateDialect>
</configuration>
<!-- not working
<dependencies>
<dependency>
<groupId>org.xerial.thirdparty</groupId>
<artifactId>jdbc-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
-->
</plugin>
but Eclipse shows the following error, saying java.sql.Date is missing :
Execution default of goal de.juplo:hibernate4-maven-plugin:1.1.0:export failed:
A required class was missing while executing
de.juplo:hibernate4-maven-plugin:1.1.0:export: java/sql/Date
I wonder why this is a problem as java.sql.Date is included in the JDK (rt.jar)
I tried to add the dependency to a jar containing java.sql.Date (org.xerial.thirdparty.jdbc-api) but without success.
Thank you for your help.
I just updated my IDE to Spring Tools Suite 3.9.2.RELEASE, migrate the workspace and the error has gone :)
I have a WAR Module in a multi-module Maven project (let's say foo-web), which realises a web-service. Then I have a foo-cli, which implements a web service client and tests it in a couple of unit tests.
In order to make this working, I start Jetty before the test phase this way:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>foo-web</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>test</scope>
</dependency>
...
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<useTestScope>true</useTestScope>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>process-test-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
</executions>
</plugin>
This works perfectly well while I run 'mvn test' from within the foo-cli module (it even stops automatically, with no need to specify anything else). However, when I attempt to go to the upper level (foo) and issue 'mvn test' from there, i.e., I try to run all the tests for all the modules in the project, it fails with '404 - not found'. From the output, I can see that the overlay (the war dependency) seems to be totally ignored.
Thanks in advance for any help.
You should try moving your integration test to the top level project. This way it will run after the WAR artifact has been built.
Have you had a look at the Maven Failsafe Plugin? It's designed for the sort of thing you're doing, which is actually an integration test and not a unit test. The page offers some good advice on why you might want to use the integration-test phase for your integration testing.
Namely, it describes why you might want to do start-jetty during pre-integration-test and so on, so that you can tear it all down appropriately.
I have started playing with Maven2 and I'm attempting to port one of my projects from ant to maven. I have managed to build ear file, use jaxb and other bits, but there is one thing left I don't know how to approach.
I have WAR module, with ExtJS code, and I'm using JSBuilder to create and package the code nicely. This is done as ant task and looks like this:
<target name="-pre-compile" description="Building Frontend Libraries">
<java jar="web/lib/dev/JSBuilder2.jar" failonerror="true" fork="true" >
<arg line="--projectFile web/lib/dev/frontend.jsb2 --homeDir web/lib"/>
</java>
</target>
I am wondering what would be the 'maven' way to do this? Is there a way I can do it purely in maven (had a look at maven:exec plugin but is a bit confusing) or do I have to call ant from maven to achieve this?
Thanks
The exec-maven-plugin is the correct answer (though you want the java goal). You need to bind it to a lifecycle phase. Look at the usage page for an example. In your case, you'd need something like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>jsbuilder</id>
<goals>
<goal>java</goal>
</goals>
<phase>compile</phase>
<configuration>
<mainClass><!-- fill in from jar's META-INF/MANIFEST.MF --></mainClass>
<argument>--projectFile</argument>
<argument>web/lib/dev/frontend.jsb2</argument>
<argument>--homedir</argument>
<argument>web/lib</argument>
</configuration>
</execution>
</executions>
<configuration>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
</configuration>
<dependencies>
<!-- a bit nasty, would be better if jsbuilder2 available in a maven repo. -->
<dependency>
<groupId>com.extjs</groupId>
<artifactId>jsbuilder2</artifactId>
<version>2.0.0</version>
<scope>system</scope>
<systemPath>web/lib/dev/JSBuilder2.jar</systemPath>
</dependency>
</dependencies>
</plugin>
If you're a big user of JSBuilder2, it'd be worth asking Cencha if they can release it to the maven central repo. Point them at OSS Repository Hosting.