C R
C R

Reputation: 2242

How to turn off warnings on application load from one-jar executable?

I am using sbt with the one-jar plugin, but when I run the one-jar executable that has been created I get a continuous stream of messages that look like the following:

JarClassLoader: Warning: net/liftweb/json/Formats$$anon$4.class in lib/lift-json_2.9.2-2.5-M3.jar is hidden by lib/lift-json_2.9.1-2.4.jar (with different bytecode)
JarClassLoader: Warning: net/liftweb/json/JsonParser$BoolVal$.class in lib/lift-json_2.9.2-2.5-M3.jar is hidden by lib/lift-json_2.9.1-2.4.jar (with different bytecode)
JarClassLoader: Warning: net/liftweb/json/TypeInfo.class in lib/lift-json_2.9.2-2.5-M3.jar is hidden by lib/lift-json_2.9.1-2.4.jar (with different bytecode)
JarClassLoader: Warning: net/liftweb/json/Meta$$anonfun$mappingOf$1.class in lib/lift-json_2.9.2-2.5-M3.jar is hidden by lib/lift-json_2.9.1-2.4.jar (with different bytecode)

I tried passing parameters to the jvm as suggested in a couple of the responses to one-jar remove verbose warning information on application load, but I continue to get the annoying warnings.

How does one turn-off these warnings when using sbt-onejar?

I am using the most recent version of sbt-onejar.

Upvotes: 1

Views: 646

Answers (1)

Jacek Laskowski
Jacek Laskowski

Reputation: 74759

tl;dr There's no easy way to turn the messages off since they come from System.err.

I know little about the plugin so I unzipped the JarClassLoader class as follows:

jar -xf src/main/resources/one-jar-boot-0.98.jar src/com/simontuffs/onejar/JarClassLoader.java

In the class, at line 998 there's the call to WARNING method:

if (!Arrays.equals(existing.bytes, bytes) && !name.startsWith("META-INF")) {
    // TODO: this really needs to be a warning, but there needs to be a way
    // to shut it down.  INFO it for now.  Ideally we need to provide a 
    // logging layer (like commons-logging) to allow logging to be delegated.
    if (name.endsWith(".class")) {
        // This is probably trouble.
        WARNING(existing.name + " in " + jar + " is hidden by " + existing.codebase + " (with different bytecode)");
    } else {
        INFO(existing.name + " in " + jar + " is hidden by " + existing.codebase + " (with different bytes)");
    }
} else {
    VERBOSE(existing.name + " in " + jar + " is hidden by " + existing.codebase + " (with same bytecode)");
}

The method WARNING is implemented as follows:

protected void WARNING(String message) {
    System.err.println(PREFIX() + "Warning: " + NAME() + message); 
}

It's led me to claim that turning it off is impossible (unless you can shut down the entire System.err that I don't know being possible).

Upvotes: 1

Related Questions