---------- Forwarded message ----------
Date: Mon, 15 Apr 2002 16:43:35 -0600 (MDT)
From: Mark Gulbrandsen <[EMAIL PROTECTED]>
To: JD Brennan <[EMAIL PROTECTED]>
Subject: RE: [JBoss-user] File-system access




        String jarURLString = "templates.jar";
        System.err.println("opening " + jarURLString);
        URL jarURL = getClass().getResource(jarURLString);
        if(jarURL == null) {
            throw new NullPointerException("can't open " + jarURLString);
        }

        System.out.println("Opened " + jarURL);

        JarURLConnection con = (JarURLConnection)jarURL.openConnection();
        System.out.println("con = " + con);
        JarFile jarFile = con.getJarFile();
        System.out.println("jarFile = " + jarFile.getName());

        //RIGHT HERE !! the above outputs the name of the ejb.jar file
        //(which is not ejb.jar, but something else). This outputs the
        //name of the file that jboss copies to its
        //$JBOSS/server/default/tmp/deploy directory, something like
        //92.myejbs.jar.

        JarEntry jarEntry1 = jarFile.getJarEntry("email/templates.jar");
        //email/templates.jar is the jar file inside of myejbs.jar.
        if(jarEntry1 == null) {
            throw new NullPointerException("not found");
        }
        System.out.println("found " + jarEntry1.getName());

        JarInputStream jarInputStream = new 
JarInputStream(jarFile.getInputStream(jarEntry1));

        JarEntry jarEntry = jarInputStream.getNextJarEntry();
        while(jarEntry != null) {
            System.err.println("found " + jarEntry.getName());

            if(jarEntry.getName().compareTo("Payment.txt") == 0) {
                //the following code is NOT production, it is a test
                byte[] bytes = new byte[1024*1024*2];
                int len = jarInputStream.read(bytes,0,1024*1024*2);
                System.err.println(new String(bytes));
                jarInputStream.read(bytes,len,(1024*1024*2)-len);
                System.err.println(new String(bytes));
            }

            jarEntry = jarInputStream.getNextJarEntry();

        }


There you have it. But what I really want to do is to be able to access a
resource or something so that I can have templates.jar represented as a
JarFile object, because it is less work to access it if it is not in
myejbs.jar. I just can't figure out how to find it if it is not in
myejbs.jar.

Any help?

Thanks,

Mark

On Mon, 15 Apr 2002, JD Brennan wrote:

> You can use JarInputStream() instead of JarFile() to
> read your resources.jar.
>
> new JarInputStream(jar.getInputStream(entry));
>
> How did you get from the URL to name of the deployed
> ejb jar?  That would be a neat trick to do.
>
> JD
>
> -----Original Message-----
> From: Mark Gulbrandsen [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 15, 2002 1:14 PM
> To: [EMAIL PROTECTED]
> Subject: [JBoss-user] File-system access
>
>
>
>
> I have an ejb jar file that is deployed in server/default/deploy. Call it
> myejbs.jar.
>
> I also have a jar file that has many resources called resources.jar.
> resources.jar is placed inside of myejbs.jar. I can access resource.jar
> through getClass().getResource("resource.jar"). This gives me a URL, which
> I can get a JarFile from via a few other calls. However, the JarFile that
> I get is myejbs.jar. So then I have to call into the java.util.jar apis to
> finally end up with a JarEntry.
>
> What I really want to do is access resource.jar as a JarFile, not a
> JarEntry. So how do I configure jboss 3.0 to allow me to access
> resource.jar as a JarFile? Also, I'd rather not put resource.jar in
> myejbs.jar, because these resource could change more often than the ejbs,
> but I don't want to have to redeploy my ejbs every time a resource
> changes. I tried putting resource.jar in $JBOSS/server/default/deploy/,
> but I still couldn't access it. Where can I put resource.jar and what do I
> need to configure so my ejbs can access it through the ClassLoader (via
> getResource)?
>
> Thanks,
>
> Mark
>
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
>




_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to