I have a maven project in STS(Eclipse) and I try deploying it to Tomcat 6 in STS. For maven install I use gwt-maven-plugin. Installed war contains all folders (WEB-INF/, META-INF/, compiled GWT frontend folder). When I deploy this project to tomcat (in STS), there are only WEB-INF and META-INF folders in webapps/project folder. Folder with compiled GWT frontend is nowhere to find. In context.xml I even tried to set docBase to installed war, but no difference in result. Have anyone an idea where problem could be?, because now I have to manually copy this folder to unpacked folder in webapps. Thanks alot.
Might be a configuration problem, post your gwt-maven-plugin xml here.
Here's mine, just for reference
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<configuration>
<logLevel>DEBUG</logLevel>
<style>PRETTY</style>
<runTarget>/ApplicationScaffold.html</runTarget>
<hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>
<!-- <modules><module>${project.groupId}.Main</module></modules>-->
<copyWebapp>true</copyWebapp>
<debugPort>8001</debugPort>
<extraJvmArgs>-Xmx900m</extraJvmArgs>
<!-- instruct plugin not to require open browser in test mode -->
<mode>htmlunit</mode>
<!-- compiler speed up -->
<draftCompile>true</draftCompile>
<optimizationLevel>0</optimizationLevel>
<disableAggressiveOptimization>true</disableAggressiveOptimization>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- must override the plugin's default dependencies -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwt.version}</version>
</dependency>
</dependencies>
</plugin>
Related
I have 2 .zip files: shared-lib-windows.zip and shared-lib-linux.zip. A maven dependency jar looks for the the shared-lib directory under WEB-INF/lib/ and expects .exe or .out file to be present in the shared-lib directory.
How do I setup the .zip files in my pom.xml so that the appropriate zip file is picked up, extracted to the renamed(shared-lib, without the -os) directory?
I have already setup the maven dependency (jar) as:
<profiles>
<profile>
<id>Linux</id>
<dependencies>
<dependency>
<groupId>com.dependency</groupId>
<artifactId>depedency-linux</artifactId>
<version>0.0.9</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>Windows</id>
<dependencies>
<dependency>
<groupId>com.dependency</groupId>
<artifactId>dependency-windows</artifactId>
<version>0.0.9</version>
</dependency>
</dependencies>
</profile>
</profiles>
Now I just want Maven to pick up the .zip files from either src/main/resources or .m2/.../ and do the magic!
I have looked into answers which suggested maven-ant-plugin, but someone mentioned that'd be uncool.
[edit: add info]
I have a Maven web-project packaged as a .war and deployed to Tomcat.
Also, the .exe/.out files are a 3rd party dependency with a size of 120/150 MB respectively. Since my git does not have large file support and the binaries won't be updated, I've zipped it and added to my Git managed Maven web-project.
I went through official documentation about Maven profiles, phases and properties.
I came up with a solution that uses maven-antrun-plugin. I'm still looking for a solution that does not rely on it.
Run the below pom.xml on Linux with: mvn package -P Linux
<profiles>
<profile>
<id>Linux</id>
<properties>
<binary.zip>${project.basedir}/src/main/resources/binary-linux.zip</binary.zip>
<unzip.folder>${project.build.directory}/${project.build.finalName}/WEB-INF/lib/binary</unzip.folder>
</properties>
<dependencies>
<dependency>
<groupId>com.dependency</groupId>
<artifactId>depedency-linux</artifactId>
<version>0.0.9</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>Windows</id>
<properties>
<binary.zip>${project.basedir}/src/main/resources/binary-windows.zip</binary.zip>
<unzip.folder>${project.build.directory}/${project.build.finalName}/WEB-INF/lib/binary</unzip.folder>
</properties>
<dependencies>
<dependency>
<groupId>com.dependency</groupId>
<artifactId>dependency-windows</artifactId>
<version>0.0.9</version>
</dependency>
</dependencies>
</profile>
</profiles>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>unzip-binary</id>
<phase>prepare-package</phase>
<configuration>
<tasks>
<echo message="unzip the binary" />
<unzip src="${binary.zip}" dest="${unzip.folder}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
This will extract the .zip into the ..WEB-INF/lib/binary directory (in the prepare-package phase) before archiving it into a .war (in the package phase) with maven-war-plugin plugin.
I have created a neo4j user-defined procedure. It also compiles and works in neo4j.
Recently though, I added a dependency to my procedure plugin that prevents neo4j from starting when I try to run the newly built jar. Concretely, I receive following exception at the bottom of the stack trace:
Caused by: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
The only thing I changed is to add MapDB to my dependencies. So I suspect that it depends on some signed artifact. As it turns out neo4j plugins are "uber-jars" (i.e., shaded jars) which doesn't work very well with signed dependencies.
I figured I could try to exclude MapDB from the shading by changing the scope to provided and additionally adding the mapdb jar to plugins folder of neo4j. So the plugins folder of neo4j now includes both mapdb.jar and myprocedure.jar.
This doesn't seem to work though: neo4j starts, but when calling my procedure I receive a ClassNotFound Exception.
Any ideas on how I can solve this dilemma? I really depend on something like MapDB as my graph is very large and keeping everything in my procedure in-memory regularly leads to memory exceptions.
Many thanks in advance!
The important part of my pom.xml should it help (I started off with the procedure template so it still looks quite similar):
<dependencies>
<!-- other dependencies that don't make a difference ... -->
<dependency>
<groupId>org.mapdb</groupId>
<artifactId>mapdb</artifactId>
<version>3.0.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>${neo4j.version}</version>
<scope>provided</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.neo4j.test</groupId>
<artifactId>neo4j-harness</artifactId>
<version>${neo4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>1.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<!-- Neo4j Procedures require Java 8 -->
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<!-- This generates a jar-file with our procedure code,
plus any dependencies marked as `compile` scope.
This should then be deployed in the `plugins` directory
of each Neo4j instance in your deployment.
After a restart, the procedure is available for calling. -->
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
So, one solution that worked was to use the maven-assembly-plugin instead of the maven-shade-plugin. The assembly plugin creates a standalone jar with all dependencies without re-packaging all dependencies.
Of course, I had to remove the <scope>provided</scope> for mapdb so it is also included in the assembled jar.
The rest is just replacing the shade plugin with following snippet (thanks to this question here):
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
Afterwards I received another exception which I thought was due to a wrong signature:
Caused by: java.lang.VerifyError ...
Turns out this was just because I had another procedure in neo4j that uses the same dependencies as mapdb. Quick fix was to remove that procedure library.
Of course, there are also other solutions, including removing the signature, or re-signing it. However, I explicitly did not want to remove any signatures.
I'm not aware that neo4j is checking any jar signatures by default. I suspect the repackaging of mapdb artifact being the culprit.
To validate that, remove the shade or assembly plugin in and build a jar that solely contains your code. Copy that jar and the mapdb.jar into the plugin folder and observe logs during a restart.
I have a testng dependency in pom.xml with 'test' scope:
</dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
My folder layout is as follows:
src/test/java - test source folder
src/test/resources - test resources folder
When trying to import testng in classes created under src/test/java/ IntelliJ can not find testng.
First of all open Maven Projects tab and simply refresh to get in sync.
Secondly, open the project structure and check if your sources are marked correctly.
Without more info, this is what I would suggest.
I suspect you have src/test/java in one module/project and you would like to reuse it in other module/project? If that's correct you need to build and install your test jar (add to your source project):
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Then you can use it in other projects by adding maven dependency.
I have a third party library coming with .jar and .so file.
I configured pom.xml as following:
<dependency>
<groupId>com.abc.def</groupId>
<artifactId>sdc</artifactId>
<version>1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.abc.def</groupId>
<artifactId>sdc</artifactId>
<version>3</version>
<scope>compile</scope>
<type>so</type>
</dependency>
With this configure, I successfully tested through Intellij and apk file under target contains structure like lib/armeabi/sdc.so
However, after I do mvn clean package, the apk file generated did not contain sdc.so file, and after installing apk file on android device, lib folder is empty.
Searching through the internet, and did not find answer.
Btw, I do add <nativeLibrariesDirectory>${project.basedir}/libs</nativeLibrariesDirectory> into pluginManagement as mentioned Native libraries (.so files) are not added to an android project, but does not help.
Updates:
If someone is facing same problem as I am that SO file did not copy over, please try manually copy the so file over as following:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.abc.def</groupId>
<artifactId>libdef</artifactId>
<version>2.1.3</version>
<type>so</type>
<destFileName>libdef.so</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/libs/armeabi</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I suggest you to use maven-android-plugin version 2.8.3 or more.
The scope of your native lib must be runtime (not sure it is required, but anyway it's a fact)
The artifactId must start with lib (i.e. it must be libsdc)
<dependency>
<groupId>com.abc.def</groupId>
<artifactId>libsdc</artifactId>
<version>3</version>
<scope>runtime</scope>
<type>so</type>
</dependency>
The artifactId will be the library name so load it with this line of code
System.loadLibrary("sdc");
reference
Note: I don't know if sdc if the real artifactId, but if it's the case you must consider re-publishing it with the lib prefix.
I would suggest looking into the Assembly plugin: http://maven.apache.org/plugins/maven-assembly-plugin/ I have not used it in any Android project yet, but I do use it in my regular java server projects which require non-maven items be in expected locations.
I am developing application that uses Cassandra NoSQL database and I am adding web interface. I have 2 projects: cassandra-access (this project is DAL) and web (this project is web application).
Scenario is simple enaugh. Cassandra-access has dependencies on hector.jar which is not in maven repository. So I added this dependency to my local repository via mvn install:install-file and I list my repository in parent pom:
<repositories>
<repository>
<id>loc</id>
<url>file://${basedir}/../mvn-local-repository</url>
</repository>
</repositories>
In Web projects pom I added dependency on Cassandra-access. But when i start the Web application with hello world read from database I am getting classNotFound exception as if the hector.jar isn't on class path. When I write mvn clean install the resulting war of web project doesn't include hector.jar in WEB-INF/lib. That further confirms my theory.
How to achieve that war get's all the transitive dependcies? I thought that all dependencies that are in scope compile (which is default) will get copied.
Web projects pom:
<dependency>
<groupId>net.product</groupId>
<artifactId>cassandra-access</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Cassandra-access pom:
<dependency>
<groupId>me.prettyprint</groupId>
<artifactId>hector</artifactId>
<version>0.7.0</version>
</dependency>
It maybe not the optimal solution but it works for me:
put the hector jar in the lib directory of the cassandra access.
add to the cassandra-access pom:
<dependency>
<groupId>%HECTOR_JAR_GROUP_ID%</groupId>
<artifactId>%HECTOR_JAR_ARTIFACT_ID%</artifactId>
<version>%HECTOR_JAR_VERSION%</version>
<scope>system</scope>
<systemPath>${basedir}/lib/%HECTOR_JAR_NAME%</systemPath>
</dependency>
then add the following plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>