File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Creating manifest.mf file with class-path entry without version info. (am using mvn jar:jar) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Creating manifest.mf file with class-path entry without version info. (am using mvn jar:jar)" Watch "Creating manifest.mf file with class-path entry without version info. (am using mvn jar:jar)" New topic
Author

Creating manifest.mf file with class-path entry without version info. (am using mvn jar:jar)

Jeevan Sunkersett
Ranch Hand

Joined: Jul 03, 2007
Posts: 75
Hi,

I am using maven 2.0.9 as a build tool. To build a jar from my code, I use the maven command

c:\>mvn jar:jar



This creates a jar file with a manifest.mf within.
But, the class-path entry that I get in the manifest.mf is in maven style,

In manifest.mf getting:
Class-Path: xstream-1.2.2.jar annogen-0.1.0.jar mina-core-1.1.5.jar jdom-1.0.jar backport-util-concurrent-1.4.jar

Is there any setting for the maven plugin, which can strip out the version info, and build the jar with manifest.mf with version info stripped out

In manifest.mf the Class-Path is desired as

Class-Path: xstream.jar annogen.jar mina-core.jar jdom.jar backport-util-concurrent.jar


~g1
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

What's complaining about this?

In manifest.mf expected:
Class-Path: xstream.jar annogen.jar mina-core.jar jdom.jar backport-util-concurrent.jar

The versioning info should be OK.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Jeevan Sunkersett
Ranch Hand

Joined: Jul 03, 2007
Posts: 75
Yes Martijn,

You are right, even with versioning it should be okay.

However in my scenario, the jar is part of a EAR.

Used and executed, as j2EE dependeny, by the web application; deployed in side of gerinomo. (all business logic exists in the .jar)

But a requirement exists, to execute business logic via a cron scheduler; using java -jar ApplicationBizLogic.jar

When the maven build prepares the EAR and deploys it on gernimo, all shared libraries/ jars in <APP-SERVER>\shared\lib are without the version info;
while the manifest.mf in the ApplicationBizLogic.jar has version info in the Class-Path

and so cannot be executed using java -jar ApplicationBizLogic.jar.

So my query, on how to strip out version-info, in the maven jar plugin.

~g1

Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I think your cron job should execute the properly versioned Jar , I'm not sure how you can strip out the version info.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

I'm unclear on what you're actually doing, but here's what you need to be doing, anyway:

1. Make a Maven project for the executable JAR with the backend business logic in it.

2. Make a Maven project for the EAR. The executable JAR should be a dependency.

Also note that a stock executable JAR isn't like a WAR or EAR where you can throw dependent JARs into the primary JAR file and have them found by the classloader. So you either have to explode all the library JARS then add them to the primary structure of the executable JAR or you have to explicitly add a classpath to the execution command line and forgo the "java -jar" mode of execution.

There is a Maven plugin that gets around that - I think it adds a custom classloader to the executable JAR. It also produces a stock JAR without the embedded dependent jars and classloader, which is probably going to be what the EAR dependency pulls.

Another approach, which I've done is to make the business logic be an RMI server and have the webserver invoke it. You could turn that inside out and make the business logic be EJBs, but I'm considering that the reason you have a cron invocation is that there's probably some heavy-duty processing going on that you don't want to inflict on the appserver. In my case, about 4 million transactions had to be run and each transaction was fairly hungry.

Depending on the coupling, an ESB-style approach might be worth considering, too.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating manifest.mf file with class-path entry without version info. (am using mvn jar:jar)
 
Similar Threads
Problems in making an executable jar file thru Maven
pom.xml for maven2 users
FATAL ERROR:The PluginDescriptor for the plugin Plugin [org.jvnet.jaxb2.maven2:mavenjaxb2-plugin]
JBOSS DeploymentException : Not able to find module file : .war in a .ear file
yet another question regarding creating a runnable jar with Eclipse/Maven