Using external util JAR from Session EJB

I have a Stateless Session EJB that uses some classes packaged in a utility jar. How do I package the EJB jar with this util jar, and get the app server to recognize this utility jar? including a /lib dir with the utils jar in it, like you would with a WAR, doesn't work.
I've temporarily got this to work by modifying the startup scripts for my app server to ensure my jar is included in the -classpath arg, but this cannot be the intended way. (cannot find details on this in the tutorial).
Thanks in advance!

Well, the answer depends a lot on which appserver you're using, because it obviously depends on how the vendor implemented the containers' ClassLoaders. What usually works is dependent upon a portion of the JVM spec regarding the MANIFEST.MF file. If you package your ejb.jar and library.jar in an .ear file, you can put the following in the ejb.jar MANIFEST.MF:
ClassPath: library.jarNote that there must be at least one blank line at the end of the MANIFEST.MF file.
This works on WebLogic, but, as an example, JBoss uses a single ClassLoader, so I'm not entirely sure how you'd go about the same thing there.
And you're quite right - putting it in the JVM ClassPath is not a good idea...

Similar Messages

  • Problem in Creating a jar file using java.util.jar and deploying in jboss 4

    Dear Techies,
    I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
    package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.jar.JarEntry;
    import java.util.jar.JarOutputStream;
    import java.util.jar.Manifest;
    import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
    * @author Piku Mishra
    public class JarCreation
         * File object
         File file;
         * JarOutputStream object to create a jar file
         JarOutputStream jarOutput ;
         * File of the generated jar file
         String jarFileName = "rrs.jar";
         *To create a Manifest.mf file
         Manifest manifest = null;
         //Attributes atr = null;
         * Default Constructor to specify the path and
         * name of the jar file
         * @param destnPath of type String denoting the path of the generated jar file
         public JarCreation(String destnPath)
         {//This constructor initializes the destination path and file name of the jar file
              try
                   manifest = new Manifest();
                   jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
              catch(Exception e)
                   e.printStackTrace();
         public JarCreation()
         * This method is used to obtain the list of files present in a
         * directory
         * @param path of type String specifying the path of directory containing the files
         * @return the list of files from a particular directory
         public File[] getFiles(String path)
         {//This method is used to obtain the list of files in a directory
              try
                   file = new File(path);
              catch(Exception e)
                   e.printStackTrace();
              return file.listFiles();
         * This method is used to create a jar file from a directory
         * @param path of type String specifying the directory to make jar
         public void createJar(String path)
         {//This method is used to create a jar file from
              // a directory. If the directory contains several nested directory
              //it will work.
              try
                   byte[] buff = new byte[2048];
                   File[] fileList = getFiles(path);
                   for(int i=0;i<fileList.length;i++)
                        if(fileList.isDirectory())
                             createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
                        else
                             FileInputStream fin = new FileInputStream(fileList[i]);
                             String temp = fileList[i].getAbsolutePath();
                             String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
    //                         System.out.println( subTemp+":"+fin.getChannel().size());
                             jarOutput.putNextEntry(new JarEntry(subTemp));
                             int len ;
                             while((len=fin.read(buff))>0)
                                  jarOutput.write(buff,0,len);
                             fin.close();
              catch( Exception e )
                   e.printStackTrace();
         * Method used to close the object for JarOutputStream
         public void close()
         {//This method is used to close the
              //JarOutputStream
              try
                   jarOutput.flush();
                   jarOutput.close();
              catch(Exception e)
                   e.printStackTrace();
         public static void main( String[] args )
              JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
              jarCreate.createJar("put your source directory");
              jarCreate.close();

    Hi,
    I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
    You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved.

  • Including utility jar when packing ejb in weblogic

    Hi,
    I am new to j2ee programming. I have an ejb which uses some utility jars. I followed the bea documents to structure the directory. The directory structure is, like,
    EjbProject
    - classes
    --com
    ---mine
    ----projectTracking --> has the class files of the ejb and supporting java files
    - src
    --com
    ---mine
    ----projectTracking --> contains the source files of the ejb and the supporting java files
    META-INF > contains ejb-jar.xml and weblogic-ejb-jar.xml
    The source java files are dependent on an utility jar file.
    so when I try the java weblogic.appc src, it throws me exception saying the utility file is missing. My question , is where should I put this utility jar file. Please send me your thoughts.
    Thanks in advance

    Hi,
    you can put your utility jar in the ear file along with the EJBs and make a classpath entry to these files in the EJB jar's META-INF\Manifest.mf file. As you said if you are working with weblogic you can put these files any where in the directory structure and place the entry in the startWeblogic.cmd file. But i recomend first option.
    Ashok.

  • Modifying JAR file using java.util.jar package  over the network

    Hello,
    I am modifying a JAR file programmatically using java.util.jar package. The time taken to save the contents to a local disk is very less (around 1 sec) . When I tried modifying the JAR from a remote machine over the network (from mapped drive or shared folder of WIN NT), the time taken to save is 15-20 times more.
    I am recreating the whole JAR while modifying. Is there any way to improve the performance. Or is it possible to write only the changed files?
    Thanks,
    Prasad Y S.

    When you "update" a jar file, you must always recreate it from scratch.

  • How to create ErrorLog file from Session EJB

    Hi my friends,
    I have the need to write the Exception Errors from Session EJBs into log file. The problem is my project is the multi-user application and many EJBs' user transactions need to log the errors to only one log file, if I use EJB named ErrorLogWriter as the main component for log file writer and the other EJBs just reference to this EJB to log the errors, each request will create one instance of ErrorLogWriter therefore we can't access to only one log file. Somebody told me that it should be OK if we use servlet as the log file writer because only one servlet instance is initialized for multi-requests, and the other EJBs just call this servlet. Do you have any ideas or suggestion for this matter? If using servlet is the right solution, can I call servlet method from Session EJBs? and how?
    Thanks in advance for any help
    Quoc Nguyen

    Look for log4j -
    http://jakarta.apache.org/ ( then side menu )

  • Help:how to use java.util.jar to zip or unzip a binary file.

    how to use java.util.jar to zip or unzip a binary file or a file contain native code.

    It may help you to know how I add JARs
    1. I open my Project (myProject)
    2. I Mount the JAR to the FileSystem (like mypackages.jar = which includes com.mus.de.myClass.java)
    3. I Mount the File to the FileSystem (like c:\..myfiles..\myProject)
    3.1 I add the File to my Project
    4. I select File | New -> Classes | Main
    4.1 I typed "import com.mus.de.myClass.java" to refer to this package.
    4.2 I called some of the public methods
    thats it
    Andreas

  • Using a JMS control from an EJB project

    I'm developing an EJB in Workshop and my EJB is expected to send messages to a JMS queue. How can I use a JMS control (JCX) from my EJB?

    If you're talking about making an executable jar file that will work with the bouncycastle jar:
    (1) Make a jar as usual with your classes in it
    (2) Include a manifest file that specifies the class containing your app's main() method
    (3) In that same manifest, make sure that the bouncycastle jar is included in the Class-Path
    Details are in Sun's Tutorial: [Packaging Programs in JAR Files|http://java.sun.com/docs/books/tutorial/deployment/jar/index.html] and specifically [http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html|http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html] for the business of having your app recognise the other jar file's classes at runtime.
    Doubtless this can all be done from the comfort of your IDE, but I don't know how. There will be documentation on NetBeans site I suppose.
    Edited by: pbrockway2 on Jul 23, 2008 8:59 PM

  • Using external library jar

    Hi everyone,
    I am working on a J2EE 1.3 project. I have a external library jar file at, for example, /myproject/lib. My EAR has to access that external library jar. Moreover, the library jar is not self-contained. It has to use the class that stored in the EAR file.
    I have seen a lot of articles that talking about using Class-Path attribute in the manifest file but that seem not work in my case.
    Could any one have any idea how I can call a external library jar file which is not self-contained under J2EE 1.3 spec? Thank you very much.
    Jacky

    In J2EE 1.3 there was no portable mechanism for extending the appserver-wide classpath of
    a J2EE appserver. However, most appserver's have some way of doing it. You'll need to
    consult the documentation of whatever implementation you're using.
    However, in that case you cannot have code in the appserver classpath with dependencies on
    code in a specific J2EE application. The dependency can only occur in the other direction.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use Tuxedo's services from an EJB: Jolt x JET ?

    Hi.
    Can anyone tell me if an EJB MUST use JET (instead Jolt) to access Tuxedo services
    Suppose the following case:
    We have a client using JNDI service to obtain an EJB.
    In my client i invoke the appropriate methods to create a jolt session and to
    start a jolt transaction. My EJB Bean only call Tuxedo services (using Jolt).
    Will this application work ? Will EJB code use the transaction created by the
    client code ? Will a transaction context exist ?
    Thanks in advance.

    Hi Daniel,
    If you mean WebLogic Server 5.1 by WL 5.1 (instead of WebLogic Enterprise), then
    yes, you need to use Jolt until you upgrade to a later release of WebLogic Server.
    WTC wasn't fully supported until WebLogic Server 6.1 and later.
    The transaction context of the container Jolt is being used in is not extended
    to the Tuxedo system. Jolt can be used to start a new and separate transaction
    in Tuxedo, but that transaction and the containers current transaction will not
    be coordinated.
    I'm not sure what you mean when you say:
    The transaction management when using Jolt is realized for Jolt API.
    There is no relantionship between Jolt transactions and Tuxedo transactions.
    Is this rightThe transaction management when using Jolt is transaction management of
    the Tuxedo system you are talking to. Jolt is a client side API that uses a
    delegated model for transactions. So a transaction started with Jolt starts
    a transaction in Tuxedo, but does not affect the transaction context of the
    environment the client, i.e., the place where the Jolt call was made. So if
    you are using Jolt inside an EJB hosted in the EJB container of WebLogic
    Server, the Jolt calls will have no impact or effect on the transaction state
    of the EJB.
    Regards,
    Todd
    "Daniel" <[email protected]> wrote:
    >
    Ok.
    We have EJBs running in Weblogic and they are using Tuxedo services.
    We have used Jolt instead WTC because we are running WL 5.1. Can i
    use WTC with WL 5.1 ?
    The transaction management when using Jolt is realized for Jolt API.
    There is
    no
    relantionship between Jolt transactions and Tuxedo transactions. Is this
    right
    Thanks in advance.
    "Todd Little" <[email protected]> wrote:
    "Daniel" <[email protected]> wrote:
    Hi.
    Can anyone tell me if an EJB MUST use JET (instead Jolt) to access
    Tuxedo
    services
    ? You can use either Jolt or preferably use WTC and JATMI.
    Suppose the following case:
    We have a client using JNDI service to obtain an EJB.
    In my client i invoke the appropriate methods to create a jolt session
    and to
    start a jolt transaction. My EJB Bean only call Tuxedo services (using
    Jolt).Why is the client creating a Jolt session and transaction? They will
    not be associated
    with the EJB's execution. The client's Jolt context is not propogated
    to the
    EJB. Can you explain what it is you want to do? What do you want included
    in
    the transaction?
    Will this application work ? Will EJB code use the transaction created
    by the
    client code ? Will a transaction context exist ?Well I suppose it depends upon what you mean by work. It comes down
    to what are
    you trying to accomplish. The client is a WLS client? Is the EJB a
    client of
    some Tuxedo service? If those are both true, then you would be best
    served by
    controlling the transaction with the EJB's deployment descriptor and
    having the
    EJB use WTC to access Tuxedo. WTC will take of propagating any required
    transaction
    state to Tuxedo.
    Regards,
    Todd

  • How to use external libraries jar files in the composite application?

    Hi,
    I have some external jars files (which consists of java classes) that I would like to use in my composite application. 
    I have created a DC with type as external library for the jars.  However, I don't know how to specify the DC to be used in my caf application.
    Can anyone help?
    Thanks.
    Regards,
    Fui Voon

    Hi,
    My jar files consists only java classes and a manifest.mf. The files are compiled using jdk 1.4.2-b28.  Will this be any issue?
    It seems that if I ignore the error and continue step 7 which is to do deployment of the ear, the error given is
    Cannot update it.
    Caused by: com.sap.engine.library.bytecode.cf.CFException: Invalid constant pool tag, 60 at index 41.
    Does anyone know what that mean?
    Is there any sample that teach how to deploy external libraries as bundled library?
    Thanks.
    Regards,
    Fui Voon

  • Persistant connection from Session EJB to MQ Series

              Hi Technocrats,
              In our Application we have deployed MDB and Stateless Session Bean to receive
              and send messages in asynchronous mode.MDB is asynchronous but we need our Session
              bean also to send messages without closing the session and connection.now we are
              doing the jms clean up by closing the session and connection and looking for persistant
              connection with Weblogic server to MQ through session bean.Is it possible?if so
              how?please let me know if u've some solution or from ur friends.
              advance thanx
              Subrahmanyam
              

    My assumption is that your MQ installation is working fine, and you're able to send messages to it from MQ test scripts or tools. I'm not going to give a "tutorial", just a high-level description of what you'll have to do, along with some important details.
    The most straightforward way to send messages to MQ from WLS/ALSB is to just use JMS to send a message. This requires two other steps.
    You'll have to use the "JMSAdmin" tool in the IBM MQ client distribution, which is used to specify the connection information for your QueueManager and Queue. This information is written to a "JNDI repository" of some sort, most likely just a file in a specified directory (by specifying the File JNDI provider and the directory to store into, both in the JMSAdmin config file). It's possible to store the JNDI info in other repositories, like LDAP, but I don't have a clear feeling for whether that's practical (or used).
    Then, in WLS, you define a "Foreign JMS Server", where you can specify the location of the JNDI settings file (the directory), and the JNDI provider class. Nothing in the WLS config or the app needs to know that it's communicating with MQ. It just uses JMS.

  • Using external C libraries from TOOL code

    Hello,
    As described in "Integrating with external systems", FORTE TOOL code can
    interface with C libraries.
    I finally got the DMathTime example running, thanks to Alain Dunan in UK who
    put me on the right track.
    At the begining I paid no attention to the fact that the documentation says
    "interfacing with C functions". It is the "C" which is important, it means
    that the declarations of all the externals of the library must comply to C
    and not to C++ !
    Therefore it's wrong to compile the DMathTime library with a C++ compiler
    right away (CC -PIC -c *.c).
    If you do so every thing works fine until you run the program. Then you get :
    USER ERROR: The dynamic library
    /sp1/soft/forte2e2/userapp/distmath/cl0/dmathtm for the project
    DistMathAndTimeProject could not be found.
    Class: qqsp_ExistenceException
    Detected at: qqsh_DynScope::GetLoadedScope at 1
    Last TOOL statement: method DistMathAndTimeTest.Runit, line 5
    Error Time: Wed Aug 7 10:22:19
    Exception occurred (remotely) on partition
    "TestDistMathAndTimeProject_cl0_Part1", (partitionId =
    C9731008-EAE4-11CF-B553-C56F3BFEAA77:0x160:0x42, taskId =
    [C9731008-EAE4-11CF-B553-C56F3BFEAA77:0x21d:0x4.89]) in application
    "AutoCompileSvc_cl0", pid 29598 on node nation in environment CentralEnv.
    SYSTEM ERROR: System Error: ld.so.1:
    /sp1/soft/forte2e2/install/bin/ftexec: fatal: relocation error: symbol not
    found: OurTime: referenced in
    /sp1/soft/forte2e2/userapp/distmath/cl0/dmathtm.so, loading the library
    '/sp1/soft/forte2e2/userapp/distmath/cl0/dmathtm.so'
    Class: qqos_DynamicLibraryException
    Error #: [101, 29]
    Detected at: qqos_DynamicLibrary::Load at 1
    Error Time: Wed Aug 7 10:22:19
    Exception occurred (remotely) on partition
    "TestDistMathAndTimeProject_cl0_Part1", (partitionId =
    C9731008-EAE4-11CF-B553-C56F3BFEAA77:0x160:0x42, taskId =
    [C9731008-EAE4-11CF-B553-C56F3BFEAA77:0x21d:0x4.89]) in application
    "AutoCompileSvc_cl0", pid 29598 on node nation in environment
    CentralEnv.
    It works if you change the external declarations of the library to read :
    extern "C" <declaration>
    prior to compiling the library with the C++ compiler (there might be other
    ways to get the same result).
    Alain told me that it works if instead of compiling the library with a C++
    compiler, a C compiler is used; but unfortunately I don't have a C compiler
    on the SPARC solaris here.
    best regards,
    Pierre Gelli
    ADP GSI
    Payroll and Human Resources Management
    72-78, Grande Rue, F-92310 SEVRES
    phone : +33 1 41 14 86 42 (direct) +33 1 41 14 85 00 (reception desk)
    fax : +33 1 41 14 85 99

    Apart from the Oracle documentation you mean?
    http://technet.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96590/adg11rtn.htm#1656
    Cheers, APC

  • Everytime I go to Google Mail I have to re-verify myself. It used to remember me from session to session. Very frustrating!

    I have changed from Windows 7 32 bit to Windows 7 64 bit and am having a fair amount of issues, including this one.

    Websites remembering you and automatically log you in is stored in a cookie.
    * Create an allow cookie exception (Tools > Options > Privacy > Cookies: Exceptions) to keep such a cookie, especially for secure websites and if cookies expire when Firefox is closed.
    Make sure that you do not run Firefox in Private Browsing mode.
    * https://support.mozilla.com/kb/Private+Browsing
    * In [[Private Browsing]] mode all cookies are session cookies that expire if that session is ended, so websites won't remember you.
    * Do not use [[Clear Recent History]] to clear the "Cookies" and the "Site Preferences"
    Clearing "Site Preferences" clears all exceptions for cookies, images, pop-up windows, software installation, and passwords.
    * http://kb.mozillazine.org/Cookies
    * http://kb.mozillazine.org/Password_Manager

  • How to (make best) use external js library from html object (need help from dev)

    Ok, on another discussion about rotating full screen backgrounds slideshows, i was orientated to try a small lib named "backstrech"
    I throw myself in, and i really like what we can do with it.
    To use it simply, just make an html object and paste this in :
    <script src="http://musecdn2.businesscatalyst.com/scripts/4.0/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="assets/jquery.backstretch.min.js" type="text/javascript"></script>
    <script>
      $.backstretch([
          "http://dl.dropbox.com/u/515046/www/outside.jpg"
        , "http://dl.dropbox.com/u/515046/www/garfield-interior.jpg"
        , "http://dl.dropbox.com/u/515046/www/cheers.jpg"
      ], {duration: 3000, fade: 750});
    </script>
    then add the jquery.backstretch.min.js to your "downloaded files" (file menu > files to download)
    And you’re done.
    Now, i need some help from better developers.
    As you can see, my first line is a call to jquery, the same that we find later in Muse exported code.
    Reason 1 : without this line, jquery is not defined and the plugin won’t work.
    This raises 2 issues :
    - We load twice the same ressource which is useless (100k)
    - loading js is all about having the page hangs while it loads, hence, they are put at the end of the body.
    Does anybody know a way to load this particular html script AFTER we are sure the muse scripts (esp. jquery) have been loaded ?
    (in the Edge Animate world, i’d go for the yepnope, and put it at the right place in the code, though, here i have no access to page load structure except head)
    PS : in addition to that, i made an exported page/excluded from navigation where i put all the images i wanted for the background, i could then simply change the images lines :
    , "http://dl.dropbox.com/u/515046/www/garfield-interior.jpg"
    to
    , "images/my_image_name_as_in_ressources.jpg"

    Got it, there was a bug in my code. Here is what you do:
    1. Download the js file https://raw.github.com/srobbin/jquery-backstretch/master/jquery.backstretch.min.js
    2. In Muse: Go to File -> Add Files for Upload and add the script file
    3. Open Page Properties -> Metadata -> HTML for <Head>
    Paste this code in:
    <script>
    window.onload = function() {
    var loaded = function() {
      $.backstretch([
          "http://dl.dropbox.com/u/515046/www/outside.jpg"
        , "http://dl.dropbox.com/u/515046/www/garfield-interior.jpg"
        , "http://dl.dropbox.com/u/515046/www/cheers.jpg"
      ], {duration: 3000, fade: 750});
    //Load the plugin:
    var head= document.getElementsByTagName('head')[0];
    var script= document.createElement('script');
    script.type= 'text/javascript';
    script.onreadystatechange = loaded;
    script.onload = loaded;
    script.src= 'assets/jquery.backstretch.min.js';
    head.appendChild(script);
    }; //Window OnLoad
    </script>
    4. Preview or Publish = Done!
    Example: http://musebackstretch.businesscatalyst.com/index.html

  • Using Archive Utility.app from Terminal

    Hi there!
    Does anybody know if it is possible to send commands or options to Archive Utility.app via Terminal?
    It is possible to invoke Archive Utility.app and pass it the path to a zip file, and it will uncompress it. However, I would like to also pass it a destination path, and see what other options it may have.
    Thanks in advance!
    davewg

    It's because this will be done via a script and I want to show a progress bar to the users, then they can see something is happening - Archive Utility.app has a very nice little progress bar! :o)

Maybe you are looking for

  • Interview questions again..??

    can someone tell me the first 5-10 questions the interviewer wud ask related to experience etc..Please give more details if possible.. Questions you people mostly face in interviews...I am not asking for questions about abap in general but questions

  • How can I transfer photos from my iPhone to iPhoto without iCloud getting involved?

    Hi All: I would like to transfer photos to iphoto without iCloud synching.  Last time I synched my iphone to my laptop icloud changed my .mail account setting and moved/added folders within .mail.  It took me a very long time to figure out what happe

  • How can i use the database in my plug-in?

    Hi :        I write a plug-in, but i want it can read the datafile and get the data of corresponding column ,at last show them on the pageitem. I know InDesign have this founction but i can`t get use it in my plug-in. ( * -- * ) !

  • Apple maps satellite imagery doesn't work

    After upgrading to iOS 6 and eagerly trying out the new maps , I was met with disappointment as the satellite imagery function doesn't work, I'm left with a pin surrounded by complete blackness. The normal map view works fine and so do all the other

  • PSE6 Organizer... How to display only the hidden pics

    Since deleting bad pics is very slow in my PC, in PSE5 I began using an alternate method; I hit Alt-F2 to hide unwanted pics and then selected the Hidden tag, selected all the pics and deleted them all in one batch. But now in PSE6 there is no Hidden