java - Problems with Eclipse adding referenced jars to exported jar file -


I want to create a JAR file from a Meven Java project and it wants to add as external jar file in another project I am However I am receiving a NoClassDefFoundError error.

  thread "main" java.lang.NoClassDefFoundError exception: org / slf4j / LoggerFactory on com.tutelatechnologies.dashboard.DataUsageLogs.Logging.getlogger (Logging.java:10) on com.tutelatechnologies java.lang.ClassNotFoundException: .dashboard.DataUsageLogs.Logging.d on com.tutelatechnologies.dashboard.DataUsageLogsRunner.DUL_TESTER.main (Logging.java:26) org.slf4j.LoggerFactory in Java due to (DUL_TESTER.java:11) on .net.URLClassLoader $ 1.run java.net.URLClassLoader.findClass on java.net.URLClassLoader $ 1.run (URLClassLoader.java:355) (URLClassLoader.java:366) java.security.AccessController.doPrivileged (Native method on) on java.lang.ClassLoader.loadClass (java.lang.ClassLoader.loadClass in classloader (ClassLoader.java:423) sun.misc.Launcher $ AppClassLoader.loadClass (Launcher.java:308) (URLClassLoader.java: 354). Java: 356) ... 3 More   

jar file is very simple, it only includes wrappers for logging with Log4J and SLF4J I have it blow:

  import org. Slf4j.Logger; Import org.slf4j.LoggerFactory; Public class logging {public zero E (string msg, class input class) {logger log = loggerfiner Tag (input class); Logs.error (msg); } Public Zero (string message, class input class) {logger log = loggerfinor.logger (input class); Logs.warn (msg); } Public Zero D (String Message, Class InputClass) {Logger Log = Logger Factor Tag (input class); Logs.debug (msg); } Public Zero T (String Message, Class InputClass) {Logger Log = Logger Factor Tag (input class); Logs.trace (msg); }}   

Now I right-click this project, export - & gt; Java - & gt; Click the jar file then click Exclude all selected folders.

Then I go to my new project by right-clicking the jar file on my project, Build Path- & gt; Select Select. Configure Build Path then in the Library tab I click on the "Add external jar" button and link it to my jar file. I add my source code and a Javadock so that I can link it correctly. It looks fine, but when I run it, I get a nochlas defound error. The reason for this is that in eclipse dependency the jar does not seam to add the file.

If I add this project to the Java Build path then I can get it to work. But I want it to be a self-contained jar file. It separates when it is logarithtitter. Runs the MetLogger (InputClass); Which is looking for slf4j dependency

The following line is the only line used for this test. logging d. ("Exam", thisClass.class);

Can all dependencies be packed into a single jar file and is it properly linked?

FYI, I have tried to make it a runner jar, which works fast to work but then the jar file does not know how to link to the log4j.properties file. This file is located in src / main / resources

Any help is appreciated.

Cheers,

"itemprop =" text ">

It looks like a missing jar, not just SLF4J , Rather your code is Based on your folder structure it seems that you are using Maven, is it possible that you have only the Slaf 4 J-API only marked as Test Dependency? You actually need that one against (ie, marked as a compilation dependency), but various plug-ins such as logback-classic or whatever you are using. Test dependency may be, P>

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -