I have 2 project in my eclipse work_space.
Project A:Source of Apache Tomcat by a little edit[and have some dependent jars].
Project B: A small project call one method[One method of project A's methods].
So when I used Project A in Project B(added to BuildPAth's projects) or test this method in project A that work. But When project B used exported project A's jar file DOESN'T Work(only remove project A from project B's BuildPath and add A's jar file).
Exception which throw is:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/util/FileUtils
at org.apache.jasper.JspC.resolveFile(JspC.java:1602)
at org.apache.jasper.JspC.setOutputDir(JspC.java:863)
at org.apache.jasper.JspC.setArgs(JspC.java:276)
at org.apache.jasper.JspC.main(JspC.java:241)
at jspCompiler.pars(jspCompiler.java:65)
at jspCompiler.main(jspCompiler.java:100)
at maintst.main(maintst.java:11)
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.util.FileUtils
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Where is problem?
EDIT
Maintst.java
import jspParser.jspCompiler;
public class maintst {
public static void main(String[] args) throws Exception {
jspCompiler cmp=new jspCompiler();
cmp.main(new String[]{"F:\\arshad droos\\Thesis\\secureBranch\\personalblog\\build","F:\\arshad droos\\Thesis\\secureBranch"});
}
}
Browsing the code of Apache Tomcat i could not find the find org.apache.tools.ant.util.FileUtils. Since running from eclipse works, this probably means is that Project A has some jar in the build path which has this file. Find it, put in in the build path of Project B and things should work.
Eclipse has a fatjar named plugin. After installing this jar to eclipse plugins(Copy past jar file to eclipse's plugin directory) In Export menu select jar fat. In this way size of exported jar is big But Standalone.
Thank you.
Related
I created maven project, I addded log4j2 dependencies to POM, and my project obviously can't import LogManager class. Why? That's output from maven console.
c:\Users\Dawid\Desktop\Pracbaza\my-project>java -cp target\my-project-1.0-SNAPSHOT.jar com.spica.project.App
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
at com.spica.project.App.<clinit>(App.java:7)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
you've added those dependencies to the pom, so maven knows that your project depends on log4j, but you're not executing maven right now. you're using the java executable to run your compiled code. java has no idea what a pom.xml is (since maven is an external tool).
you have several options:
list all of your dependencies in the cp argument, not just your jar. so java -cp target\your.jar;path\to\log4j2.jar;anything;else
list your dependencies in your jar file's MANIFEST.MF file. you can either list absolute paths (BAD IDEA) or file names and place your libs alongside your jar
package your jar as either jar-with-dependencies or onejar. that way it'll pack all the libs alongside your own code and will be able to find them. there is a difference between these 2 options that you better understand before you pick one.
This is because your log4j jar is not there in the classpath while running your code. Try adding the log4j jar in your classpath (in -cp switch).
I've been having troubles lately in creating a jar file that can call a secured web service on Weblogic server using Jdev.
I've created a web service proxy which is handling the situation perfectly. My goal is to deploy this web service as a jar file so that I can use it in my other projects as a simple library.
I was able to deploy the project as a jar file, which in turn allowed me to use it's different methods to connect to the web service.
However, when I run the web service client on eclipse I get an error:
Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/xml/crypto/wss/provider/CredentialProvider
at WebServiceCaller.callGetCardDetailJar(WebServiceCaller.java:55)
at WebServiceCaller.main(WebServiceCaller.java:29)
Caused by: java.lang.ClassNotFoundException: weblogic.xml.crypto.wss.provider.CredentialProvider
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
The problem may be fixed by finding the weblogic.jar file and including it in the eclipse build path, but is there a way to deploy a jar file with all the library dependencies included in it ?
There is a way to create a wlfullclient.jar (see oracle doc http://docs.oracle.com/cd/E13222_01/wls/docs103/client/jarbuilder.html ), but your class is not in it, it's rather in oracle.webservices.standalone.client.jar or in wls-api.jar or in weblogic.jar... it's rather confusing, I think Oracle never managed to simplify this jar dependency problem, actually in earlier versions of WebLogic things were a lot simpler!
I'm trying to use the apache http library in my project. I imported the libreries in my project http://imgur.com/WvwqcDS
When I run my program, I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpEntity
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpEntity
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
The ClassLoader can't find org.apache.http.HttpEntity, which should be inside "httpcore-4.3.jar". Open the jar as an archive and verify that it contains org/apache/http/HttpEntity.class. If it does, the issue is in your launch configuration. In Eclipse, go to Run > Run Configurations... and find the Java Application profile for your main class (which should be the class containing the main method in "Launcher" project, based on the screenshot). Under the Classpath tab, you should see your library jars listed.
If not, go back to your "Launcher" project in the Navigation pane, right-click and select Properties, go to "Build Path", remove your jars, press OK, then go back in and add them again (to guarantee the eclipse meta-data is fresh). Also, under the "Order and Export" tab, it's a good idea to check off all jars so that if you include Launcher as a dependency for another project, the jars are transitively included.
your Eclipse is having trouble locating the external jars, try importing them into your workspace or referencing them outside by using "add external jar's"
In my case Maven was not updating dependencies properly. I use mvn clean and then re-updated dependencies then it got fixed.
I have been searching the web for a while now and no solutions found have been working out for me. So, I turn to you.
I get a java.lang.NoClassDefFoundError when I try to integrate the API of BIRT (an eclipse plugin for reports and documents). I copy paste their code, include ALL of the jar file in the lib folder (birt-runtime-4_2_2\ReportEngine\lib) and still I get the NoClassDefFoundError. What am I doing wrong? I cant find any useful information on their page. Furthermore, I have tried out a couple of other source codes, yet I still get the same problem. So i would argue that the imports of the jar-files might be faulty. But I cannot for the love of God find the fault is.
The code I have copy pasted (just to try out) is found here:
http://wiki.eclipse.org/Java_-_Simple_Design_Engine_API_%28BIRT%29
The complete error message is this:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/Platform
at org.eclipse.birt.core.framework.jar.ServicePlatform.getExtensionRegistry(ServicePlatform.java:72)
at org.eclipse.birt.core.framework.jar.ServicePlatform.createFactoryObject(ServicePlatform.java:98)
at org.eclipse.birt.core.framework.Platform$1.run(Platform.java:297)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.birt.core.framework.Platform.createFactoryObject(Platform.java:293)
at org.eclipse.birt.report.model.api.DesignEngine.<init>(DesignEngine.java:90)
at org.eclipse.birt.report.model.api.DesignEngine.newSession(DesignEngine.java:142)
at standard.Main.main(Main.java:36)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.Platform
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 8 more
Except from Birt's jar files you will also have to copy some extra jars from Birt Runtime to Tomcat's WEB-INF folder.
Download Birt Runtime from the following link: http://download.eclipse.org/birt/downloads/
In Birt Runtime you will find a folder called ReportEngine. In this folder there is a lib folder. Just copy it to your WEB-INF folder.
I had a similar problem and it worked for me. Take a look at my problem: NoClassDefFoundError for Birt Class EngineException
I am attemping to add JUnit tests to my existing Eclipse 3.7.2 project and it seems like JUnit is not properly added to the project. I have attempting adding the JUnit jar manually. I have tried several other run configuration modifications that all result in the same error. New projects that I create also exhibit this error when I add a JUnit test.
java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/junit/runner/RemoteTestRunner
Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
Are you installing Eclipse to a directory to which you can't write? Windows 7 UAC can prevent certain files from being written, especially in C:\Program Files.... It's better to install Eclipse in a directory that you can write.
This could be caused by a classpath issue. First ensure that you definitely have the junit.jar in your build path.
In Eclipse Indigo: Go to “Package Explorer” right-hand click > ‘Build Path’ > ‘Configure Build Path’ > in the Libraries tab. There you should the junit.jar.
Generally creating the test case within Eclipse adds this jar to the build path.
The same exception could also occur if you have a build path conflict. Going to Window > Show View > 'Markers' shows you the problems with the project. (In my case there was a circular reference)