RE: Problems with standalone jars using EOModels and NSBundle

From: JR Ruggentaler (JR.Ruggentale..pv.com)
Date: Fri Feb 16 2007 - 09:52:30 EST

  • Next message: Zak Burke: "Re: Unable to Launch WOApplication"

    I have a standalone Java app that uses EOF and a EOModel but does not
    use WO frameworks and it works fine. Here is the classpath.

    jars\myapp.jar;jars\myutils.jar;jars\javaeoaccess.jar;jars\javaeocontrol
    .jar;jars\javafoundation.jar;jars\javaxml.jar;jars\mysq.jar;jars\JavaJDB
    CAdaptor.framework\Resources\Java\javajdbcadaptor.jar;

    There is some code that loads the EO model and the jars directory
    contains all the jars from the class path plus the complete
    JavaJDBCAdaptor.framework directory structure.

     Directory of \\foo\C\myappdir\jars

    02/14/2007 12:44 PM <DIR> .
    02/14/2007 12:44 PM <DIR> ..
    03/14/2003 04:01 PM <DIR> CVS
    02/12/2007 03:44 PM 148,061 myutils.jar
    05/01/2002 09:25 PM 541,224 javaeoaccess.jar
    05/01/2002 09:23 PM 456,238 javaeocontrol.jar
    04/17/2002 07:00 PM 861,247 javafoundation.jar
    03/14/2003 04:01 PM <DIR> JavaJDBCAdaptor.framework
    12/05/2001 05:58 AM 925,202 javaxml.jar
    11/28/2001 02:44 PM 114,798 mysql.jar
    02/14/2007 12:44 PM 256,657 myapp.jar

    The app was developed using the Kawa IDE but is now maintained with
    Eclipse. Initial development was done in 2002 so it's dooable without
    any special WOProject or IDE support. We also have "Agents" that use
    frameworks and EOF but I don't work on those. My suggestion here is
    start simple. Try writing a simple app the accesses a DB using EOF. I
    think after that all you need to do to add a frame work is add the
    framework to you classpath.

    J.R.

    -----Original Message-----
    From: Kieran Kelleher [mailto:kieran_list..ac.com]
    Sent: Friday, February 16, 2007 7:28 AM
    To: woproject-de..bjectstyle.org
    Subject: Re: Problems with standalone jars using EOModels and NSBundle

    Joshua,

    I've never done what you are trying to do, but your post reminded me of
    this blog post by Ray Kiddy on command line EOF apps.
    http://worldofwebobjects.blogspot.com/2006/04/command-line-tool-for-
    fetching-with.html

    HTH, Kieran

    On Feb 16, 2007, at 1:16 AM, Joshua Archer wrote:

    > ...admittedly I'm kinda stupid when it comes to constructing jars
    > -- if I were to just create a normal jar of my app, how would I have
    > to craft it so it picks up all the other jars and libraries, etc. that

    > I need as well? I've tried adding everything to the - classpath
    > argument, but that doesn't seem to work for me.
    >
    > On Feb 15, 2007, at 7:29 PM, Chuck Hill wrote:
    >
    >> I suspect the problem is the structure of your jar. It is not
    >> throwing an exception on loading a class, it is throwing it on
    >> loading bundle resources. As a start, I'd guess that fat jars and
    >> NSBundle are not compatible. If you need the one jar thing, you are
    >> probably going to have to write a replacement for NSBundle.
    >>
    >> Chuck
    >>
    >>
    >>
    >> On Feb 15, 2007, at 5:23 PM, Joshua Archer wrote:
    >>
    >>> hey everyone,
    >>>
    >>> I've done some searching on the archives, google, etc to try and
    >>> find an answer to this problem, but I'm not getting what I'm after.
    >>> I thought I'd throw this to the group and see what you think (or
    >>> point me to the right archive and tell me to shut up :) ).
    >>>
    >>> I've created a command line java application that makes use of a
    >>> couple of frameworks that access a few EOModels that I use in my
    >>> main WO app, for the purposes of initializing data in the database,
    >>> creating admin accounts, etc. I've built it in Eclipse, and as long
    >>> as I run in eclipse, all is fine with the world.
    >>> However, when I try to compile the app as a jar and run it, I get
    >>> NSBundle initialization errors:
    >>>
    >>> tintangel:~/Development jarcher$ java -jar
    >>> PachydermAccountGenerator.jar Exception in thread "main"
    >>> java.lang.ExceptionInInitializerError
    >>> at org.pachyderm.PachydermAccountGenerator.main
    >>> (PachydermAccountGenerator.java:65)
    >>> Caused by: java.lang.NullPointerException
    >>> at
    >>> com.webobjects.foundation.NSBundle.LoadUserAndBundleProperties
    >>> (NSBundle.java:640)
    >>> at com.webobjects.foundation.NSBundle.<clinit>
    >>> (NSBundle.java:367)
    >>> ... 1 more
    >>>
    >>> I've put in lines to the code to show the current bundle info right
    >>> up front in the main method, but I think the problem is that
    >>> NSBundle won't even initialize when the class is loaded.
    >>>
    >>> Here's part of the main method:
    >>>
    >>> public static void main(String[] args) {
    >>>
    >>> System.out.println("Main.main: main bundle = " +
    >>> NSBundle.mainBundle());
    >>> System.out.println("Main.main: JavaFoundation bundle = "
    +
    >>> NSBundle.bundleForName("JavaFoundation"));
    >>> ....
    >>>
    >>> }
    >>>
    >>> And I've included all the jars locally using fat jar, so the classes

    >>> are in the path and available (if not, I'd be seeing class not
    >>> defined exceptions).
    >>>
    >>> Any clue how to get this to work? Are there system variables I need
    >>> to set?
    >>>
    >>> ----------------------------------------------------------------
    >>> Joshua Archer
    >>> Software Engineer
    >>> CSU - Center for Distributed Learning
    >>> Phone: 707.664.2085
    >>> Fax: 707.664.4350
    >>>
    >>>
    >>
    >> --
    >>
    >> Practical WebObjects - for developers who want to increase their
    >> overall knowledge of WebObjects or who are trying to solve specific
    >> problems.
    >> http://www.global-village.net/products/practical_webobjects
    >>
    >>
    >>
    >>
    >>
    >>
    >
    > ----------------------------------------------------------------------
    > -------
    > Joshua Archer
    > Software Engineer, CSU - Center for Distributed Learning
    > Phone: 707.664.2085, Fax: 707.664.4350
    > ----------------------------------------------------------------------
    > -------
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Feb 16 2007 - 09:52:35 EST