[kf-users] Knopflerfish & RMI
Gunnar Ekolin
gunnar at ekolin.se
Sun Dec 21 10:01:02 CET 2008
Ok, another see bellow then...
On Sat, Dec 20, 2008 at 12:54:45PM +0200, Alin Dreghiciu wrote:
> Thanx Gunnar for your answer,
>
> See bellow.
>
> On Fri, Dec 19, 2008 at 3:44 PM, Gunnar Ekolin <gunnar at ekolin.se> wrote:
> > On Fri, Dec 19, 2008 at 03:13:52PM +0200, Alin Dreghiciu wrote:
> >> Hi guys,
> >>
> > ...
> >
> >> Then by setting the rmi logging on via
> >> "-Djava.rmi.server.logCalls=true", the following is logged inside the
> >> server part that runs within kf:
> >>
> >> java.lang.NoClassDefFoundError: sun/reflect/SerializationConstructorAccessorImpl
> >>
> >> So, adding boot delegation for "sun.*" solved the problem.
> >>
> >
> > Since the RMI code called from the bundle wants to load a class in
> > package that does not start with "java." then that package must either
> > be imported by the bundle or made available via boot delegation.
>
> The exception does not appear by the moment of starting up the rmi
> registry or exporting the remote object. It appears by the moment that
> the client code lookup the remote object, and it appears on the server
> part. And in my view I should not import the package or have boot
> delegation because my code uses classes from java.rmi.* package which
> as stated by the specs should automatically be using the system class
> loaded. If that code wanna load any class from its own class loader
> (hence system class loader in this case) it is its own business and I
> should not import it or have boot delegation for it. This is like with
> the URL class: the fact that by the end the actual classes are sun
> classes it does not make me import them or have boot delegation setup
> for sun classes.
Since you do get the exception, the sun code actually requests a
bundle-classloader instance to load the class (and not the
class-loader that loaded the RMI-classes). The bundle classloader
requires the import/boot delegation. We have seen this behaviour also
in relation to Swing PLAF classes thats the reason for the default
xargs file to use '*' for the boot-delegation.
> > My guess is that different frameworks and versions of them uses
> > different default settings for the boot delegation property. It can
> > also be that someone has set up a context classloader that searches
> > the call stack for a class loader that can load the requested class.
>
> I do not think that is the case. Felix only delegates for java.*, and
> for the eclipse case I am controlling the boot delegation property
> (I'm using pax Runner) and the value is again only "java.*".
> Also there is no context class loader involved as I specifically set
> the context class loader to "null" while setting up the RMI registry
> and exporting teh remote object.
Ok, we will have too look into this in more details then.
> > The default xargs-file (props.xargs) comming with KF 2.1, 2.2 actually
> > sets boot delegation to '*'.
>
> I'm using Pax Runner and there is no props.xargs involved, so the
> default value of that property is used. But is that a good thing that
> you do by default boot delegation for "*"? This will make unaware
> people think that is normal that they use for example javax.* classes
> and do not import them, which is not the case.
The default boot delegation if you do not set the system property for
it is 'java.'* and nothing else. I fully agree with you, i.e., I do
not like that '*' either it is there to avaoid similar problems as
yours but for swing look and feel classes. Again swing code assumes
that any classloader can be used to load any code available in the JVM
jars which is not try in OSGi. For that to work the classloaded that
loaded swing must be used, not an arbitrary bundle class loader that
have loaded some swing-subclass or soo. Guess it would be of interest
to track this down a litle further.
\GE
More information about the Knopflerfish-users
mailing list