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

Similar Messages

  • Setting classpath within java application

    Hi
    Sorry if this question has already been asked, I've searched for it but couldn't find it.
    I've written a class (see below) that when given a directory will add all of the jar files to the classpath.
    The classpath is updated to include all of the jar files but if I try to use a class within one of these jar files then an exception is generated stating that the class can't be found.
    Can anyone help me with this problem? I thought that I would only need to update the classpath.
    Thanks,
    Rob
    public class Jar {
         public static void addJarsToClasspath(String root) {
              File f = new File(root);
              if (f.exists()) {
                   File[] jars = f.listFiles(new FilenameFilter(){
                        public boolean accept(File dir, String file) {
                             return ((String)dir.getName()+file).endsWith(".jar");
                   String classpath = System.getProperty("java.class.path");
                   for (int i=0; i<jars.length; i++) {
                             classpath = classpath.concat(":"+root+"/"+jars.getName());
                   System.setProperty("java.class.path",classpath);
                   System.out.println(System.getProperty("java.class.path"));

    You can do this with batch files in Windows NT/2000:
    1) create a batch file called "setcp.bat" containing the following:
    for %%i in (C:\myPath\*.jar) do call appendcp.bat %%i
    2) create another batch file called "appendcp.bat" containing the following:
    set CLASSPATH=%CLASSPATH%;%1
    Now you can run setcp.bat and it will add all JAR files in C:\myPath to your CLASSPATH.
    Jesper

  • 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

  • How to add jar files  classpath in sun stdio creator

    Hi,
    i am using log4j-1.2.13.jar in my application.
    how to add it to my classpath in sun stdio.
    with regards
    shannu sarma

    Hi there,
    These threads will answer your question
    http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=61842
    http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=56060
    Thanks
    K

  • Jars on classpath within webservice?

    Hi. I've created a web service using apache axis. I am having a problem getting my external classes on the classpath of my web service.
    import com.mycompany.MyClass
    public class MyService{
      static {
        MyClass.initialize();
      public String myServiceMethod(){
    }When i deploy on weblogic 9.2 i get:
    weblogic.application.ModuleException: [HTTP:101216]Servlet: "AxisServlet" failed to preload on startup in Web application: "mywar.war".
    java.lang.ExceptionInInitializerError
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:242)
            at org.apache.ws.java2wsdl.SchemaGenerator.<init>(SchemaGenerator.java:121)
            at org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:306)
            at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:339)
            at org.apache.axis2.deployment.DeploymentEngine.populateService(DeploymentEngine.java:340)
            at org.apache.axis2.deployment.DeploymentEngine.loadServicesFromUrl(DeploymentEngine.java:181)
            at org.apache.axis2.deployment.WarBasedAxisConfigurator.loadServices(WarBasedAxisConfigurator.java:264)
            at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:74)
            at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:486)
            at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:406)
            at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:276)
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
            at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
            at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:68)
            at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
            at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
            at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:504)
            at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1698)
            at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1675)
            at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1595)
            at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2734)
            at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:892)
            at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:336)
            at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
            at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
            at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
            at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
            at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
            at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
            at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
            at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
            at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:26)
            at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:641)
            at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
            at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:229)
            at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154)
            at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
            at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:565)
            at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:136)
            at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:104)
            at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:320)
            at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:815)
            at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1222)
            at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:433)
            at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:161)
            at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeli
    verer.java:181)
            at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.
    java:12)
            at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:
    67)
            at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
            at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
            at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class Not found : com.mycompany.MyClass
            at org.apache.axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:88)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at com.mycompany.MyService.<clinit>(Unknown Source)
            ... 52 more
    Caused by: java.lang.ClassNotFoundException: Class Not found : com.mycompany.MyClass
            at org.apache.axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:84)
            ... 56 more
            at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:894)
            at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:336)
            at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
            at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
            at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
            Truncated. see log file for complete stacktrace
    java.lang.ClassNotFoundException: Class Not found : com.mycompany.MyClass
            at org.apache.axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:84)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at com.mycompany.MyService.<clinit>(Unknown Source)
            Truncated. see log file for complete stacktraceI believe the error is occurring when Axis loads the service class and the static block is executed. ie - <clinit>.
    MyClass lives in a packaged jar - myjar.jar. How do I get myjar.jar on the runtime classpath of MyService?
    I've tried placing myjar.jar in the WEB-INF/lib folder of the axis war, as well as packaging it in the .aar of MyService
    Thanks!

    bump.
    anybody have any ideas on this?

  • How to Add JAR files and Config files to CLASSPATH at runtime?

    QUERY:
    During runtime, I need to load the JAR files and relevant config files( .cfg files and .properties file) into CLASSPATH and run a specific java program from one of the JAR which is available in CLASSPATH.
    Please advise me any relevant Java API details or a sample java program to implement the above use case.
    Thanks in advance.

    During runtime, I need to load the JAR files and relevant config files( .cfg files and .properties file) into CLASSPATH and run a specific java program from one of the JAR which is available in CLASSPATH.
    Please advise me any relevant Java API details or a sample java program to implement the above use case.
    You don't add to YOUR classpath once your app is launched.
    You create a NEW process for the app you want to run and provide the proper environment for it to run in - including any PATH or CLASSPATH environment variables.
    The Java API for the ProcessBuilder class has a simple example that shows how to create the arguments and launch an external application.
    ProcessBuilder (Java Platform SE 7 )
    There are also PLENTY of other examples of using ProcessBuilder; just search the net.

  • How to add jar files to applet's classpath

    hi everyone,
    i got an issue to add jar file's to applt's classpath,
    i looked around accross many resources but getting no solution on this.
    i have a commons-httpclient3.1.jar and i have to make it available it to a an applet class bundled in a jar file say myjar.jar
    how can i achieve it?
    any help would be much appreciated
    thanks

    That's a long time I haven't written applets, but if I remind well, we are able to set multilple jar in the classapth parameter, separated by semicolon.
    Look the page http://java.sun.com/docs/books/tutorial/deployment/applet/html.html
    Edited by: jswim on Dec 6, 2007 3:51 PM

  • How add ant.jar in to the Java on the NW65 ?

    Server: NW65SP8
    Step-1: i do this in the NetWare console:
    javac -d SYS:\JAVA\classes -classpath SYS:\JAVA\ksrlib\ant.jar SYS:\JAVA\classes\ZipTest.java
    ZipTest.java have this strings:
    mport org.apache.tools.zip.ZipEntry;
    import org.apache.tools.zip.ZipOutputStream;
    import java.io.*;
    import java.util.zip.Adler32;
    import java.util.zip.CheckedOutputStream;
    public class ZipTest {
    public static void main(String[] args)
    throws IOException {
    All without errors. After this i see file:
    sys:\JAVA\classes\ZipTest.class
    Step-2:
    run this ZipTest :
    java ZipTest
    And in the Loggerscreen i see this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/zip/
    ZipOutputStream
    at ZipTest.main(ZipTest.java:24)
    java: Class ZipTest exited with status 1
    Please, help me found my error.
    Serg

    Thanks all for advise.
    At this tie all work.
    this was my steps:
    1. in the my SLED11 move from eclipse to NetBeansIDE6.8
    2. download add to the SLED11 and configure in the NetBeans for use:
    /home/ksr/bin/j2sdk-1_4_2_18/j2sdk1.4.2_18 as JDK1.4
    3.Configure NetBeans for use ant.jar in the myzip Project
    4. this my source:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package myzip;
    import org.apache.tools.zip.ZipEntry;
    import org.apache.tools.zip.ZipOutputStream;
    import java.io.*;
    import java.util.zip.Adler32;
    import java.util.zip.CheckedOutputStream;
    //import java.util.Calendar;
    import java.util.Date;
    //import java.util.TimeZone;
    import java.text.SimpleDateFormat;
    //import java.util.*;
    public class Main {
    public static void main(String[] args) throws IOException {
    System.out.println("\nInside the java program.");
    System.out.println("You passed : " + args.length + " parameters.");
    for (int i=0; i<=args.length-1; i++) {
    System.out.println("Parameter # " + (i+1) + "\tValue = " + args[i]);
    System.out.println("SourceDir="+args[0]);
    System.out.println("DestinationFile="+args[1]);
    //+ + + + + + +
    //Calendar c=Calendar.getInstance();
    Date dtn = new Date();
    SimpleDateFormat dtnf = new SimpleDateFormat("yyyyMMdd");
    String NameZip = args[1];
    NameZip=NameZip+"_"+dtnf.format(dtn)+".zip";
    //System.out.println("="+ dtnf.format(dtn) );
    //System.out.println("="+ NameZip );
    ZipOutputStream zipOutputStream = null;
    File rootFile = new File(args[0]); // sysdata://test
    System.out.println("\nrootFile: "+rootFile+"\n");
    String pathPrefix = rootFile.getAbsolutePath().substring(0, rootFile.getAbsolutePath().lastIndexOf(System.getP roperty("file.separator")));
    System.out.println("pathPrefix: "+pathPrefix+"\n");
    System.out.println("pathPrefix-length: "+pathPrefix.length()+"\n");
    //File zipFile = new File("/home/ksr/test1.zip"); // sysdata://test.zip
    File zipFile = new File(NameZip);
    System.out.println("zipFile: "+zipFile+"\n");
    try {
    zipOutputStream = new ZipOutputStream(new CheckedOutputStream(new FileOutputStream(zipFile), new Adler32()));
    zipOutputStream.setEncoding("CP866");
    putZipEntry(zipOutputStream, rootFile, pathPrefix.length());
    } finally {
    if (zipOutputStream != null) {
    zipOutputStream.close();
    private static void putZipEntry(ZipOutputStream zipOutputStream, File file, int pathPrefixLength) throws IOException {
    if (!file.isDirectory()) {
    zipOutputStream.putNextEntry(new ZipEntry(file.getAbsolutePath().substring(pathPref ixLength)));
    InputStream in = null;
    try {
    in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
    byte[] bytes = new byte[(int) file.length()];
    int iCount;
    while ((iCount = in.read(bytes)) != -1) {
    zipOutputStream.write(bytes, 0, iCount);
    } finally {
    if (in != null) {in.close();}
    } else {
    File[] childFiles = file.listFiles();
    for (int i = 0; i < childFiles.length; i++) {
    File childFile = childFiles[i];
    // ++++
    //add for check file size > 0 or this is i directory
    if ( ((childFile.length() != 0) && childFile.isFile()) || childFile.isDirectory() ) {
    putZipEntry(zipOutputStream, childFile, pathPrefixLength);
    And at this time - all work !
    Problem with "Exception in thread "main" java.lang.NoClassDefFoundError:" -
    resolved after use in the NetBean JAVA1.4
    Problem with applycation freeze anc CPU utilization up to 100 % - resolved after add check:
    if this is a file and file size >0 or this is a directory , then zip
    else - SKIP
    Serg

  • How to add jar library in java?

    Hi,
    I am Anil,
    Could it possible to add library in Java library?
    like java.io.DataInputStream is library in Java (JDK), so I want to add my own library in Java JDK.
    I have created a package net.jini.j2space and one interface in it J2Space, I have created jar of this.
    and now I want to this jar to Java library so I can import it in my projects.
    Please help me.
    Thanks in advance.

    Hi, I am Zander Smith and I want to share my story with you. I am a sport star in my community, I am known for my football skills. I had a very healthy physique because I used to do almost 4 hours of daily workout. One day it was raining heavily and I was busy playing football with a nearly club who challenged our team. While playing I hit my leg on the goal post and broke my leg. I came out of hospital after three months. Since I was on complete bed rest I gained 35 pound. I had lost my athletic shape. I was very upset with my bulky body and I wanted to have my old shape back at any cost.
    I started to work out. As I was restricted by doctor to do rigorous work out, it did not help me the way I wanted. After a month one of my friends suggested me [Acai berry|http://ezinearticles.com/?Acai-Berry---How-I-Lost-30-Pounds-in-Under-30-Days-Using-The-Acai-Berry&id=1998407] . I thought that my workouts are enough for losing my weight, but I was impatient. I took all the information about this product and I found it useful. I purchased Acai Berry Supplement and used it. Now it is like a dream come true, I have come back to my earlier shape. Thanks to Acai Berry now I am living my life as I lived before. [Acai berry|http://www.goarticles.com/cgi-bin/showa.cgi?C=1829429]

  • Signing Jars from within Java Code

    Hi,
    I would like to sign a jar file from within my Java code. Reason for this is that I wish to update a jar file at runtime, throw away the class loader that loaded the jar, and load the updated code inside a new classloader.
    One problem, however: The jar file has to be signed before loading it. How can I do this from my Java program? Or do I need to have the jarsigner tool available at the location where I resign the jar?
    Thanks in advance,
    Ronald.

    Hi,
    In the meantime I found an answer to my problem. In rt.jar there exists a class sun.security.tools.JarSigner, which can be used for exactly this purpose. Not completely portable, but it'll do the trick.
    Ronald.

  • Possible to create a JAR file from within a java app?

    Is it possible to create a jar file from within a java application?
    Can it be done more elegantly than by spawning-off another
    process with the Runtime and exec() portions of the api?
    Thanks
    Scott

    Thanks! I was mislead by the API notes for java.util.jar:
    The JarOutputStream class is used to write the contents
    of a JAR file to any output stream.
    I was looking for a class or method to make jar files.
    Seems this is it ;)
    Thanks
    Scott

  • OpenScript/How to add .jar file to Java Code in relative path

    Hi all,
    I want to add a .jar file which can be executed separately (like "java -jar A.jar") to my recorded Java Code.I've read this wiki http://everest2.us.oracle.com/wiki/Generic_JAR_Project about how to add a .jar file to "Assets", however, I cannot figure out how to use the .jarr file in Java code,I mean , how to get this .jar file like the method the databank added in "Assets"?
    Things I did are as followed:
    1.Execute my .jar file in OpenScript Java code with absolute path like this:
    String cmd = "C:\Users\A.jar";
    Runtime.getRuntime().exec(cmd);
    This does work, but must set a absolute path in Java code like "C:\User\A.jar" ,which is not the workaround I want (I need my scripts can be run on other machines).
    2.Try to get its current path with following codes:
    File directory = new File(".");
    String currentPath=directory.getCanonicalPath();
    However,though this can get its absolute path (which is the the project path) in Eclipse like "C:\Users\Workspace\testProject", this only gets "C:\OracleATS\openScript" in OpenScript.
    I thought to copy my .jar file to the project path , got its current path in java code first,then can know the path of .jar file, but this workaround failed because of the above reason.
    I notice that in the "Assets" there are "Databanks","Object Libraries","JAR Files","Scripts". Since the databanks and scripts that added to "Databanks" and "Scripts" can be got or run in Java Code like:
    *getDatabank("DatabankName").getNextDatabankRecord(); String data = eval("{{db.DatabankName.data}}");*
    *or getScript("ScriptName").run();*
    *Is there a method to get and run the jar file added to "Assets\JAR Files" like the above?*
    Thank you very much!
    Regards,
    Angyoung

    Hi DM,
    Thanks for your reply!
    I've found a workaround,which is calling OpenScript's APIs ,such as this.getScriptPackage().getRepository() and this.getScriptPackage().getWorkspace(),etc to locate the .jar file.
    And this workaround can still work even though the script is run on other machine.
    Sorry to reply you so late!
    Regards,
    Angyoung

  • Want to Generate custom logs with Log4J within Java Embedding activity

    Hi Gurus,
    i want to Generate custom logs with Log4J within Java Embedding activity. For that i have performed some steps, but the log file has not been created.
    ServerSide Configuration:
    *===============*
    1. I have copied the log4j-1.2.15.jar file to the "oracle.soa.ext_11.1.1" location and recreate the oracle.soa.ext.jar file using an-script, which appends the log4j.jar file to the classpath.( That was created successfully)
    2. Specify a File location in log4j.xml for creating the log file. (e.g. (<middleware_home>/config/customLog.log)
    3. Then create a folder and add log4j.xml and log4j.dtd file under the folder.
    4. Modify the startManagedWeblogicServer by adding JAVA_OPTIONS="-Dlog4j.configuration=<middleware_home>/config/log4j.debug.xml”
    5. Then restart the SOA server.
    log4j.xml :
    I have used fileAppender.
    DevelopmentSide Configuration:
    *===================*
    1. Create synchronous BPEL process and Add "JAVA Embedding Activity" inbetween receiveInput and replyOutput activity.
    2.Import the log4j-1.2.15.jar to the project libs
    3.In the BPEL source code, import the Logger class.
    4.Insert the code in the JAVA Embedding Activity
    Logger logger = Logger.getLogger("CustomLog");
    logger.info("CustomeLog " + getTitle());
    Compile and deploy the project into the SOA_server and test it. Test status is completed but log is not created in the mentioned location.
    Ref: http://blog.andrade.inf.br/search/label/Log4j
    Is there any other way to achieve this requirement. Please suggest.
    Thanks in Advance,
    Sharmistha

    You can try this.
    http://veejai24.blogspot.co.uk/2008/04/simple-way-to-implement-log4j-in-your.html
    Thanks,
    Vijay

  • Including large number of jars in classpath...

    Hello,
    I have an application that relies on over 100 jars and a set of classes - I have been using an IDE to set the classpath so far, which has been fine, but I need to distribute the application to others, and so need to bundle the classes, preferably as a jar. I have tried multiple variations of setting the classpath within the manifest for the jar file (that includes only my source), and have finally resorted to setting the classpath using a batch file and running directly using the classes. Neither method works - the classpath seems to be too long - the best results I've got are with the bat file, but this loads all but the last 8 jars - taking out a few jars adds one or two more, so this seems to confirm a maximum length for the classpath. (FYI, I have previously used the manifest to set the classpath and this has been fine, but in this case I had only two jars.)
    Has anyone come across this problem, and if so, have you managed to find a solution - I've combed through the relevant postings to this forum and have found similar problems but no actual Manifest or bat file example apart from a description of what was done, all of which I've tried, and none of which worked. The option to use the wildcard * in the classpath environment variable doesn't work because I cannot use JDK1.6 - the external libraries need to run on JDK1.5 - I have actually tried this but it is not expanded.
    Aba-Sah

    Another option is to package (or "flatten") all the dependencies into a single JAR. I use the following Groovy script in ANT builds to copy files from many JARs to a single location ...
    <!-- set up a groovy task -->
    <taskdef name="groovy"
              classname="org.codehaus.groovy.ant.Groovy"
         classpathref="compile-cp"/>
    <!-- you'll need to adapt this to your environment -->
    <target name="flattenLibs">
              <mkdir dir="${dist-temp}"/>
              <groovy>
                   import java.io.*;
                   import java.util.zip.*;
                   import java.util.jar.*;
                   def copyBinary(isDir, dfile, is) {
                        def file = new File( dfile )
                        if ( isDir ) {
                             file.mkdirs()
                        else {
                             def preIndex = Math.max( dfile.lastIndexOf( "/" ), dfile.lastIndexOf( "\\" ) )
                             if ( preIndex > 0 )
                                  new File( dfile.substring( 0, preIndex + 1 ) ).mkdirs()
                             def fout = new BufferedOutputStream( new FileOutputStream( file ) )
                             try {
                                  byte[] buffer = new byte[ 1024 ]
                                  int i
                                  while ( ( i = is.read( buffer, 0, buffer.length ) ) > 0 )
                                       fout.write( buffer, 0, i )
                                  fout.close()
                             finally {
                                  fout.close()
                   def destDir = project.getProperty( "dist-temp" )
                   if ( destDir.endsWith( "\\" ) || destDir.endsWith( "/" ) )
                        destDir = destDir.subString( 0, destDir.length() - 1 )
                   // Look at "core-cp"
                   def libs = []
                   project.getReference( "core-cp" ).list().each { pe ->
                        if ( pe.endsWith( ".jar" ) )
                             libs.add( pe )
                   def noisy = "true".equalsIgnoreCase( project.getProperty( "noisy" ) )
                   // Copy:
                   libs.each { lib ->
                        def jfile = new JarFile( new File( lib ) )
                        def e = jfile.entries()
                        while ( e.hasMoreElements() ) {
                             def entry = e.nextElement()
                             def name = entry.getName()
                             if ( noisy )
                                  println "Copying \"${name}\" ..."
                             def is = new BufferedInputStream( jfile.getInputStream( entry ) )
                             try {
                                  copyBinary( entry.isDirectory(), "${destDir}/${name}", is )
                             finally {
                                  is.close()
              </groovy>
         </target>

  • Why getResource of jar in classpath returns null?

    When i iterate through the jars in the classpath and try to turn them into URL's via the getResources(), they all return null. What am I doing wrong?
    (NOTE: It does print out the classpath properly when i print that out)
    String classPath = System.getProperty( "java.class.path" );
    String delim = System.getProperty( "path.separator" );
    String[] locations = classPath.split( delim );
    for ( int i = 0; i < locations.length; i++ )
          /* ** It doesn't work with either of these statments: ** */
          //This one tries the full path (e.g. /home/me/test/some.jar)
          //Enumeration en = getClass().getClassLoader().getResources( locations[ i ].substring( locations[ i ] );
          //This one tries to use just the local name of the jar (e.g. test.jar)
          Enumeration en = getClass().getClassLoader().getResources( locations[ i ].substring( locations[ i ].lastIndexOf( '/' ) + 1 ) );
          //This just prints null
          while (  en.hasMoreElements(); ) System.out.println( en.nextElement() );
    }Edited by: 6tr6tr on Dec 4, 2008 5:46 PM
    Edited by: 6tr6tr on Dec 4, 2008 5:47 PM

    What you are doing doesn't make sense. The resource locations within a JAR file are relative to the package directory structure within the JAR file, not to its own absolute location on the disk. And you seem to be expecting to retrieve a JAR file from within a JAR file. This makes no sense either.

Maybe you are looking for

  • Help needed in refreshing a button array

    Hi, I am developing a GUI, in which window1 is in package pack1 & window2 in pack2. from window1, clicking "Add" button window2 appears. In window1, I am storing the content of a particular directory in my file system as a string array. So, each stri

  • FI CO Integation: Document type for real-time integration with FI not there

    Dear Gurus, This is the error message that I got and I am looking for a solution could anyone help me please. I was doing simultaneous costing and doing Product Cost Collector reports.[KKBC_PKO] This is IDES 6.00 ehancement package 4, How do I define

  • Oracle Service Bus 11gR1

    We are able to install and bring up Oracle Service Bus 11gR1. When the architecture of installed Oracle Service Bus 11g R1 has only the Admin server, we are able to login to the sbconsole and console, But our as per our current architecture requireme

  • Premiere CC 2014 losing link to Preview files - what I've found

    Upgraded to Premiere CC 2014 in an effort to resolve the dreaded "losing link to Preview files" problem. After some testing, I've discovered that I need to actually close any and all timelines before saving/quitting in order to keep the link intact.

  • Importing DATA cd

    Hello all: I created a data cd with about 60 songs from my other computer and would like to import them to this one. Do I need to change the files so itunes will read them? When I insert cd instead of the "import" button it shows "browse" Thanks in a