pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
NoClassDefFoundErrors
4+ messages / 2 participants
[nested] [flat]

* NoClassDefFoundErrors
@ 2009-03-18 08:01  Robin Rosenberg <robin.rosenberg.lists@dewire.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Robin Rosenberg @ 2009-03-18 08:01 UTC (permalink / raw)
  To: pgsql-jdbc


Under various error conditions (and possibly otherwise) we get noclassdeffound errors instead of an SQL exception.


Caused by: java.lang.NoClassDefFoundError: org/postgresql/core/Parser
	at org.postgresql.core.v3.QueryExecutorImpl.parseQuery(QueryExecutorImpl.java:77)
	at org.postgresql.core.v3.QueryExecutorImpl.createParameterizedQuery(QueryExecutorImpl.java:55)


java.lang.NoClassDefFoundError: org/postgresql/core/Parser
	at org.postgresql.core.v3.QueryExecutorImpl.parseQuery(QueryExecutorImpl.java:77)
	at org.postgresql.core.v3.QueryExecutorImpl.createParameterizedQuery(QueryExecutorImpl.java:55)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.<init>(AbstractJdbc2Statement.java:134)
	at org.postgresql.jdbc3.AbstractJdbc3Statement.<init>(AbstractJdbc3Statement.java:41)
	at org.postgresql.jdbc4.AbstractJdbc4Statement.<init>(AbstractJdbc4Statement.java:30)
	at org.postgresql.jdbc4.Jdbc4Statement.<init>(Jdbc4Statement.java:30)
	at org.postgresql.jdbc4.Jdbc4PreparedStatement.<init>(Jdbc4PreparedStatement.java:23)
	at org.postgresql.jdbc4.Jdbc4PreparedStatement.<init>(Jdbc4PreparedStatement.java:18)
	at org.postgresql.jdbc4.Jdbc4Connection.prepareStatement(Jdbc4Connection.java:37)
	at org.postgresql.jdbc3.AbstractJdbc3Connection.prepareStatement(AbstractJdbc3Connection.java:266)
	at org.postgresql.jdbc2.AbstractJdbc2Connection.prepareStatement(AbstractJdbc2Connection.java:187)

These are just a few examples. NoClassDefFoundError seems to occur in many situations and so far it has
always been related to an underlying exception of some kind. These particular cases I'm not sure about, and
cannot verify, but I suspect a bad parameter or even an SQL syntax error.

So, my question is: How do I get error handling to work? All errors don't lead to NoClassDefFoundError.

We're currently on version 8.3-603 of the driver within glassfish 2.1

-- robin



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: NoClassDefFoundErrors
@ 2009-03-18 08:45  Oliver Jowett <oliver@opencloud.com>
  parent: Robin Rosenberg <robin.rosenberg.lists@dewire.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Oliver Jowett @ 2009-03-18 08:45 UTC (permalink / raw)
  To: Robin Rosenberg <robin.rosenberg.lists@dewire.com>; +Cc: pgsql-jdbc

Robin Rosenberg wrote:
> Under various error conditions (and possibly otherwise) we get noclassdeffound errors instead of an SQL exception.
> 
> Caused by: java.lang.NoClassDefFoundError: org/postgresql/core/Parser
> 	at org.postgresql.core.v3.QueryExecutorImpl.parseQuery(QueryExecutorImpl.java:77)
> 	at org.postgresql.core.v3.QueryExecutorImpl.createParameterizedQuery(QueryExecutorImpl.java:55)

> We're currently on version 8.3-603 of the driver within glassfish 2.1

$ jar tvf postgresql-8.3-603.jdbc2.jar  | grep Parser.class
  2904 Thu Jan 31 03:01:38 NZDT 2008 org/postgresql/core/Parser.class

The class is there, so either you have a mangled copy of the driver jar,
or glassfish is breaking something, or you have encountered a JVM bug.

Parser is an integral part of the driver, used whenever you have a query
that contains any of these characters: '"-/$

-O



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: NoClassDefFoundErrors
@ 2009-03-18 08:59  Robin Rosenberg <robin.rosenberg.lists@dewire.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Robin Rosenberg @ 2009-03-18 08:59 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

onsdag 18 mars 2009 09:45:56 skrev Oliver Jowett <oliver@opencloud.com>:
> Robin Rosenberg wrote:
> > Under various error conditions (and possibly otherwise) we get noclassdeffound errors instead of an SQL exception.
> > 
> > Caused by: java.lang.NoClassDefFoundError: org/postgresql/core/Parser
> > 	at org.postgresql.core.v3.QueryExecutorImpl.parseQuery(QueryExecutorImpl.java:77)
> > 	at org.postgresql.core.v3.QueryExecutorImpl.createParameterizedQuery(QueryExecutorImpl.java:55)
> 
> > We're currently on version 8.3-603 of the driver within glassfish 2.1
> 
> $ jar tvf postgresql-8.3-603.jdbc2.jar  | grep Parser.class
>   2904 Thu Jan 31 03:01:38 NZDT 2008 org/postgresql/core/Parser.class
> 
> The class is there, so either you have a mangled copy of the driver jar,
> or glassfish is breaking something, or you have encountered a JVM bug.
> Parser is an integral part of the driver, used whenever you have a query
> that contains any of these characters: '"-/$
> 
> -O
> 

Indeed it is there. NoClassDefFoundError is ofter confused with ClassNotFoundException. 

NoClassDefFoundError means the class was found, but it couldn't be loaded because
of another class was needed for the base class or interface or an exception was thrown
in a static initializer during class loading. There might be other reasons, but those are
the ones I know about. The problem is that these errors are very hard to debug, so I was
hoping for a clue.

-- robin





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: NoClassDefFoundErrors
@ 2009-03-18 09:20  Oliver Jowett <oliver@opencloud.com>
  parent: Robin Rosenberg <robin.rosenberg.lists@dewire.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Oliver Jowett @ 2009-03-18 09:20 UTC (permalink / raw)
  To: Robin Rosenberg <robin.rosenberg.lists@dewire.com>; +Cc: pgsql-jdbc

Robin Rosenberg wrote:

> Indeed it is there. NoClassDefFoundError is ofter confused with ClassNotFoundException. 
> 
> NoClassDefFoundError means the class was found, but it couldn't be loaded because
> of another class was needed for the base class or interface or an exception was thrown
> in a static initializer during class loading. There might be other reasons, but those are
> the ones I know about. The problem is that these errors are very hard to debug, so I was
> hoping for a clue.

I do understand the difference between the two.

NoClassDefFoundError doesn't behave as you describe. It means, as the
name says, that the named class could not be loaded.

It's thrown as a *result* of trying to resolve the named class, perhaps
because it is named as a base class or interface during classloading of
another class, or because it's referenced by a method descriptor that
needs to be resolved (some time after classloading). In this case, the
JVM is trying to resolve a call from QueryExecutorImpl (which is loaded,
initialized, and executing) to a static method on Parser. The first time
such a method is called, the JVM attempts to load and initialize Parser
so that it can resolve the method descriptor. When it cannot find
Parser.class, a NoClassDefFoundError is thrown.

I believe the class named in the NoClassDefFoundError is always the
ultimately missing class. (So if class A exists, but initialization of A
fails because class B does not exist, then you get a
NoClassDefFoundError: B as a result of trying to resolve A)

Incidentally, exceptions in static initializers during class
initialization are reported by an ExceptionInInitializerError, *not*
NoClassDefFoundError.

I would suggest taking a hard look at how Glassfish is loading the
driver classes, sounds like it is mangling things along the way somehow.

-O



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2009-03-18 09:20 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-03-18 08:01 NoClassDefFoundErrors Robin Rosenberg <robin.rosenberg.lists@dewire.com>
2009-03-18 08:45 ` Oliver Jowett <oliver@opencloud.com>
2009-03-18 08:59   ` Robin Rosenberg <robin.rosenberg.lists@dewire.com>
2009-03-18 09:20     ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox