db4o Developer Community

db4o open source object database, native to Java and .NET
Welcome to db4o Developer Community Sign in | Join
in Search
More Search Options

Causes of GenericObject returned from a query

Last post 08-28-2008, 07:47 PM by mjablonski. 5 replies.
Sort Posts: Previous Next
  •  08-26-2008, 03:59 PM 50772

    Causes of GenericObject returned from a query

    Hi,

    I am trying to figure out the cause of getting an ObjectList of GenericObject back from a query instead of my own application's objects. I am using 6.4 (haven't tried 7.2 yet but will soon if I can't get around this). It's a web application that runs under Tomcat, everything is on one node but multithreaded by http request so I'm using Db4o.openServer(config, filename, 0) with a ThreadLocal to hold ObjectContainers (server.openClient()). During runtime, the database is opened read-only (it is loaded with data during a development step).

    Things work fine if I run my application (through Tomcat) against the classes that Eclipse creates. Db4o is damn fast. However when I do an ant build (using the same jdk, which is MacOSX Java 1.5) and deploy to Tomcat (same version), the queries return GenericObject and things crash (due to classcast exceptions).

    The info available on these forums seem to suggest that this will happen if the classes change fully qualified names in any way. This is not the case. In fact, I put in some diagnostic code at the point the query comes back to do a forName on my class, and it does work. If I log the GenericObject directly (toString, that is), it shows up as "(G) com.blah.MyClass" - the correct fully qualified class name.

    I haven't dug into the db4o source code yet, and would prefer not to at this point. Does anyone know of all reasons that db4o would return GenericObject, besides the class not being available by its exact name?

     Thanks!

  •  08-26-2008, 04:43 PM 50773 in reply to 50772

    Re: Causes of GenericObject returned from a query

    In my experience, GenericObject is returned when your classes are not deployed to both the client and server parts of your application.  In Java I believe (sorry, I'm a .NET guy) this often comes down to an incorrect classpath.  I can't say how that would change between an Eclipse build and an Ant build but that is usually the problem.

    HTH,

    Brett 

  •  08-26-2008, 06:25 PM 50774 in reply to 50772

    Re: Causes of GenericObject returned from a query

    Hi,

    sounds like an class-loader-issue... please make sure, that db4o-*.jars are located only in WEB-INF/lib of your web-application and NOT in any Tomcat/lib-directory.

    Does it help?

    Cheers, Maik


    http://db4o.blogspot.com/
  •  08-26-2008, 06:50 PM 50776 in reply to 50774

    Re: Causes of GenericObject returned from a query

    Interesting idea! When running Tomcat against an Eclipse-created class folder (the first case which works), the dbo jars are in WEB-INF/lib, but when I do the ant build+deploy (the second case, which does not work), everything outside the war is copied to the Tomcat common lib. I'll try modify the build to pull the dbo jars into the application's war file and see if that helps. Thanks!

  •  08-28-2008, 06:56 PM 50821 in reply to 50776

    Re: Causes of GenericObject returned from a query

    It did indeed fix the problem. All I had to do was package the db4o jars with the app in the war file and it all works fine. I also found a page in the documentation that described the classloader issue (I can't find it now) that seems to confirm it but doesn't specifically address app server deployments. Thanks for the help. Awesome tool, I'm hoping it will save me a lot of work going forward.

  •  08-28-2008, 07:47 PM 50822 in reply to 50821

    Re: Causes of GenericObject returned from a query

View as RSS news feed in XML