0

I generate jar file with maven-assembly-plugin plugin. I use java -jar to execute jar. I got error message:

log4j: WARN JmDNS or serviceInfo not found

I tried to use path to jar in -classpath, but got same error.

Plugin configuration:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
            <execution>
                <id>make-assembly</id>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <archive>
                <manifest>
                    <mainClass>test.LeanFTest</mainClass>
                </manifest>
            </archive>
            <finalName>${project.artifactId}-fatjar-${project.version}</finalName>
            <appendAssemblyId>false</appendAssemblyId>
            <descriptors>
                <descriptor>src/main/assembly/leanft-assembly.xml</descriptor>
            </descriptors>
        </configuration>
    </plugin>
plaidshirt
  • 5,189
  • 19
  • 91
  • 181

1 Answers1

1

Most likely, this boils down to:

  • Your maven build does not include dependent artefacts into your JAR file. In other words: the JAR you create does not include the logj4 JARs. You can change that with your maven config, see here for details.
  • As your JAR doesn't contain the dependencies, all JARs you depend on must be in your classpath. Meaning: when you run your new JAR on the command line, all elements that might be required for running it must be present on the classpath.
GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • Dependencies are included in this jar file, but I already tried to use path to log4j jar file in classpath. – plaidshirt Jul 02 '18 at 07:44
  • How can they be included when the maven config your are showing isn't written to include them? – GhostCat Jul 02 '18 at 07:53
  • I use two plugins to generate jar. Another one is `maven-jar-plugin`. I have two jars generated, 60 KB and 16 MB, but all the jars are copied to a `lib` named folder. – plaidshirt Jul 02 '18 at 08:02