Maven assembly - Error reading assemblies - plugins

I have defined a personalized jar-with-dependencies assembly descriptor. However, when I execute it with mvn assembly:assembly, I get :
...
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] javax/ already added, skipping
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] META-INF/maven/ already added, skipping
[INFO] [assembly:assembly {execution: default-cli}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error reading assemblies: No assembly descriptors found.
My jar-with-dependencies.xml is in src/main/resources/assemblies/.
My assembly descriptor is the following :
<?xml version='1.0' encoding='UTF-8'?>
<assembly>
<id>jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<dependencySets>
<dependencySet>
<scope>runtime</scope>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>**/LICENSE*</exclude>
<exclude>**/README*</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources/META-INF/services</directory>
<outputDirectory>META-INF/services</outputDirectory>
</fileSet>
</fileSets>
</assembly>
And my project pom.xml is :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>jar-with-dependencies.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>org.my.app.HowTo</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
When mvn assembly:assembly is performed, dependencies are unpacked and I get the previous error when unpack has finished.
Moreover, if I execute mvn -e assembly:assembly it is say that no descriptors has been found, however it try to unpack dependencies and a JAR with dependencies is created but it doesn't contain META-INF/services/* as specified in descriptor :
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error reading assemblies: No assembly descriptors found.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error reading assemblies: No assembly descriptors found.
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:597)
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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error reading assemblies: No assembly descriptors found.
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:356)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.apache.maven.plugin.assembly.io.AssemblyReadException: No assembly descriptors found.
at org.apache.maven.plugin.assembly.io.DefaultAssemblyReader.readAssemblies(DefaultAssemblyReader.java:206)
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:352)
... 19 more
I don't see my error. Does someone has a solution ?

There are two problems here. First, when using your own descriptor, you must specify the path to your customized descriptor file (by the way, you can use any location but putting the descriptor in src/main/resources is maybe not the best choice, you don't really want the descriptor to be packaged in your application, I'd use the standard location which is src/main/assembly as mentioned in this page).
<descriptors>
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>
Second, your configuration element is currently inside an execution block and is thus specific to this execution. In other words, it won't apply if you run assembly:assembly on the command line. So, if you want to call assembly:assembly with a custom descriptor, either use:
mvn assembly:assembly -Ddescriptor=path/to/descriptor.xml
Or move the configuration outside the execution element (to make the configuration global):
<project>
...
<build>
...
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>path/to/descriptor.xml</descriptor>
</descriptors>
...
</configuration>
</plugin>
</plugins>
...
</build>
...
</project>

assembly is trying to open /assemblies/${ref}.xml in classpath
check this
http://maven.apache.org/plugins/maven-assembly-plugin/xref/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.html

Related

Maven pom.xml for MATLAB compiler project

I have a Tomcat servlet project that requires a MATLAB jar generated by mcc. I have implemented a mojo plugin (mcc-maven-plugin) that generates the jar. It simply takes the specifications from a pom and creates a MATLAB command of the form:
cd '/home/jeffemandel/webpropofolmm/matlab/src/main/matlab';mcc -W 'java:webpropofol_java,loadServlet' -d '/home/jeffemandel/webpropofolmm/matlab/target' class{loadServlet:loadServlet.m} class{locServlet:locServlet.m} class{testStruct:testStruct.m}
This generates the file /home/jeffemandel/webpropofolmm/matlab/target/webpropofol_java.jar
Note that target must exist for mcc to work.
I need this file in my main project, but it is resource-intensive to generate the jar every time I make a minor tweak to the UI (which has a small amount of Java and a lot of HTML, css, and javascript). My confusion point is how to generate a jar that doesn't depend on any Java code. Here is my pom.xml:
<?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>org.jeffmandel.webpropofol</groupId>
<artifactId>optimaltiva</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javabuilder</groupId>
<artifactId>javabuilder</artifactId>
<version>9.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jeffmandel</groupId>
<artifactId>mcc-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>mcc</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<packageName>webpropofol_java</packageName>
<className>loadServlet</className>
<classes>
<loadServlet>loadServlet.m</loadServlet>
<locServlet>locServlet.m</locServlet>
<testStruct>testStruct.m</testStruct>
</classes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<groupId>org.jeffmandel.webpropofol</groupId>
<artifactId>optimaltiva</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<file>${project.build.directory}/webpropofol_java.jar</file>
<generatePom>true</generatePom>
</configuration>
<executions>
<execution>
<id>install-jar-lib</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>install</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I run mvn compile, this is what I get:
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< org.jeffmandel.webpropofol:optimaltiva >---------------
[INFO] Building optimaltiva 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # optimaltiva ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/jeffemandel/webpropofolmm/matlab/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # optimaltiva ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-antrun-plugin:1.4:run (default) # optimaltiva ---
project.artifactId
[INFO] Executing tasks
[INFO] Executed tasks
[INFO]
[INFO] --- mcc-maven-plugin:0.0.1-SNAPSHOT:mcc (default) # optimaltiva ---
[INFO] cd '/home/jeffemandel/webpropofolmm/matlab/src/main/matlab';mcc -W 'java:webpropofol_java,loadServlet' -d '/home/jeffemandel/webpropofolmm/matlab/target' class{loadServlet:loadServlet.m} class{locServlet:locServlet.m} class{testStruct:testStruct.m}
[INFO] Loading source files for package webpropofol_java...
Constructing Javadoc information...
Standard Doclet version 1.8.0_221
Building tree for all the packages and classes...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/loadServlet.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/loadServletRemote.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/locServlet.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/locServletRemote.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/testStruct.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/testStructRemote.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/Webpropofol_javaMCRFactory.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/package-frame.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/package-summary.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/webpropofol_java/package-tree.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/constant-values.html...
Building index for all the packages and classes...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/overview-tree.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/index-all.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/deprecated-list.html...
Building index for all classes...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/allclasses-frame.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/allclasses-noframe.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/index.html...
Generating /home/jeffemandel/webpropofolmm/matlab/target/doc/html/help-doc.html...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 36.215 s
[INFO] Finished at: 2020-12-12T22:26:54-05:00
[INFO] -----
The problem is that every time I run mvn compile it generates the jar, rather than seeing that the source files haven't changed so don't regenerate the jar. My ultimate goal is to have one project that contains the matlab and servlet.
I did some more reading and figured out that it was the responsibility of the mojo plugin to figure out whether recompilation was needed. MATLAB needs to rebuild the entire jar even if only a single file changes, so I added the following code to my mojo plugin:
import org.apache.commons.io.filefilter.AgeFileFilter;
import java.io.FileFilter;
File myJar = new File(outputDirectory + File.separator + packageName + ".jar");
AgeFileFilter myFilter = new AgeFileFilter(myJar, false);
File source = new File(sourceDirectory);
File[] files = source.listFiles((FileFilter) myFilter);
if (files.length==0) {
getLog().info("Project up to date");
} else {
...
}
This does the trick.

Maven not building Scala project correctly

Problem
I got a Maven - Scala project. It compiles etc. when I want to build it in IntelliJ it works but the output jar is empty except a pom.xml.
When a build the whole project via command line with mvn scala:compile I get the following errors:
[INFO] Compiling 67 source files to /Users/my.name/Documents/company/util/util/target/classes at 1555483575272
[ERROR] error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
[ERROR] at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
[ERROR] at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
[ERROR] at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:53)
[ERROR] at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
[ERROR] at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:45)
[ERROR] at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
[ERROR] at scala.reflect.internal.Mirrors$RootsBase.getClassByName(Mirrors.scala:102)
[ERROR] at scala.reflect.internal.Mirrors$RootsBase.getRequiredClass(Mirrors.scala:105)
[ERROR] at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass$lzycompute(Definitions.scala:257)
[ERROR] at scala.reflect.internal.Definitions$DefinitionsClass.ObjectClass(Definitions.scala:257)
[ERROR] at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1394)
[ERROR] at scala.tools.nsc.Global$Run.<init>(Global.scala:1215)
[ERROR] at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
[ERROR] at scala.tools.nsc.MainClass.doCompile(Main.scala:23)
[ERROR] at scala.tools.nsc.Driver.process(Driver.scala:51)
[ERROR] at scala.tools.nsc.Driver.main(Driver.scala:64)
[ERROR] at scala.tools.nsc.Main.main(Main.scala)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[ERROR] at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
[ERROR] at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.256 s
[INFO] Finished at: 2019-04-17T08:46:16+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.3.1:compile (default-cli) on project util: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
I also can run mvn compile which succeeds but produces an empty jar:
[INFO] Building util 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # util ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/markus.geilehner/Documents/Syniverse/util/util/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) # util ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /Users/markus.geilehner/Documents/Syniverse/util/util/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.334 s
[INFO] Finished at: 2019-04-17T09:03:55+02:00
[INFO] ------------------------------------------------------------------------
Project File Structure
-util
--src
---main
----scala
-----com.company.util
------Scala Classes and packages
pom.xml
Here some parts of the pom.xml. I use the net.alchim Scala-maven plugin.
The build process is configured to use the scala directory.
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<configuration>
<reportPlugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<jvmArgs>
<jvmArg>-Xms64m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
</jvmArgs>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
Solution
I had the same error when working with a scala project combined with maven.
Issue-1
One Issue can be that you use the wrong Java-Version (9/10) try to change it to Java 8 (1.8) in IntelliJ (File => Project-Structure).
Issue-2
In your pom add the following execution beneath the maven-scala plugin.
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<phase>compile</phase>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>testCompile</goal>
</goals>
<phase>test-compile</phase>
</execution>
<execution>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
Do a clean install an try again.

How do I include a maven jar project to a maven war project?

I have an eclipse java/jar project that used to statically link to other jar files. I remade this project into a maven project (Listing 1) so I could remove these static jar files and let maven resolve them.
And I have another war web application that I also transformed another project MyWarProject that used to have a dependency on MyJarProject to maven. And added MyJarProject as a dependency (Listing 2).
This the upper section pom.xml for my jar project
<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>MyJarProject</groupId>
<artifactId>MyJarProject</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>......
This is the full listing pom.xml for the war project that depends on the jar file
<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>MyWarProject</groupId>
<artifactId>MyWarProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>MyJarProject</groupId>
<artifactId>MyJarProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
The first jar projects builds fine after a maven clean install. However the war project displays this error message. Those missing classes like ItemsDAO are supposed to be resolved from the jar project.
And no jar file is actually copied to the WEB-INF folder. Please help!
INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # MyWarProject ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # MyWarProject ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 41 source files to C:\Users\iaddou\workspace1\MyWarProject\target\classes
[INFO] Some input files use or override a deprecated API.
[INFO] Recompile with -Xlint:deprecation for details.
[INFO] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\utility\MegaItemProcessCodeType.java uses unchecked or unsafe operations.
[INFO] Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/utility/WebServicesLogger.java:[3,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\utility\WebServicesLogger.java:3: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/utility/WebServicesLogger.java:[15,32] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\utility\WebServicesLogger.java:15: package com.documentum.fc.client does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/utility/WebServicesLogger.java:[216,17] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\utility\WebServicesLogger.java:216: cannot find symbol
symbol : class IDfSession
location: class com.rd.test.MyWarProject.utility.WebServicesLogger
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemsImpl.java:[15,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemsImpl.java:15: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemsImpl.java:[16,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemsImpl.java:16: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemsImpl.java:[17,35] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemsImpl.java:17: package com.rd.test.common.data does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemsImpl.java:[42,13] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemsImpl.java:42: cannot find symbol
symbol : class ItemsDAO
location: class com.rd.test.MyWarProject.MegaItemsImpl
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemVersionHistoryImpl.java:[11,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemVersionHistoryImpl.java:11: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemVersionHistoryImpl.java:[12,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemVersionHistoryImpl.java:12: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemVersionHistoryImpl.java:[13,35] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemVersionHistoryImpl.java:13: package com.rd.test.common.data does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemVersionHistoryImpl.java:[40,17] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemVersionHistoryImpl.java:40: cannot find symbol
symbol : class VersionHistoryDAO
location: class com.rd.test.MyWarProject.MegaItemVersionHistoryImpl
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemDetailImpl.java:[12,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemDetailImpl.java:12: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemDetailImpl.java:[13,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemDetailImpl.java:13: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemDetailImpl.java:[14,35] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemDetailImpl.java:14: package com.rd.test.common.data does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemDetailImpl.java:[39,17] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemDetailImpl.java:39: cannot find symbol
symbol : class ItemDAO

The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid version could be found

I hit into deployment error for Jboss AS 7.1.1 Final deployment as mentioned at Could not connect to remote://localhost:9999. The connection timed out Jboss 7.1.1 Final. I am trying to use latest version of Jboss Maven plugin '7.4.Final' from '7.1.1.Final'. When I made change in POM configuration I am getting following error for both versions of plug-in. I have confirmed that my .m2 has both of these plug-in versions available.
Is POM meta data corrupt in my case, if so how do I clean it up to get it working?
[INFO] Searching repository for plugin with prefix: 'jboss-as'.
[DEBUG] Loading plugin prefixes from group: org.apache.maven.plugins
[DEBUG] Loading plugin prefixes from group: org.codehaus.mojo
[DEBUG] maven-jboss-as-plugin: using locally installed snapshot
[DEBUG] Artifact not found - using stub model: Unable to determine the latest version
org.apache.maven.plugins:maven-jboss-as-plugin:pom:LATEST
[DEBUG] Using defaults for missing POM org.apache.maven.plugins:maven-jboss-as-plugin:pom:LATEST
[DEBUG] maven-jboss-as-plugin: using locally installed snapshot
[DEBUG] Artifact not found - using stub model: Unable to determine the release version
org.apache.maven.plugins:maven-jboss-as-plugin:pom:RELEASE
[DEBUG] Using defaults for missing POM org.apache.maven.plugins:maven-jboss-as-plugin:pom:RELEASE
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid version could be found
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAggregationNeeds(DefaultLifecycleExecutor.java:462)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:175)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
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)
Caused by: org.apache.maven.plugin.version.PluginVersionNotFoundException: The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid version could be found
at org.apache.maven.plugin.version.DefaultPluginVersionManager.resolvePluginVersion(DefaultPluginVersionManager.java:229)
at org.apache.maven.plugin.version.DefaultPluginVersionManager.resolvePluginVersion(DefaultPluginVersionManager.java:91)
at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:179)
at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
... 15 more
UPDATE
POM.xml
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- continue build even test fails -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
<configuration>
<filename>${project.build.finalName}.jar</filename>
<username>${userName}</username>
<password>${password}</password>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
The stack trace show us as
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin'
does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
It should be org.jboss.as.plugins:jboss-as-maven-plugin instead.
The JBoss Application Server 7: Plugin Documentation told us to configure as the following: -
<project>
...
<build>
<!-- To define the plugin version in your parent POM -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
</plugin>
...
</plugins>
</pluginManagement>
<!-- To use the plugin goals in your POM or parent POM -->
<plugins>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.4.Final</version>
</plugin>
...
</plugins>
</build>
...
</project>
Please review and ensure that the plugin org.jboss.as.plugins:boss-as-maven-plugin is under the <build> in your pom.xml.
I hope this may help.
I was facing similar issue. This issue was due to older version of maven2.2.1.
When moved to newer version3.x of maven it worked.

Errors using Maven Mojo sql:execute

TL;DR version: I want to be able to use the Maven Mojo SQL Plugin to create/drop any given table in my DB schema (or load data for those tables) at will via the mvn command-line. How?
I'm a long-time Java developer, but for the most part I've been living in an ant-based world. I like the power and explicitness of ant, and the control that it gives me over everything. However, in my new job, there's a push to use maven. So I've decided to learn it using a project I'm working on at home.
One of the things that I have set up on a different personal project is the ability to completely set up and tear down my Postgres database from ant on the command line. I can slice and dice any table, sequence, and integration test data that I please, individually or in concert. Sure, it means that I have about a gajillion ant targets, but it works very well. I like this; it has served me quite well over the years.
In researching how to accomplish this in Maven over the weekend, I found the Mojo SQL Maven Plugin. After looking at the usage page (and I use that term loosely, as it's really just a single semi-example with no explanations) and the example page, I was able to come up with some changes to my pom.xml file. I fixed some obvious typos in the example (postgressql), and referenced the PostgreSQL JDBC page to make sure I had the JDBC connection string correct. I'll paste all of the pom.xml (modified to protect the guilty) below:
<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>com.mycompany.myapp</groupId>
<artifactId>myapp</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>JBoss</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.0.CR7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-606.jdbc4</version>
</dependency>
</dependencies>
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432/myapp</url>
<settingsKey>myapp</settingsKey>
<!--all executions are ignored if -Dmaven.test.skip=true-->
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<id>drop-db-before-test-if-any</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<!-- need another database to drop the targeted one -->
<url>jdbc:postgresql://localhost:5432/template1</url>
<autocommit>true</autocommit>
<sqlCommand>drop database myapp</sqlCommand>
<!-- ignore error when database is not avaiable -->
<onError>continue</onError>
</configuration>
</execution>
<execution>
<id>create-db</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>jdbc:postgresql://localhost:5432/template1</url>
<!-- no transaction -->
<autocommit>true</autocommit>
<sqlCommand>create database myapp</sqlCommand>
</configuration>
</execution>
<execution>
<id>create-schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<srcFiles>
<srcFile>src/main/sql/create_person.sql</srcFile>
</srcFiles>
</configuration>
</execution>
<execution>
<id>create-data</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<orderFile>ascending</orderFile>
<fileset>
<basedir>${basedir}</basedir>
<includes>
<include>src/test/sql/person_data.sql</include>
</includes>
</fileset>
</configuration>
</execution>
<!-- drop db after test -->
<execution>
<id>drop-db-after-test</id>
<phase>test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>jdbc:postgresql://localhost:5432/template1</url>
<autocommit>true</autocommit>
<sqlCommand>drop database myapp</sqlCommand>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Now, since I haven't created the database, it doesn't show up in a \l on the PG command-line:
[mike#mike myapp]$ psql template1
Welcome to psql 8.3.5, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
template1=# \l
List of databases
Name | Owner | Encoding
-----------+----------+----------
postgres | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
(3 rows)
Thus, when I run mvn sql:execute, I expect my database to get created...Or at least not to fail on the drop-db-before-test-if-any task since that is set to continue on error. But of course:
[mike#mike myapp]$ mvn sql:execute
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sql-maven-plugin:1.5:execute (default-cli) # myapp ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.667s
[INFO] Finished at: Mon Dec 05 20:22:17 CST 2011
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sql-maven-plugin:1.5:execute (default-cli) on project myapp: FATAL: database "myapp" does not exist -> [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/MojoExecutionException
The error page mentioned on the last line there isn't helpful; it just tells me that a plugin caused the error, not Maven itself.
So let's run it with the -X switch. I'll just post the interesting part of the error:
[ERROR] Failed to execute goal org.codehaus.mojo:sql-maven-plugin:1.5:execute (default-cli) on project myapp: FATAL: database "myapp" does not exist -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sql-maven-plugin:1.5:execute (default-cli) on project myapp: FATAL: database "myapp" does not exist
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
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:319)
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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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)
Caused by: org.apache.maven.plugin.MojoExecutionException: FATAL: database "myapp" does not exist
at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:618)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.postgresql.util.PSQLException: FATAL: database "myapp" does not exist
at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:444)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:99)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:124)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:29)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:386)
at org.postgresql.Driver.connect(Driver.java:260)
at org.codehaus.mojo.sql.SqlExecMojo.getConnection(SqlExecMojo.java:899)
at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:612)
... 21 more
But, but, but...<onError>continue</onError>!
So, to the questions:
What am I doing wrong? Is it my expectations, or my code?
You'll notice that I have a create-person.sql file. I know from the examples that I can have multiple files there, such as create-address.sql. But in ant, I have the ability to create the address table separately from the person table, so long as I perform the ant tasks keeping in mind the order of referential integrity. Is something like that possible with maven? If so, how?
Sorry for the verbosity, and thanks in advance for any assistance.
Failed to execute goal org.codehaus.mojo:sql-maven-plugin:1.5:execute
(default-cli)
default-cli is the special executionId when the plugin is invoked from command-line. See this.
You have bound all the sql plugin execution to maven lifecycle phases, but you are trying to invoke the plugin directly.
mvn test should work.
Here is a related SO discussion.