users@glassfish.java.net

Re: OSGi bundle cannot find classes in glassfishv3/glassfish/lib/*.jar files

From: Sahoo <Sahoo_at_Sun.COM>
Date: Sat, 10 Apr 2010 05:41:11 +0530

Bryce,

That's expected behavior. OSGi bundles can't see contents of lib
directory. If your jar files depend on Java SE APIs only (in other
words, they don't depend on any Java EE APIs), then you can copy them to
java.ext.dirs to get the desired behavior. If you start GlassFish using
asadmin command, java.ext.dirs is set to domain1/lib/ext.

If your jar files do depend on EE APIs, then you have to use a special
ClassLoader that appserver provides in your Class.forName() call. To
obtain that ClassLoader, you have to depend on some GlassFish APIs. Let
me know if this is what you need.

Thanks,
Sahoo

glassfish_at_javadesktop.org wrote:
> I have an OSGi bundle that attempts to load a class by name (Class.forName(...)), and is getting a ClassNotFoundException.
>
> The jar containing the class is located in the glassfishv3/glassfish/lib/ directory.
>
> My bundle is located in glassfishv3/glassfish/domains/domain1/autodeploy/bundles/
>
> I do not specifically import the package through the manifest file, but I do have the manifest entry "DynamicImport-Package:*"
>
> I am using glassfish v3 final, with all the latest updates.
>
> Is the behavior I am seeing expected or a bug? If it is expected behavior, is there another place where I can put my jar files so that my bundle will be able to see them, without making them into bundles or embedding them within my bundle?
>
> Thanks in advance
> Bryce
> [Message sent by forum member 'bhar99328']
>
> http://forums.java.net/jive/thread.jspa?messageID=396190
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>