Home > Archive > PostgreSQL JDBC > November 2005 > Deploying my application (nesting the jar)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Deploying my application (nesting the jar)
Benjamin Stookey

2005-11-21, 8:24 pm

I realize that it's not possible to nest the jar in
another jar, but I was wondering if anyone could give
me a suggestion for deploying my application using
this jar file.

I did try extracting the jar to include the class
files in my classpath (is this a bad idea?), but once
I did that I get the "No suitable driver"
SQLException. I'm probably making some blundering
mistake with my classpath, but I can't figure it out.

How have other people done this? Ideally, I'd like my
application to be in one jar file to make it easier
for my users. I'm still hoping this is possible...

Thanks for the help,
-Ben

/**
* @develEnv ECLIPSE
* @javaVer JAVA 1.4.2_08
* @OPSystem SUSE LINUX
*/




____________________
______________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Mark Lewis

2005-11-21, 8:24 pm

Well, you could actually nest the jar inside of another jar (we've done
it here before), but you need to do some ugly things like using your own
classloader and doing some tricks to avoid the must-be-the-same-
classloader security checks DriverManager does.

Just including the postgres driver classes directly in your jar file is
simpler, and that's what we mostly do when we need to bundle an
application with build-in PostgreSQL support. Not sure why it's not
working for you.

-- Mark Lewis

On Mon, 2005-11-21 at 15:27 -0800, Benjamin Stookey wrote:
> I realize that it's not possible to nest the jar in
> another jar, but I was wondering if anyone could give
> me a suggestion for deploying my application using
> this jar file.
>
> I did try extracting the jar to include the class
> files in my classpath (is this a bad idea?), but once
> I did that I get the "No suitable driver"
> SQLException. I'm probably making some blundering
> mistake with my classpath, but I can't figure it out.
>
> How have other people done this? Ideally, I'd like my
> application to be in one jar file to make it easier
> for my users. I'm still hoping this is possible...
>
> Thanks for the help,
> -Ben
>
> /**
> * @develEnv ECLIPSE
> * @javaVer JAVA 1.4.2_08
> * @OPSystem SUSE LINUX
> */
>
>
>
>
> ____________________
______________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Benjamin Stookey

2005-11-22, 1:23 pm

So if I extract the jar and include the class files in
my project classpath, do I still instantiate the
driver using:

Class.forName("org.postgresql.Driver").newInstance();

I appologize for my ignorance on this one.

Below is the .classpath file created by Eclipse. The
extracted jar is excluded from the source, but
included as a library. However, I get the "no suitable
driver" SQLException. Also, when I included the Jar as
a library it worked fine, just when I come to
deploying this it gets complicated.

Thanks,
-Ben

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
excluding="org/|org/postgresql/|org/|org/|org/postgresql
/|org/postgresql/core/|org/postgresql/core/types/|org/postgresql/core/v2/|org/po
stgresql/core/v3/|org/postgresql/ds/|org/postgresql/ds/common/|org/postgresql/fa
stpath/|org/postgresql/geometric/|org/postgresql/jdbc2/|org/postgresql/jdbc2/opt
ional/|org/postgresql/jdbc3/|org/postgresql/largeobject/|org/postgresql/ssl/|org
/postgresql/translation/|org/postgresql/util/|org/postgresql/xa/|org/postgresql/
jdbc3/|org/postgresql/|org/" kind="src" path=""/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER
"/>
<classpathentry kind="lib" path="org"/>
<classpathentry kind="output" path="bin"/>
</classpath>


--- Mark Lewis <mark.lewis@mir3.com> wrote:

> Well, you could actually nest the jar inside of
> another jar (we've done
> it here before), but you need to do some ugly things
> like using your own
> classloader and doing some tricks to avoid the
> must-be-the-same-
> classloader security checks DriverManager does.
>
> Just including the postgres driver classes directly
> in your jar file is
> simpler, and that's what we mostly do when we need
> to bundle an
> application with build-in PostgreSQL support. Not
> sure why it's not
> working for you.
>
> -- Mark Lewis
>
> On Mon, 2005-11-21 at 15:27 -0800, Benjamin Stookey
> wrote:
> in
> give
> once
> out.
> my
> easier
> broadcast)---------------------------
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map
> settings
>






____________________
______________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Benjamin Stookey

2005-11-28, 8:28 pm

I managed to resolve this problem, though not in the
manner I would have liked. For the sake of anyone who
finds this post I'll pass on my solution.

I used an Eclipse plugin called Fat Jar Eclipse Plugin
on Sourceforge:

http://sourceforge.net/projects/fjep/

This plugin allows me to nest any external jars
included in the project into a single deploy-able jar.

I would have prefer ed to simply include the unpacked
jar in my project, but after 3 days trying to it, this
tool was welcome relief.

If anyone has any suggestions on why I couldn't get
those class files loaded then I'd be happy to hear
it...

My file structure was
/Project
/Source
/org/postgresql/...

I added org/ as a class folder to the build path, but

Class.forName("org.postgresql.Driver").newInstance();
always failed.

Cheers,
-Ben

--- Benjamin Stookey <jamstooks@yahoo.com> wrote:

> So if I extract the jar and include the class files
> in
> my project classpath, do I still instantiate the
> driver using:
>
>

Class.forName("org.postgresql.Driver"). newInstance();[color
=darkred]
>
> I appologize for my ignorance on this one.
>
> Below is the .classpath file created by Eclipse. The
> extracted jar is excluded from the source, but
> included as a library. However, I get the "no
> suitable
> driver" SQLException. Also, when I included the Jar
> as
> a library it worked fine, just when I come to
> deploying this it gets complicated.
>
> Thanks,
> -Ben
>
> <?xml version="1.0" encoding="UTF-8"?>
> <classpath>
> <classpathentry
>[/color]
excluding="org/|org/postgresql/|org/|org/|org/ postgresql
>

/|org/postgresql/core/|org/postgresql/core/types/|org/postgresql/core/v2/|org/po
>

stgresql/core/v3/|org/postgresql/ds/|org/postgresql/ds/common/|org/postgresql/fa
>

stpath/|org/postgresql/geometric/|org/postgresql/jdbc2/|org/postgresql/jdbc2/opt
>

ional/|org/postgresql/jdbc3/|org/postgresql/largeobject/|org/postgresql/ssl/|org
>

/postgresql/translation/|org/postgresql/util/|org/postgresql/xa/|org/postgresql/
> jdbc3/|org/postgresql/|org/" kind="src" path=""/>
> <classpathentry kind="con"
> path="org.eclipse.jdt.launching.JRE_CONTAINER
> "/>
> <classpathentry kind="lib" path="org"/>
> <classpathentry kind="output" path="bin"/>
> </classpath>
>
>
> --- Mark Lewis <mark.lewis@mir3.com> wrote:
>
> things
> directly
> Stookey
> using
> class
> blundering
> like
> possible...
> map
>
>
>
>
>
> ____________________
______________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will
> ignore your desire to
> choose an index scan if your joining column's
> datatypes do not
> match
>






____________________
______________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Benjamin Stookey

2005-11-28, 8:28 pm

So I found a solution and thought I'd post it here for
anyone who found this post.

I used the Fat Jar Eclipse Plugin at sourceforge

http://fjep.sourceforge.net/

It allowed me to export my project as a single jar and
include any external jars I was using.

I tried for days to get the extracted jar to work as
class files, so when I found this plugin it was a
welcome relief.

If anyone has any idea what I was doing wrong though;
I'd love to hear it. I included the /org directory in
my project and added it as a class folder to the build
path, but


Class.forName("org.postgresql.Driver").newInstance();

always failed.

Cheers,
-Ben

--- Benjamin Stookey <jamstooks@yahoo.com> wrote:

> So if I extract the jar and include the class files
> in
> my project classpath, do I still instantiate the
> driver using:
>
>

Class.forName("org.postgresql.Driver"). newInstance();[color
=darkred]
>
> I appologize for my ignorance on this one.
>
> Below is the .classpath file created by Eclipse. The
> extracted jar is excluded from the source, but
> included as a library. However, I get the "no
> suitable
> driver" SQLException. Also, when I included the Jar
> as
> a library it worked fine, just when I come to
> deploying this it gets complicated.
>
> Thanks,
> -Ben
>
> <?xml version="1.0" encoding="UTF-8"?>
> <classpath>
> <classpathentry
>[/color]
excluding="org/|org/postgresql/|org/|org/|org/ postgresql
>

/|org/postgresql/core/|org/postgresql/core/types/|org/postgresql/core/v2/|org/po
>

stgresql/core/v3/|org/postgresql/ds/|org/postgresql/ds/common/|org/postgresql/fa
>

stpath/|org/postgresql/geometric/|org/postgresql/jdbc2/|org/postgresql/jdbc2/opt
>

ional/|org/postgresql/jdbc3/|org/postgresql/largeobject/|org/postgresql/ssl/|org
>

/postgresql/translation/|org/postgresql/util/|org/postgresql/xa/|org/postgresql/
> jdbc3/|org/postgresql/|org/" kind="src" path=""/>
> <classpathentry kind="con"
> path="org.eclipse.jdt.launching.JRE_CONTAINER
> "/>
> <classpathentry kind="lib" path="org"/>
> <classpathentry kind="output" path="bin"/>
> </classpath>
>
>
> --- Mark Lewis <mark.lewis@mir3.com> wrote:
>
> things
> directly
> Stookey
> using
> class
> blundering
> like
> possible...
> map
>
>
>
>
>
> ____________________
______________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will
> ignore your desire to
> choose an index scan if your joining column's
> datatypes do not
> match
>






____________________
______________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Andres Olarte

2005-11-29, 3:24 am

In your source folder (Source), are you including the drivers source files,
or the class files (the files that you extract from the driver jar file) ??

If you are using the drivers source then your aproach should work. But if
you are using the class files fomr the driver jar, it wont work. In that
case, you need to copy to the files to your build folder, or where your
compiler places your compiled files. I think this is your problem.

Benjamin Stookey

2005-11-29, 3:24 am

Thank you!

That's exactly what I was doing. I had the class files
outside of the /bin folder.

I moved them in there and it worked perfectly. When I
exported to jar I included all the output folders for
the project and that worked too!

The Fatjar plugin is cool, but I'm not sure what goes
on under the hood. This solution is much clearer.

Thanks again,
-Ben

--- Andres Olarte <olarte.andres@gmail.com> wrote:

> In your source folder (Source), are you including
> the drivers source files,
> or the class files (the files that you extract from
> the driver jar file) ??
>
> If you are using the drivers source then your
> aproach should work. But if
> you are using the class files fomr the driver jar,
> it wont work. In that
> case, you need to copy to the files to your build
> folder, or where your
> compiler places your compiled files. I think this
> is your problem.
>





____________________
______________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com