No basedir set from native-maven-plugin - maven

I'm having some trouble getting the maven native plugin to work. The problem is that I'm getting an IllegalStateException: "No basedir set" when compiling. The stacktrace follows:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-7:compile (default-compile) on project native-ipc: Execution default-compile of goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-7:compile failed: No basedir set
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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.PluginExecutionException: Execution default-compile of goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-7:compile failed: No basedir set
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.lang.IllegalStateException: No basedir set
at org.codehaus.plexus.util.DirectoryScanner.scan(DirectoryScanner.java:286)
at org.codehaus.mojo.natives.NativeSources.getFiles(NativeSources.java:183)
at org.codehaus.mojo.natives.NativeSources.getAllSourceFiles(NativeSources.java:240)
at org.codehaus.mojo.natives.plugin.NativeCompileMojo.execute(NativeCompileMojo.java:167)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
... 20 more
The native-ipc pom.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>native-ipc</groupId>
<artifactId>native-ipc</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>so</packaging>
<properties>
<basedir>${project.basedir}</basedir>
</properties>
<parent>
<groupId>com.discovix</groupId>
<artifactId>discovix-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<javahOS>MacOS</javahOS>
<sources>
<source>
<directory>src/main/cpp</directory>
<fileNames>
<fileName>ipc.cpp</fileName>
</fileNames>
<includes>
<include>${java.home}/include/*</include>
</includes>
</source>
<source>
<includes>
<include>/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/include/</include>
<include>/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/include/darwin/</include>
</includes>
</source>
</sources>
<linkerStartOptions>
<linkerStartOption>-shared -Wall</linkerStartOption>
</linkerStartOptions>
<compilerProvider>generic-classic</compilerProvider>
<compilerExecutable>g++</compilerExecutable>
</configuration>
<executions>
<execution>
<id>javah</id>
<phase>generate-sources</phase>
<configuration>
<javahOS>MacOS</javahOS>
<javahProvider>default</javahProvider>
<javahOutputDirectory>${project.build.directory}/custom-javah</javahOutputDirectory>
<workingDirectory>${project.basedir}</workingDirectory>
<javahClassNames>
<javahClassName>com.discovix.projects.glimmerglass.jni.posix.IPC</javahClassName>
</javahClassNames>
<goals>
<goal>javah</goal>
</goals>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.discovix</groupId>
<artifactId>network-analyzer</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
And the parent pom is simply:
<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>com.discovix</groupId>
<artifactId>discovix-parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>Discovix GlimmerGlass</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<modules>
<module>network-analyzer</module>
<module>native-ipc</module>
<module>generators</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I feel like I'm missing something obvious. Any help would be appreciated.
-RB

If anyone else runs into this, the problem seemed to be tag order. Ad moved the original pom.xml into a macosx sub-module. The following maven file worked.
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<!-- #todo Break this out into a parent pom and child modules once we have multiple platforms to support. -->
<groupId>com.discovix</groupId>
<artifactId>macosx</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jnilib</packaging>
<name>JNI - MacOSX</name>
<parent>
<groupId>com.discovix</groupId>
<artifactId>discovix-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<jdkIncludePath>/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/include</jdk IncludePath>
<javahOS>macosx</javahOS>
<javahOutputDirectory>${project.build.directory}/custom-javah</javahOutputDirectory>
<!-- demonstrate we can override location of javah generate directory and use javah -o option instead" -->
<javahOutputFileName>posix-ipc.h</javahOutputFileName>
<javahClassNames>
<javahClassName>com.discovix.projects.glimmerglass.jni.posix.IPC</javahClassName>
</javahClassNames>
<compilerProvider>generic</compilerProvider>
<compilerStartOptions>
<compilerStartOption>-fPIC -O</compilerStartOption>
</compilerStartOptions>
<sources>
<source>
<directory>../src/main/native</directory>
<fileNames>
<fileName>ipc.cpp</fileName>
</fileNames>
</source>
<source>
<directory>/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/include/darwin</directory>
<includes>
<include>**/*.h</include>
</includes>
</source>
</sources>
<linkerStartOptions>
<linkerStartOption>-prebind -dynamiclib -lc -ldl</linkerStartOption>
</linkerStartOptions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.discovix</groupId>
<artifactId>network-analyzer</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

The problem is caused by not having a <directory> defined inside a <source>. In the problem above, you have:
<sources>
...
<source>
<includes>
<include>/Library/Java/...</include>
<include>/Library/Java/...</include>
<includes>
<source>
...
<sources>
Notice there is no <directory> tag!
I had a similar problem where I was using a Maven property in the directory tag. Unfortunately, the Maven property was undefined. Yes, it took a while to chase that down.
I hope this helps.

Related

SpringBoot: can't create ear with maven: Unable to deduce layout

I have a SpringBoot project with the war and ear module, that I build using maven ( a build automation tool used primarily for Java projects.) and IntelliJ IDEA This is my pom.xml of the war project:
<?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>
<parent>
<groupId>com.bendiciones</groupId>
<artifactId>bendiciones-parent</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>bendiciones-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com.bendiciones</groupId>
<artifactId>bendiciones-war</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<finalName>${project.build.finalName}-${project.version}</finalName>
<earSourceDirectory>src/main/resources</earSourceDirectory>
<packagingExcludes>**/*.jar</packagingExcludes>
<modules>
<webModule>
<groupId>com.bendiciones</groupId>
<artifactId>bendiciones-war</artifactId>
<contextRoot>/bendiciones</contextRoot>
<bundleFileName>bendiciones.war</bundleFileName>
</webModule>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<releaseProfiles>release</releaseProfiles>
<autoVersionSubmodules>true</autoVersionSubmodules>
<preparationGoals>clean install</preparationGoals>
<arguments>-DaltDeploymentRepository=releases::default::http://el1881.bc:8081/nexus/content/repositories/MicroserviceReleases</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<layout>NONE</layout>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<finalName>bendiciones</finalName>
</build>
</project>
But when I build the class I have this error:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.5.RELEASE:repackage (repackage) on project bendiciones-ear: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.5.RELEASE:repackage failed: Unable to deduce layout for '/bendiciones/bendiciones-ear/target/bendiciones-4.0.0-SNAPSHOT.ear' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.5.RELEASE:repackage (repackage) on project bendiciones-ear: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.5.RELEASE:repackage failed: Unable to deduce layout for '/bendiciones/bendiciones-ear/target/bendiciones-4.0.0-SNAPSHOT.ear'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
Try removing the following from your top pom...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

SpringBoot fails with compatability problems

This is my pom.xml file:
<?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>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<start-class>com.phoneBook.Main</start-class>
</properties>
<groupId>SpringProject</groupId>
<artifactId>SpringProject</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>com.phoneBook.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.10.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
When I try to load a simple SpringBoot project it fails with the following error:
java.lang.NoSuchMethodError: org.springframework.util.ObjectUtils.unwrapOptional(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.validation.DataBinder.<init>(DataBinder.java:179)
at org.springframework.boot.bind.RelaxedDataBinder.<init>(RelaxedDataBinder.java:83)
at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:253)
at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:240)
at org.springframework.boot.context.config.ConfigFileApplicationListener.bindToSpringApplication(ConfigFileApplicationListener.java:241)
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:197)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.phoneBook.Main.main(Main.java:30)
I understood from reading posts here that it's an issue of compatability with dependencies. I was trying to use different versions without success.
It's not a duplicate of: Spring Boot Application Unable to start?
I added the dependencies shown there and I still got the same error.
By the error we can see there is a version mismatch between spring-context and spring-core :
178: public DataBinder(#Nullable Object target, String objectName) {
179: this.target = ObjectUtils.unwrapOptional(target);
180: this.objectName = objectName;
181: }
To check which version of each is used run :
mvn dependency:tree | grep 'spring-context\|spring-core'
You can go further and check the actual packaged version, it should be the same as shown by maven :
jar tf SpringProject-1.0-SNAPSHOT.jar | grep 'spring-context\|spring-core'
If it shows :
BOOT-INF/lib/spring-context-4.3.14.RELEASE.jar
BOOT-INF/lib/spring-core-4.3.14.RELEASE.jar
and the error still persists, please post a complete source sample and steps to reproduce it.

How to use maven-install-plugin to install-file for module

With this projects structure I cannot install the sqljdbc4.jar to my local maven repository.
This is LiferayBuild/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>...</groupId>
<artifactId>LiferayBuild</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>LiferayBuild</name>
<description>Liferay Aggregator Project (build modules)</description>
<properties>
...
</properties>
<modules>
...
<module>../Liferay</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
<file>${basedir}/lib/sqljdbc4-4.0.jar</file>
<packaging>jar</packaging>
<generatePom>false</generatePom>
<pomFile>../Liferay/pom.xml</pomFile>
</configuration>
<executions>
<execution>
<id>inst_sql</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>install</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And this is Liferay/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>...</groupId>
<artifactId>Liferay</artifactId>
<version>1.2.1</version>
<name>Liferay</name>
<description>Liferay Connector</description>
<properties>
...
</properties>
<dependencies>
...
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
...
</dependencies>
<!-- Build Settings -->
<build>
<resources>
...
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
...
</plugins>
</build>
<pluginRepositories>
...
</pluginRepositories>
<profiles>
<profile>
...
</profile>
</profiles>
When I Run as... Maven install, I get a BUILD FAILURE
[ERROR] Failed to execute goal on project Liferay: Could not resolve dependencies for project com.realsoft:Liferay:jar:1.2.1: Failure to find com.microsoft.sqlserver:sqljdbc4:jar:4.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
What can I do to get the jar installed to my local repository? I have already tried the suggestions from http://blog.valdaris.com/post/custom-jar/ but with no outcome. Please help!
Thanks, I have used
<phase>clean</phase>
and moved the lib folder to my basedir of my multi-module project.

What dependency scope for Derby JDBC drivers in intergration scope (cayenne)

I am trying to build my pom.xml so that I can automatically create my database schema when running 'mvn install'. I'm using the "maven-cayenne-plugin" to do this. This is plugin is being called (at the integration-test phase), as I can see the output. But the mojo fails with the exception: (I used the -e and -X flag to see this).
java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
(I get the same if I try and use the EmbeddedDriver and whether or not I include 'derbyclient' or simply 'derby' as my dependency).
Here's a pom.xml that should replicate the issue.
I'm using MVN 3 on Windows.
[ Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000) ]
<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>com.mycompany</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.cayenne.plugins</groupId>
<artifactId>maven-cayenne-modeler-plugin</artifactId>
<version>3.2M1</version>
</plugin>
<plugin>
<groupId>org.apache.cayenne.plugins</groupId>
<artifactId>maven-cayenne-plugin</artifactId>
<version>3.2M1</version>
<executions>
<execution>
<id>cgen</id>
<configuration>
<superPkg>com.mycompany.model.generated</superPkg>
<map>${project.build.sourceDirectory}/../resources/datamap.map.xml</map>
<destDir>${project.build.sourceDirectory}</destDir>
</configuration>
<goals>
<goal>cgen</goal>
</goals>
</execution>
<execution>
<id>cdbgen</id>
<configuration>
<map>${project.build.sourceDirectory}/../resources/datamap.map.xml</map>
<driver>org.apache.derby.jdbc.ClientDriver</driver>
<url>jdbc:derby:memory:tracedb;create=true</url>
<username>test</username>
</configuration>
<goals>
<goal>cdbgen</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.10.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
This also requires a valid cayenne "datamap.map.xml" file (in src/main/resources), here's one I made earlier:
<?xml version="1.0" encoding="utf-8"?>
<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap http://cayenne.apache.org/schema/3.0/modelMap.xsd"
project-version="6">
<db-entity name="TEST">
<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
</db-entity>
</data-map>
EDIT:
Adding more information.
The derbyclient-10.10.1.1.jar does contain the class 'org.apache.derby.jdbc.ClientDriver' (just expanded the JAR from Netbeans).
The -X flag seems to show that the CLASSPATH is correctly referencing the JAR:
[DEBUG] (f) classpathElements = [<PROJECT-PATH>\mvn\target\classes, <HOME-DIR>\.m2\repository\org\apache\derby\derbyclient\10.10.1.1\derbyclient-10.10.1.1.jar]
SOLUTION:working pom.xml (see answer and my comment):
<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>com.mycompany</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.cayenne.plugins</groupId>
<artifactId>maven-cayenne-modeler-plugin</artifactId>
<version>3.2M1</version>
</plugin>
<plugin>
<groupId>org.apache.cayenne.plugins</groupId>
<artifactId>maven-cayenne-plugin</artifactId>
<version>3.2M1</version>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.10.1.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>cgen</id>
<configuration>
<superPkg>com.mycompany.model.generated</superPkg>
<map>${project.build.sourceDirectory}/../resources/datamap.map.xml</map>
<destDir>${project.build.sourceDirectory}</destDir>
</configuration>
<goals>
<goal>cgen</goal>
</goals>
</execution>
<execution>
<id>cdbgen</id>
<configuration>
<map>${project.build.sourceDirectory}/../resources/datamap.map.xml</map>
<driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
<url>jdbc:derby:memory:tracedb;create=true</url>
<username>test</username>
</configuration>
<goals>
<goal>cdbgen</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.10.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
To ensure that the Derby driver is available during plugin execution (vs during your code compilation), you need to add it as a dependency of the plugin itself:
<plugin>
<groupId>org.apache.cayenne.plugins</groupId>
<artifactId>maven-cayenne-plugin</artifactId>
<version>3.2M1</version>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.10.1.1</version>
</dependency>
</dependencies>
....
</plugin>

Maven permission denied

I'm getting strange exception while trying to create exploded war directory with maven. And it's strange because I already changed all files permissions to 777 for everyone.
What should I check? Ican't find any useful info in stacktrace :(
Goals I execute:
install war:exploded tomcat:redeploy
Here's stacktrace:
Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:exploded (default-cli) on project app-web: Failed to copy file for artifact [com.kk:app-core2:jar:app-SNAPSHOT:compile]: D:\kk\app-2013\app-core2\target\classes (Odmowa dostępu) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:exploded (default-cli) on project app-web: Failed to copy file for artifact [com.kk:app-core2:jar:app-SNAPSHOT:compile]
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:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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: Failed to copy file for artifact [com.kk:app-core2:jar:app-SNAPSHOT:compile]
at org.apache.maven.plugin.war.packaging.ArtifactsPackagingTask.performPackaging(ArtifactsPackagingTask.java:137)
at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.handleArtifacts(WarProjectPackagingTask.java:195)
at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.performPackaging(WarProjectPackagingTask.java:107)
at org.apache.maven.plugin.war.AbstractWarMojo.buildWebapp(AbstractWarMojo.java:479)
at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:412)
at org.apache.maven.plugin.war.WarExplodedMojo.execute(WarExplodedMojo.java:43)
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: java.io.FileNotFoundException: D:\kk\app-2013\app-core2\target\classes (Odmowa dostępu)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:138)
at org.codehaus.plexus.util.FileUtils.doCopyFile(FileUtils.java:1067)
at org.codehaus.plexus.util.FileUtils.copyFile(FileUtils.java:1049)
at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFile(AbstractWarPackagingTask.java:304)
at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask$1.registered(AbstractWarPackagingTask.java:152)
at org.apache.maven.plugin.war.util.WebappStructure.registerFile(WebappStructure.java:211)
at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFile(AbstractWarPackagingTask.java:147)
at org.apache.maven.plugin.war.packaging.ArtifactsPackagingTask.performPackaging(ArtifactsPackagingTask.java:112)
... 26 more
EDIT 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/maven-v4_0_0.xsd">
<parent>
<artifactId>app</artifactId>
<groupId>com.kk</groupId>
<version>2013-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>app-web</artifactId>
<packaging>war</packaging>
<name>Application</name>
<dependencies>
<!- whole lot of dependecies->
</dependencies>
<build>
<resources>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
<includes>
<include>**</include>
</includes>
<excludes>
</excludes>
</resource>
<resource>
<filtering>false</filtering>
<directory>src/main/java</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<filtering>false</filtering>
<directory>src/main/html</directory>
<includes>
<include>**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<excludeResources>true</excludeResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
<complianceLevel>1.6</complianceLevel>
<includes>
<include>**/IMediaManager.java</include>
<include>**/CachableMediaManager.java</include>
<include>**/BaseApplication.java</include>
</includes>
<aspectLibraries>
<aspectLibrary>
<groupId>com.kk</groupId>
<artifactId>commons-cache</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<finalName>app-web</finalName>
</build>
<profiles>
<profile>
<id>development</id>
<dependencies>
<dependency>
<groupId>com.kk</groupId>
<artifactId>app-web-config</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
</properties>
</profile>
</profiles>
</project>

Resources