0

I used the maven assembly package to create a single monolithic jar. Included is the datanucleus package, but I am getting errors because I did not maintain the OSGI structure (plugins.xml & META-INF/META-INF.MD). The answers on stackoverflow([question]: Datanucleus, JDO and executable jar - how to do it?) do not provide answers on how to create the single deployable jar.

Does anyone know what maven directives I can use to ensure OSGI structure?

Community
  • 1
  • 1
kungfoo
  • 597
  • 5
  • 16

1 Answers1

1

So, the problem is that packing everything into a monolithic jar is that the OSGI structures get overritten by the OSGI structure of other jars. The benefit of the monolithic jar was to have a single file to push to the server but not necessary (since I was using capistrano to push to the server)

Instead, it's easier to just copy the jars into the final build directory. Heroku's Java setup has a perfect example of this:

https://devcenter.heroku.com/articles/java

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>helloworld</artifactId>
<dependencies>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-servlet</artifactId>
        <version>7.6.0.v20120127</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals><goal>copy-dependencies</goal></goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>
kungfoo
  • 597
  • 5
  • 16
  • The right answer! People are sometimes very keen to create these monolithic jars (sometimes called uberjars), but there are all sorts of pitfalls associated with this. If you can deploy as separate jars (or as many jars packed into a container such as a WAR), that's a much better way to do it. – Tom Anderson Oct 14 '12 at 22:51