You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Bradford Pielech <br...@alphatech.com> on 2004/06/15 16:33:53 UTC

OJB and RMI

Hello all:

I am having running into a problem. I have an RMI server which intends to 
make calls to MySQL, using PersistencBroker. It fails when I call:

--------
PersistenceBroker pbroker = 
PersistenceBrokerFactory.defaultPersistenceBroker();
--------

with:
-------------
[BOOT] ERROR: Creation of PersistenceBrokerFactory (PBF) instance failed, 
can't get PBF class object
-----------

If I remove RMI from the equation, everything works fine, i.e. the 
PersistenceBroker calls succeed.  With RMI, the Remote Server gets a 
"NoClassDefFoundError" For the PersistenceBrokerFactory.

Is there possibly anything in the OJB configuration that might affect this 
environment?  Has anyone else been able to get OJB to work in this scenario?

Thanks,
Brad



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: RE : OJB and RMI

Posted by Thomas Dudziak <to...@first.fhg.de>.
Bradford Pielech wrote:

> No, we didnt see any error messages relating to this, probably because 
> the logging configuration is set in OJB.properties.

Well not exactly for two reasons: in rc7 and newer, logging settings can 
(and should) be specified in a separate file OJB-logging.properties. 
Also, a missing OJB.properties file should be noted in the boot log 
which does not need to be configured (it simply prints to stdout; e.g. 
the error message that you got is probably from the boot logger). I'll 
check the handling of a missing properties file.

> No, we did not need to do that.  All we needed to do was make sure 
> OJB.properties, spy.properties, and the various repository.xml files 
> could be found.  There wasn't any RMI specific steps that needed to be 
> taken beyond granting permission in the RMI.policy file. We didnt even 
> need to add ojb.jar to the codebase list.

That's nice then, no need to configure OJB to make it work with RMI :-)

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: RE : OJB and RMI

Posted by Thomas Dudziak <to...@first.fhg.de>.
Bradford Pielech wrote:

> No, we didnt see any error messages relating to this, probably because 
> the logging configuration is set in OJB.properties.

Just to keep you updated: I changed the logging in CVS so that now 
you'll get a warning when the OJB.properties file was not found (before 
it was only a info message which was not visible with the default settings).

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: RE : OJB and RMI

Posted by Bradford Pielech <br...@alphatech.com>.
No, we didnt see any error messages relating to this, probably because the 
logging configuration is set in OJB.properties.


>Did you get a log message about that ? If not, then I should add one to 
>make this easier for the next person with the same problem.



>No problem!
>Just for the record: do you have to use ClassHelper#setClassLoader to make 
>it work with RMI ?

No, we did not need to do that.  All we needed to do was make sure 
OJB.properties, spy.properties, and the various repository.xml files could 
be found.  There wasn't any RMI specific steps that needed to be taken 
beyond granting permission in the RMI.policy file. We didnt even need to 
add ojb.jar to the codebase list.

Brad


>Tom
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: RE : OJB and RMI

Posted by Thomas Dudziak <to...@first.fhg.de>.
Bradford Pielech wrote:
> Tom:
> 
>         Thanks for all your help.  Sometimes a fresh set of eyes can 
> really help.  The problem was a misspelled path on the OJB.properties 
> location.

Did you get a log message about that ? If not, then I should add one to 
make this easier for the next person with the same problem.

> 
>         Now you can get back to your usual task of helping solve real 
> OJB problems.
> 
> thanks again.

No problem!
Just for the record: do you have to use ClassHelper#setClassLoader to 
make it work with RMI ?

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: RE : OJB and RMI

Posted by Bradford Pielech <br...@alphatech.com>.
Tom:

         Thanks for all your help.  Sometimes a fresh set of eyes can 
really help.  The problem was a misspelled path on the OJB.properties location.

         Now you can get back to your usual task of helping solve real OJB 
problems.

thanks again.
Brad

At 06:31 PM 6/15/2004 +0200, you wrote:
>Bradford Pielech wrote:
>
>>Tom:
>>
>>         Thanks for the pointer, but it still isn't working.  Here is 
>> some sample code inside the RMI server that illustrates the failure:
>>
>>
>>       String s = 
>> RMIClassLoader.getClassAnnotation(PersistenceBrokerFactory.class);
>>       ClassLoader cl = RMIClassLoader.getClassLoader(s);
>>       org.apache.ojb.broker.util.ClassHelper.setClassLoader(cl);
>>       PersistenceBroker pbroker = 
>> PersistenceBrokerFactory.defaultPersistenceBroker();
>>       System.out.println("PBroker: " + pbroker.toString());
>>
>>This produces the error:
>>
>>-------
>>[BOOT] ERROR: Creation of PersistenceBrokerFactory (PBF) instance failed, 
>>can't get PBF class object
>>------
>>
>>
>>Any other ideas?
>
>Hmm, I'm by no means an RMI expert (at least in environments where 
>performance is not an issue, I'd rather use XML-RPC), but I wonder whether 
>the RMI classloader is correctly initialized to find OJB classes, or 
>whether OJB is correctly configured.
>Have a look into your OJB.properties file to see what the persistence 
>broker factory class is that would used (property 
>PersistenceBrokerFactoryClass). If this property is not defined, then the 
>above error results (there is no default value for this property). If it 
>is defined, then either the OJB.properties file could not be loaded (you 
>should see this in the same log where the above error message was output), 
>or the class could not be loaded.
>In the first case, the OJB.properties file could probably not loaded (you 
>can set its path manually using the system property "OJB.properties" prior 
>to using *any* OJB class).
>In the latter case, please try to load the class directly using the RMI 
>classloader:
>
>Class.forName(classname, true, cl);
>
>and see what happens then.
>
>Tom
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: RE : OJB and RMI

Posted by Thomas Dudziak <to...@first.fhg.de>.
Bradford Pielech wrote:

> Tom:
>
>         Thanks for the pointer, but it still isn't working.  Here is 
> some sample code inside the RMI server that illustrates the failure:
>
>
>       String s = 
> RMIClassLoader.getClassAnnotation(PersistenceBrokerFactory.class);
>       ClassLoader cl = RMIClassLoader.getClassLoader(s);
>       org.apache.ojb.broker.util.ClassHelper.setClassLoader(cl);
>       PersistenceBroker pbroker = 
> PersistenceBrokerFactory.defaultPersistenceBroker();
>       System.out.println("PBroker: " + pbroker.toString());
>
> This produces the error:
>
> -------
> [BOOT] ERROR: Creation of PersistenceBrokerFactory (PBF) instance 
> failed, can't get PBF class object
> ------
>
>
> Any other ideas?

Hmm, I'm by no means an RMI expert (at least in environments where 
performance is not an issue, I'd rather use XML-RPC), but I wonder 
whether the RMI classloader is correctly initialized to find OJB 
classes, or whether OJB is correctly configured.
Have a look into your OJB.properties file to see what the persistence 
broker factory class is that would used (property 
PersistenceBrokerFactoryClass). If this property is not defined, then 
the above error results (there is no default value for this property). 
If it is defined, then either the OJB.properties file could not be 
loaded (you should see this in the same log where the above error 
message was output), or the class could not be loaded.
In the first case, the OJB.properties file could probably not loaded 
(you can set its path manually using the system property 
"OJB.properties" prior to using *any* OJB class).
In the latter case, please try to load the class directly using the RMI 
classloader:

Class.forName(classname, true, cl);

and see what happens then.

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: RE : OJB and RMI

Posted by Bradford Pielech <br...@alphatech.com>.
Tom:

         Thanks for the pointer, but it still isn't working.  Here is some 
sample code inside the RMI server that illustrates the failure:


       String s = 
RMIClassLoader.getClassAnnotation(PersistenceBrokerFactory.class);
       ClassLoader cl = RMIClassLoader.getClassLoader(s);
       org.apache.ojb.broker.util.ClassHelper.setClassLoader(cl);
       PersistenceBroker pbroker = 
PersistenceBrokerFactory.defaultPersistenceBroker();
       System.out.println("PBroker: " + pbroker.toString());

This produces the error:

-------
[BOOT] ERROR: Creation of PersistenceBrokerFactory (PBF) instance failed, 
can't get PBF class object
------


Any other ideas?

Brad


At 04:54 PM 6/15/2004 +0200, you wrote:
>Bradford Pielech wrote:
>
>>The problem occurs the very first time we call anything to do with 
>>PersistenceBroker. Another thing of note is that the RMI server and OJB / 
>>MySQL libraries are all on the same machine.
>
>This seems to be a classloader problem, perhaps the thread's context 
>classloader is the RMI classloader (which does not find OJB's classes) ? 
>If you're using a fresh version of OJB (rc7 or CVS), then you can put 
>breakpoints into the org.apache.ojb.broker.util.ClassHelper#getClass and 
>#newInstance methods to see which classloader is used (the 
>PersistenceBrokerFactory is present otherwise you'd get a different error, 
>so this occurs within OJB). Using the ClassHelper class, you can also 
>define which classloader OJB uses.
>
>Tom
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: RE : OJB and RMI

Posted by Thomas Dudziak <to...@first.fhg.de>.
Bradford Pielech wrote:

> The problem occurs the very first time we call anything to do with 
> PersistenceBroker. Another thing of note is that the RMI server and 
> OJB / MySQL libraries are all on the same machine.

This seems to be a classloader problem, perhaps the thread's context 
classloader is the RMI classloader (which does not find OJB's classes) ? 
If you're using a fresh version of OJB (rc7 or CVS), then you can put 
breakpoints into the org.apache.ojb.broker.util.ClassHelper#getClass and 
#newInstance methods to see which classloader is used (the 
PersistenceBrokerFactory is present otherwise you'd get a different 
error, so this occurs within OJB). Using the ClassHelper class, you can 
also define which classloader OJB uses.

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE : OJB and RMI

Posted by Bradford Pielech <br...@alphatech.com>.
The problem occurs the very first time we call anything to do with 
PersistenceBroker. Another thing of note is that the RMI server and OJB / 
MySQL libraries are all on the same machine.

Brad



At 04:36 PM 6/15/2004 +0200, you wrote:
>A thread problem ?
>Does your problem occurs the first call or only next one ?
>
>________________________________________________
>Jean-Baptiste BRIAUD                      SYSDEO
>                                   www.sysdeo.com
>software engineer          www.eclipsetotale.com
>
> > -----Message d'origine-----
> > De : Bradford Pielech [mailto:bradford.pielech@alphatech.com]
> > Envoyé : mardi 15 juin 2004 16:34
> > À : OJB Users List
> > Objet : OJB and RMI
> >
> > Hello all:
> >
> > I am having running into a problem. I have an RMI server which intends to
> > make calls to MySQL, using PersistencBroker. It fails when I call:
> >
> > --------
> > PersistenceBroker pbroker =
> > PersistenceBrokerFactory.defaultPersistenceBroker();
> > --------
> >
> > with:
> > -------------
> > [BOOT] ERROR: Creation of PersistenceBrokerFactory (PBF) instance failed,
> > can't get PBF class object
> > -----------
> >
> > If I remove RMI from the equation, everything works fine, i.e. the
> > PersistenceBroker calls succeed.  With RMI, the Remote Server gets a
> > "NoClassDefFoundError" For the PersistenceBrokerFactory.
> >
> > Is there possibly anything in the OJB configuration that might affect this
> > environment?  Has anyone else been able to get OJB to work in this
> > scenario?
> >
> > Thanks,
> > Brad
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE : OJB and RMI

Posted by Jean-Baptiste BRIAUD <jb...@sysdeo.com>.
A thread problem ?
Does your problem occurs the first call or only next one ?

________________________________________________
Jean-Baptiste BRIAUD                      SYSDEO
                                  www.sysdeo.com
software engineer          www.eclipsetotale.com

> -----Message d'origine-----
> De : Bradford Pielech [mailto:bradford.pielech@alphatech.com]
> Envoyé : mardi 15 juin 2004 16:34
> À : OJB Users List
> Objet : OJB and RMI
> 
> Hello all:
> 
> I am having running into a problem. I have an RMI server which intends to
> make calls to MySQL, using PersistencBroker. It fails when I call:
> 
> --------
> PersistenceBroker pbroker =
> PersistenceBrokerFactory.defaultPersistenceBroker();
> --------
> 
> with:
> -------------
> [BOOT] ERROR: Creation of PersistenceBrokerFactory (PBF) instance failed,
> can't get PBF class object
> -----------
> 
> If I remove RMI from the equation, everything works fine, i.e. the
> PersistenceBroker calls succeed.  With RMI, the Remote Server gets a
> "NoClassDefFoundError" For the PersistenceBrokerFactory.
> 
> Is there possibly anything in the OJB configuration that might affect this
> environment?  Has anyone else been able to get OJB to work in this
> scenario?
> 
> Thanks,
> Brad
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org