ADD JAR LIB TO CLASSPATH FOR TOMCAT

Hello,
I'am running a web application which also operates an automatic sending of mails.
When I run my files on Jbuilder all things are OK.
But when I test my application with Tomcat I have this error:
Error: 500
Location: /ApplicationXTS/servlet/net.projet.ControlCreateObject
Internal Servlet Error:
java.lang.NoClassDefFoundError: javax/mail/MessagingException
     at java.lang.Class.newInstance0(Native Method)
     at java.lang.Class.newInstance(Unknown Source)
     at org.apache.tomcat.core.ServletWrapper.initServlet(ServletWrapper.java:298)
     at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:445)
     at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:597)
     at org.apache.tomcat.servlets.InvokerServlet.service(InvokerServlet.java:257)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
     at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
     at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
     at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
     at java.lang.Thread.run(Unknown Source)
Thank you for your help.
F.S

It seem the required class files are not set in the tomacat classpath.im not sure which version of tomcat u are using.add the corresponding javamail jar files (including activation framework)in ur machine and set classpath accordingly.
HTH.

Similar Messages

  • Did u use jar files as classpath for appletviewer?

    as tested, jar files can not be used as classpath for appletviewer.
    java command is bellow
    appletviewer -J-classpath -Jc:\folder00\some.jar; -Jc:\folder01\any.jar; MyAppletClass
    the jar files (or classpaths) above do not work.
    I am not sure about my test, so i post my Q here for confirming it.
    thx

    appletviewer needs HTML code to run an Applet similar to how the Applet would be run from a browser. It does not have a Classpath option.
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/appletviewer.html

  • Set up the classpath for tomcat 5.0 to compile servlet

    I am totally confused how do you set up the class path, i use this command:
    c:\set CLASSPATH=.;C:\tomcat5.0\common\lib\servlet-api.jar;%CLASSPATH%
    and I compile my file which i put in j2sdk1.4.2_10\bin
    here is the command line:
    c:\j2sdk1.4.2_10\bin\servletexercise1.java
    and it gives me the error message to say that it can't find the servelt, javax.servlet.
    Please help! thanks in advance!

    I am totally confused how do you set up the class
    path, i use this command:
    c:\set
    CLASSPATH=.;C:\tomcat5.0\common\lib\servlet-api.jar;%C
    LASSPATH%I don't have a CLASSPATH environment variable on any machine that I work with.
    and I compile my file which i put in j2sdk1.4.2_10\binThat's a pretty stoopid place to put a Java source file. You shouldn't be putting any files in that directory.
    The right thing to do is to add the Java /bin directory to your PATH environment variable. When you do, make sure there are no spaces in the path name. (e.g., don't install Java to the "Program Files" directory) OR replace it with its 8-char DOS equivalent (e.g., c:\Progra~1).
    here is the command line:
    c:\j2sdk1.4.2_10\bin\servletexercise1.javaSorry, I don't see where you execute javac.exe.
    and it gives me the error message to say that it
    can't find the servelt, javax.servlet.
    Please help! thanks in advance!What is this telling you? That the javac.exe totally ignores the CLASSPATH that you set? (Hint: Right answer.)
    The correct way to do it is to use the -classpath option on javac.exe.
    %

  • How to config the CLASSPATH for Tomcat 4.0???

    I use a JavaBean in a JSP file. And I use this JavaBean to connect to Oracle. Database username and password is stored in a file named "db.properties". When I browse this JSP page, It report : Cant not find db.properties file!!!
    So I want know is where can I put this "db.properties"??Do I need config CLASSPATH or other para??
    need your help!!
    Thanks in advance!!!

    did you try to put it into the /lib/ directory of your webapplication ?
    I would solve this differently, I would create a servlet that takes initial parameters and puts them into the servlet context. then I would use that to put these information into the servletcontext.
    Then you would not have to load a properties file everytime u access the jsp pages that does the database related procedure.
    Maybe there is some place for system properties files, but this place I have not seen or how to work with it.
    I place my configuration files all under web-inf/config/ and then I mapp paths to it and read as the web application starts.
    hope it helps.
    -reynir

  • Some way to dynamically add jars to java classpath?

    I have a fixed directory that people might be adding jar files to. I do will not know what the jar files are named nor how many jar files there will be. I am wanting to be able to search this directory for all jar files & dynanically add these jar files to my class path in a peice of code I am writting so that I would be able to locate classes in them. Does anyone have any ideas on how to do this?
    Your help is much appreciated =)

    The URLClassloader probably has what you need. If not, you'll have to write you're own custom classloader... Not really that hard though.

  • How to add jar files to classpath?

    Never mind, I figured that out.
    Edited by: leoJones on Mar 25, 2008 8:29 PM

    If you want the jar file to be globally accessible, add it in the $J2EE_HOME/config/application.xml file like so:
    <library path="../test.jar" />
    Then drop the jar file in your $J2EE_HOME directory. This assumes you are manually configuring the OC4J server. I'm sure there is an equivalent way to do this from the Enterprise Manager web site.
    John H.

  • Configuring classpath in Tomcat 4.1.12

    Hi,
    I have an existing system which consists of JSP files and jars running on Tomcat 3.2.1 on Linux 6.1 platform. I have to upgrade it to Tomcat 4.1.12 on Red Hat Linux 8.0. However, now I am having problems in loading the jar files. Before the jars were under a different location than the Tomcat location as also the JSP files. and i used to simply run a script to load the jars on to the classpath, after i start the Tomcat server. However, now in the new system I am not being able to load the jars in the classpath. Tomcat simply won't find the jar files. How do I point Tomcat to the jar location? I would also like to mention here that I am being able to load the JSP files. In the context path, under server.xml, i am pointing the docbase to my application path. Is there any option to point to my classes also here?
    I am using a similar context path as below:
    <Host name="myapplication.com">
    <Context path=""
    debug="0"
    docbase="/home/opt/myapplication/myfiles"
    crossContext="true"
    reloadable="true"
    trusted="false"
    >
    Also I am not using WARs
    If somebody can suggest any solution it will surely be a great help.
    Thanking you in advance,
    Regards,
    Kaustuv Sharma

    or even put links to the jar files in .../common/libhi,
    so i put links to the jar files from common/lib in catalina.sh?
    coz, i tried this option by editing the catalina.sh file. But I got the following exception: "Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException"
    malcolmmc did u mean this?...or is there any other way where i put a link to my jar files in common/lib...?

  • Adapter jar file in classpath ?

    Hi All,
              Is it still a requirement to put the adapter jar file in classpath for the
              adapter developed using ADK in WLI2.1 and WLS6.1SP1 ?
              coz if I dont put it in the classpath, then its not able to find the message
              bundle files (.properties and .xml) !!
              Thanks
              Amit
              

    then i created a jar file named darshan.jar with following command :
    jar -xvf d:\darshan.jar darshan/*.classThat command doesn't create a .jar file, it extracts files from an existing one. You need to use c instead of x to create a new .jar file:
    jar -cvf d:\darshan.jar darshan/*.class

  • Add jar for in-memory compilation by Eclipse Compiler

    Hi,
    I have a question regarding loading a jar file by the compiler to dynamically compile with a source file. I hope someone can probably offer me an idea on what has been missing or wrong with the source codes I have written for my application.
    I am using Eclipse compiler to dynamically compile a class. In the class, I want it to make a reference to a jar file for compilation dynamically.
    Here is the source of a test class I wrote:
    import javax.servlet.http.HttpServlet;
    class MyServlet extends HttpServlet {
    }The import statement refers to the class javax.servlet.http.HttpServlet from the jar file C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar placed in the local file system.
    In the method called compileClass (shown below), I used the path of the jar file to add to the option -classpath as suggested in another thread (http://forums.sun.com/thread.jspa?threadID=5306520&start=0&tstart=0).
    private static CompileClassResult compileClass(Writer out, String className, String classSource) {
              try {
                   JavaCompiler javac = new EclipseCompiler();
                   StandardJavaFileManager sjfm = javac.getStandardFileManager(null, null, null);
                   SpecialClassLoader scl = new SpecialClassLoader();
                   SpecialJavaFileManager fileManager = new SpecialJavaFileManager(sjfm, scl);
                   List<String> options = new ArrayList<String>();
                   options.addAll(Arrays.asList("-classpath", "C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar"));
                   List<MemorySource> compilationUnits = Arrays.asList(new MemorySource(className, classSource));
                   DiagnosticListener<JavaFileObject> diagnosticListener = null;
                   Iterable<String> classes = null;
                   if (out == null) {
                        out = new PrintWriter(System.err);
                   JavaCompiler.CompilationTask compile = javac.getTask(out, fileManager, diagnosticListener, options, classes, compilationUnits);
                   boolean res = compile.call();
                   if (res) {
                        //Need to modify the api to return an array of two elements - one classes and other bytecodes for all classes in the same class file.
                        return CompileClassResult.newInstance(scl.findClasses(), scl.findByteCodes());
              } catch (Exception e) {
                   e.printStackTrace();               
              return null;
         }I also extended the class ForwardingJavaFileManager as suggested in the thread mentioned above and have it delegated to the StandardJavaFileManager sent to the compiler mentioned in the method compileClass above. The extended class (called SpecialJavaFileManager) is as follows:
    public class SpecialJavaFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> {
         private SpecialClassLoader xcl;
         public SpecialJavaFileManager(StandardJavaFileManager sjfm, SpecialClassLoader xcl) {
              super(sjfm);
              System.out.println("SpecialJavaFileManager");
              this.xcl = xcl;
         public JavaFileObject getJavaFileForOutput(Location location, String name, JavaFileObject.Kind kind, FileObject sibling) throws IOException {
              System.out.println("getJavaFileForOutput");
              MemoryByteCode mbc = new MemoryByteCode(name);
              xcl.addClass(name, mbc);
              return mbc;
         public Iterable<JavaFileObject> list(JavaFileManager.Location loc, String pkg, Set kinds, boolean recurse) throws IOException {
              System.out.println("list ");
            List<JavaFileObject> result = new ArrayList<JavaFileObject>();
            for (JavaFileObject f : super.list(loc, pkg, kinds, recurse)) {
                 System.out.println(f);
                result.add(f);
              return result;
    }I run the application and the result shows that it didn't load the jar file into the memory as expected. From the output (below) I got, it doesn't seem to invoke the method list(...) in the class SpecialJavaFileManager.
    SpecialJavaFileManager
    1. ERROR in \MyServlet.java (at line 1)
         import javax.servlet.http.*;
                ^^^^^^^^^^^^^
    The import javax.servlet cannot be resolved
    2. ERROR in \MyServlet.java (at line 3)
         class MyServlet extends HttpServlet {
                                 ^^^^^^^^^^^
    HttpServlet cannot be resolved to a typeDoes somebody know what I probably have missed or done wrong in the codes?
    Thanks.
    Jonathan

    Hi jschell,
    I read the thread referred to by the link you gave and tried to add the path using the setLocation method:
    JavaCompiler javac = new EclipseCompiler();
    StandardJavaFileManager sjfm = javac.getStandardFileManager(null, null, null);
    SpecialClassLoader scl = new SpecialClassLoader();
    List<File> path = Arrays.asList(new File("C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar"));
    sjfm.setLocation(StandardLocation.CLASS_PATH, path);
    SpecialJavaFileManager fileManager = new SpecialJavaFileManager(sjfm, scl);After I run the file with the change, I still didn't get the compiler to read the jar the file.
    Anyone knows how to solve this issue?
    Thank you.
    Jonathan

  • Add JARs to classpath within Java

    I've read through a number of different posts on this topic, but can't seem to get my code working.
    I want to write a class that will run embedded Tomcat. For certain reasons, I can't set the
    classpath to Tomcat before my class gets called, so I want to locate the Tomcat JARs, add them
    using a ClassLoader and then call the appropriate classes to setup and run Tomcat. An
    exception is being thrown, so I'm doing something wrong. Any ideas?
    Here's the code I'm trying to add the JARs with:
    String mcatHome = "tomcat/lib"
    try {
         // Scan folder for JARs and build URL array
         File mcatDir = new File(mcatHome);
         File files[] = mcatDir.listFiles(new JarFilter());
         URL jarURLs[] = new URL[files.length];
         for (int i = 0; i < files.length; i++)
              jarURLs[i] = files.toURL();
         // Add list of JARs to class loader
         URLClassLoader ucl = new URLClassLoader(jarURLs);
         // Use loader when loading classes
         Thread.currentThread().setContextClassLoader(ucl);
    catch (Exception ex) {
    then I call the contructor on the class which tries to start Tomcat:
         public void Mcat()
              startTomcat();
         protected void startTomcat()
              Embedded embed = new Embedded();
    When the constructor is invoked, I get:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/catalina/L
    ifecycleException

    jschell, the list of JARs is generated from listing them in the folder. I did print the list out and
    the URLs looked ok. (i.e. file:/....)
    Here a snippet of how the class calling is setup:
    In Runner.java:
    public void Runner()
         //code from original post to load JARs
         Mcat mcat = new Mcat()
    In Mcat.java:
    import org.apache.catalina.*;
    import org.apache.catalina.logger.*;
    import org.apache.catalina.users.*;
    import org.apache.catalina.realm.*;
    import org.apache.catalina.startup.Embedded;
    public class Mcat
        public void Mcat()
            startTomcat();
        protected void startTomcat()
            Embedded embed = new Embedded();
    }Hope this helps

  • Classes+resources in JAR: have to add each single Jar file to CLASSPATH?

    Hello,
    For my application, I plan to easily embed plugins that can be added by the user by copying it into a subfolder "plugins".
    Now, I start my app from a shellscript and in order to load resources from within some of these Jars (e.g. using Class.getResourceAsStream() ), it only works if I explicitly add the specific Jar filename to the classpath from the shellscript.
    I read in a German Java book, that also just using folder names is enough, but it does not work for me:
    Works:
    $JAVA_HOME/bin/java -Djava.library.path="./lib" -classpath "./lib:./plugins/test.jar" test.AppFails:
    $JAVA_HOME/bin/java -Djava.library.path="./lib" -classpath "./lib:./plugins/" test.AppIs it really required to add Jars explicitly, so that e.g. my shellscript has to make a Jar listing of that folder in order to pass them as classpath files?
    Thanks and regards,
    Timo

    No, you don't have to do it that way. What you need
    to do is to have your progam create a URLClassLoader
    pointing to all the jars in the plugin directory.
    Then request your plugin classes from that, rather
    than Class.forName();
    You need to create an array of file URLs for the
    jars, use File.listFiles() and then File.toURL() on
    each ..jar you find.
    p.s. If you do it this way make sure your plugin
    classes are not on the classpath.
    Hmm. Cool. I had no idea. Thanks for correcting me.

  • Classpath in tomcat.bat for jdbc driver (jsp page)

    Dear Friends,
    I am able to run my java program with Microsoft JDBC driver from console (dos prompt).
    But, when i am trying to run JSP program on browser using, the same driver, it is saying classNotFoundException().
    do i need to set the classpath for Microsoft jdbc driver in my tomcat.bat ?
    Please help me, what changes do i have to do in tomcat.bat to run the microsoft jdbc driver for jsp application.
    If anyone having idea, please share ur valuable ideas.
    thanks in advance.
    yours
    Rajesh
    [email protected]

    If the driver is packed in a jar-file, you can just place the jar in the lib directory of Tomcat. If it's not, you can pack it in a jar and do the same thing:)

  • Do I always need to add .JAR to ClassPath?

    My platform is Windows.
    I pack my .class files to a .Jar file. When I want to use this .Jar, I always have to add it to ClassPath. I think it doesn't make sense. Does anything I can do that can make me use .Jar more convenient ?
    Thanks

    Can you elaborate more?
    If you create an app and jar up all of the .class files in jar called myJar.jar for example, and then want to run that app, you just type in "java -jar myJar.jar" and its' not necessary to have myJar.jar in the classpath. (Remember to add a manifest with the Main-Class attribute defined! See java tutorial for more info on executable jars...)
    If, otoh, you have a bunch of classes in a jar, and then want to refer to those classes from some other external class(es)/jar(s), then yes, you'll need to add that jar to your classpath.
    -Ron

  • Classpath for jar files?

    Hi all,
    i am trying to run a standalone java program using JRC through command promt.
    my problem is i am importing few classes from jar files into my java class. but its not getting imported.
    how to resolve it?

    Hi Saravana
    You can use batch file to run your standalone java program.
    The contents of the batch file would be as follows:
    @echo off
    if "%OS%" == "Windows_NT" setlocal
    rem
    rem Sets the CLASSPATH environment variable to include all JAR files
    rem required for the JRC then compiles and jars Java file(s).
    rem
    rem Edit the environment variable BOBJ_JAVA_LIB to point to the
    rem location where you have the JRC jar files.
    rem
    rem Make sure to define any other required libraries in the environment
    rem variable CLASSPATH.
    rem
    rem Make sure you have defined the environment variable JAVA_HOME
    rem
    set BOBJ_JAVA_LIB=c:\Program Files\Business Objects\Common\3.5\java\lib
    set CURRENT_DIR=%cd%
    echo Using JAVA_HOME: %JAVA_HOME%
    echo Using CURRENT_DIR: %CURRENT_DIR%
    set RUNJAVA="%JAVAHOME%/bin/java"
    set RUNJAVAC="%JAVAHOME%/bin/javac"
    set RUNJAR="%JAVAHOME%/bin/jar"
    set CLASSPATH=%BOBJ_JAVA_LIB%\ReportViewer.jar;%BOBJ_JAVA_LIB%\ReportPrinter.jar;%BOBJ_JAVA_LIB%\CrystalCommon.jar;%BOBJ_JAVA_LIB%\CrystalDatabaseConnectors.jar;%BOBJ_JAVA_LIB%\CrystalReportingCommon.jar;%BOBJ_JAVA_LIB%\CrystalFormulas.jar;%BOBJ_JAVA_LIB%\CrystalQueryEngine.jar;%BOBJ_JAVA_LIB%\CrystalReportEngine.jar;%BOBJ_JAVA_LIB%\keycodeDecoder.jar;%BOBJ_JAVA_LIB%\MetafileRenderer.jar;%BOBJ_JAVA_LIB%\rpoifs.jar;%BOBJ_JAVA_LIB%\jrcerom.jar;%BOBJ_JAVA_LIB%\jrcadapter.jar;%BOBJ_JAVA_LIB%\rascore.jar;%BOBJ_JAVA_LIB%\rasapp.jar;%BOBJ_JAVA_LIB%\Serialization.jar;%BOBJ_JAVA_LIB%\external\log4j.jar;%BOBJ_JAVA_LIB%\external\icu4j.jar;%BOBJ_JAVA_LIB%\external\Concurrent.jar;%BOBJ_JAVA_LIB%\external\xercesImpl.jar;%BOBJ_JAVA_LIB%\external\xml-apis.jar;%BOBJ_JAVA_LIB%\CrystalCharting.jar;%BOBJ_JAVA_LIB%\CrystalContentModels.jar;%BOBJ_JAVA_LIB%\CrystalExporters.jar;%BOBJ_JAVA_LIB%\CrystalExportingBase.jar;%CURRENT_DIR%;%CLASSPATH%
    %_RUNJAVAC% -classpath "%CLASSPATH%" *.java
    %_RUNJAVA% -classpath "%CLASSPATH%" HelloWorldSwing
    // HelloWorldSwing is the name of your .java file
    Make sure you have all the jar files in the lib directory.
    Hope this helps you.
    Thanks
    Soni

  • Help Nedded on how to add JavaMail.jar and JAF.jar to my classpath

    Hello.. please i want to add these two packages JavaMail.jar, and JAF.jar to my classpath.
    Can anyone show me how to do this?, if possible some example.
    Thanks.

    Hi!
    Just copy them into the %JAVA_HOME%/jre/lib/ext folder.
    Or...
    Add them to your classpath as:
    java -cp <path to your jar files>/mail.jar;<path to your jar files>/jaf.jar;. YourApp
    Hope this helps.

Maybe you are looking for

  • Upgrade to OS 10.9.4 and having multiple issues

    I upgraded to OS 10.9.4 and now Mail will not open, says it needs to rebuild index but it won't. I get ICloud password prompt and when I try to connect it says there are problems opening Icloud pane. After reading other questions I went in to Console

  • Calendar in yosemite

    Im using Yosemite 10.10.1/iMac 21,5 inch,late 2009 Calendar: in the "year" view i see all month and days weeks fine. But the weeks number are wrong. For example, in June 2014, I see beside of each week, the number 2, same as July in August the number

  • How to add a Font Button in the Top of the Help File

    Dear all, In some of the Help Files (HTML Help), i've seen a Font button being added in the top of the Help File (for e.g next to Home button)...when we click this font button, the font size of the Content present in the Help File Increases/decreases

  • Ipod won't sync to music files on external harddrive

    I have too many music files to keep on my computer, so I 've got them on an external (E) drive. Itunes has no problem with that. I have my Library file on the computer (C drive) and the music files on the E drive. When I want to use Itunes to play a

  • HP C410B Photosmart all-in-one - I can't access the printer's web server

    This printer is working OK as a printer via its network connection and I can see it on the network when I do a scan. I can also 'ping' the printer OK. However I can't connect to its web server for configuration or to start a scan from the computer et