14

I am using Maven, with the one-jar pluggin, but when I run the one jar executable, I'm greeted with a wall of warnings, this is unacceptable for use

I've looked at every available resource on one-jar and see no instruction on how to keep the jar for spewing out tons of warnings when run, has anyone solved this?

JarClassLoader: Warning: META-INF/LICENSE.txt in lib/commons-io-1.4.jar is hidden by lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning: META-INF/NOTICE.txt in lib/commons-io-1.4.jar is hidden by lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning: META-INF/LICENSE.txt in lib/commons-lang-2.4.jar is hidden by lib/commons-collections-3.2.1.jar (with different bytecode)
JarClassLoader: Warning: META-INF/NOTICE.txt in lib/commons-lang-2.4.jar is hidden by lib/commons-collections-3.2.1.jar (with different bytecode)
walnutmon
  • 5,873
  • 7
  • 42
  • 57
  • 2
    I doubt the warnings are related to onejar. It might be related to the jars packaged within the uber-jar. Care to update the question with the warnings that you observe? – Vineet Reynolds Sep 07 '10 at 22:27
  • I've added warnings that I'm talking about, I've done a lot of googling and haven't found anyone complaining of something similar, the application runs fine, but as a console app which I run with arguments from the jar, having hundreds of lines scrolling my console before the app runs is distracting and unwanted – walnutmon Sep 08 '10 at 11:43
  • I do believe this is onejar, http://www.koders.com/java/fid47EFFE76AC8A4DF788B368D79D29DFE89BE94A19.aspx?s=ByteCode#L122 shows the source code to the JarClassLoader, which is in a onejar package, it has the print statements that I see here. What kind of distributed java library uses system.out these days? – walnutmon Sep 08 '10 at 11:46
  • @walnutmon, why you don't put flag on the right answer? – CAMOBAP Feb 13 '14 at 14:19

9 Answers9

10

I found that if you create a one-jar.properties file and put it in the root of your runtime classpath (ie, where your project .class files end up), it will be read by the one-jar Boot class. An entry in this properties file such as:

one-jar.silent=true

will suppress the one-jar log messages altogether.

Other values that the Boot class looks for are one-jar.info and one-jar.verbose.

The default level is INFO. As Pascal Thivent indicated above, you can also set a System property via the command line with the -D parameter of the java command, but if you do not want to have to stipulate or remember this, the properties file approach works great.

praseodym
  • 2,134
  • 15
  • 29
Jim S.
  • 101
  • 1
  • 2
8

It seems that these messages are printed when running in "verbose" mode. What I don't get is that the verbose mode doesn't seem to be activated by default.

Anyway, could you try to set the one-jar.verbose system property to false when running your one-jar:

java -Done-jar.verbose=false -jar <one-jar.jar>
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • I've looked very deeply into this problem, you're absolutely correct, unfortunately the state of this project is that the maven plug-in doesn't allow you to specify the version of the dependent code, so the source you see isn't the actual source that is executed by the plugin... someone needs to recreate this plug-in the right way because there are problems in the source versions that are included that have been fixed, but there is no way to get to them through maven. I ended up getting an old version to avoid these very annoying system outs, but then spring stuff is broken, so pick my poison – walnutmon Sep 09 '10 at 17:59
  • 2
    The `java -Done-jar.verbose=false -jar ` trick doesn't work for me. – Withheld Mar 28 '14 at 17:48
3

Regarding the latest-and-greatest One-Jar v0.97: The problem is there. The 'one-jar.properties' file actually needs to be put into the root of the final jar. It will, of course, have one line that reads, one-jar.silent=true. This can be done in Ant by setting something like <fileset dir="${build.dir}" includes="**/*.properties" /> inside the <one-jar ...> task.

It can also, just as easily, be placed into the command line using the java -Done-jar.silent=true -jar foo-jar-made-by-one-jar.jar command.

Nevertheless, it will still report a single line that it's loading properties from the One-Jar internal Boot class before going quiet. There is no way to get around this without changing source code starting at line 317 in Boot.java where the method initializeProperties logs the loading/merging operations. See Bug ID 3609329 at SourceForge in the One-Jar bug tracker where I provided the quick fix.

Summary: By adding the one-jar.properties file all but one line of extraneous logging is removed. This should help Maven users find a workaround.

ingyhere
  • 11,818
  • 3
  • 38
  • 52
1

I found I needed to use version 1.4.5 (1.4.4 did not work) and then the suggestion to place a one-jar.properties file at the root of my jar file with a single line reading one-jar.silent=true worked for me.

1

This is much better in the new version of the Maven one-jar plugin.

Add the plugin repository:

    <pluginRepository>
        <id>one-jar</id>
        <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
    </pluginRepository>

and use version 1.4.4 in the plugin definition.

Inigo
  • 41
  • 3
  • I will have a need for one-jar in the very near future, when I do use it I will try what you've added above and if it works accept your answer. Thanks! – walnutmon Mar 07 '12 at 14:04
  • I'm using version 1.4.4, but seeing the same warning message. What version of one-jar are you specifying (e.g. `0.97`)? – Vidar S. Ramdal Dec 04 '12 at 19:41
0

There's two places to get the one-jar plugin from.

  1. https://github.com/jolira/onejar-maven-plugin
  2. http://code.google.com/p/onejar-maven-plugin/

The 1st one claims to be just a copy of the 2nd one that's served from Maven's main repository. I was encouraged to use this one as it doesn't require specifiying an additional plugin repository that the 2nd one requires. However, when I switched to use the 2nd one (the official one), this problem went away for me.

Note - passing -Done-jar.verbose=false worked for me but not when set in file one-jar.properties as someone stated above.

Javateer
  • 11
  • 1
0

I submitted a patch for this quite some time ago that merely makes the default behavior silent.

    public static final int LOGLEVEL_VERBOSE = 5;

    // Loglevel for all loggers.
 -  private static int loglevel = LOGLEVEL_INFO;
 +  private static int loglevel = LOGLEVEL_NONE;

    private final String prefix;

AFAIK, it never got applied. Recently I fixed another issue, so I put my fixes out here:

https://github.com/nsoft/uno-jar

Please Re-read the "as is, no warranty" part of the license several times :)

Gus
  • 6,719
  • 6
  • 37
  • 58
0

I upgraded fromr 1.4.3 to 1.4.4 as someone suggested before and that made the deal

-1

There is no way to do this without modifying the source code

walnutmon
  • 5,873
  • 7
  • 42
  • 57