Salut,
techi_amol wrote:
> Hi,
>
> Here is something more info.
>
> I changed the packaging so now i deployed
> grizzly-servlet-webserver_1.8.1.SNAPSHOT.jar as an independent osgi bundle,
> and i modified my the Manifest my osgi archive to remove Bundle-Classpath
> attribute and use "Import-Package: com.sun.grizzly.standalone.servlet" to
> reference the ServletLauncher.
> This works. I am able to deploy me war and test the servlet. But i really
> want to understand why did this work
>
> The GrizzlyClassloader does something different than the osgi's
> BundleClassloader. Specially with regards to system packages. But what?
The classloader is constructed the following way:
> public String appendWarContentToClassPath(String appliPath) throws MalformedURLException, IOException{
>
> String path;
> File file = null;
> URL appRoot = null;
> URL classesURL = null;
> if (appliPath != null &&
> (appliPath.endsWith(".war") || appliPath.endsWith(".jar"))) {
> file = new File(appliPath);
> appRoot = new URL("jar:file:" +
> file.getCanonicalPath() + "!/");
> classesURL = new URL("jar:file:" +
> file.getCanonicalPath() + "!/WEB-INF/classes/");
> path = ExpandJar.expand(appRoot);
> } else {
> path = appliPath;
> classesURL = new URL("file://" + path + "WEB-INF/classes/");
> appRoot = new URL("file://" + path);
> }
>
> System.out.println("Running from: " + new File(path).getAbsolutePath());
> URL[] urls = null;
> File libFiles = new File(path + "/WEB-INF/lib");
> int arraySize = (appRoot == null ? 1:2);
> if (libFiles.exists() && libFiles.isDirectory()){
> urls = new URL[libFiles.listFiles().length + arraySize];
> for (int i=0; i < libFiles.listFiles().length; i++){
> urls[i] = new URL("jar:file://" + libFiles.listFiles()[i] + "!/");
> }
> } else {
> urls = new URL[arraySize];
> }
>
> urls[urls.length -1] = classesURL;
> urls[urls.length -2] = appRoot;
> ClassLoader urlClassloader = new URLClassLoader(urls,
> Thread.currentThread().getContextClassLoader());
> Thread.currentThread().setContextClassLoader(urlClassloader);
> return path;
> }
Grizzly augment the actual Context classloader.
>
> Does the above sentence even make sense?
I guess the Grizzly Classloader is doing something it shouldn't...I need
to read about, but I suspect I need to add a new method where you can
set the BundleClassloader instead of using the ContextClassloader.
Can you try the following (maybe I'm saying something really stupid). In
your code, just do:
Classloader previousCL = Thread.getContextClassloader();
Thread.setContextClassloader(BundleClassloader);
ServletLaucher.start();
Thread.setContextClassloader(previousCL);
I suspect it might works, which means I will need to expose a new API
for setting the runtime classloader.
Thanks!
-- Jeanfrancois
>
> cheers
> a.
>
>
>
>
> Jeanfrancois Arcand-2 wrote:
>> Salut,
>>
>> techi_amol wrote:
>>> Hi all,
>>>
>>> No rule change as far as i know. To make sure I checked using the
>>> "packages"
>>> command on the osgi prompt, it did recognize javax.management as a system
>>> package. Below is the detail that the packages command printed out
>>>
>>> javax.management; version="0.0.0"<System Bundle [0]>
>>> System Bundle [0] imports
>>>
>>> initial_at_reference:file:plugins/org.eclipse.update.configurator_3.2.100.v20070322.jar/
>>> [15] imports
>>>
>>> Maybe you can try to reproduce this. I am running osgi using
>>> org.eclipse.osgi_3.3.0.200704022148.jar. My dir structure looks like this
>>> equinox-osgi-runtime
>>> \configuration\config.ini
>>> \plugins\org.eclipse.equinox.common_3.3.0.200704022148.jar
>>> \plugins\org.eclipse.equinox.registry_3.3.0.v20070318.jar
>>> \plugins\org.eclipse.osgi.services_3.1.100.200704022148.jar
>>> \plugins\org.eclipse.update.configurator_3.2.100.v20070322.jar
>>>
>>>
>>> ################################################
>>> #############contents in the config.ini ##################
>>> ################################################
>>> #Eclipse Equinox Runtime Configuration File
>>> osgi.bundles=./plugins/org.eclipse.equinox.common_at_2:start,
>>> ./plugins/org.eclipse.update.configurator_at_3:start,
>>> ./plugins/org.eclipse.equinox.registry_at_start,
>>> ./plugins/org.eclipse.osgi.services_at_start
>>> osgi.bundles.defaultStartLevel=4
>>> eclipse.ignoreApp=true
>>> # End of file marker - must be here
>>> eof=eof
>>>
>>> Also i should mention this, the way i have created my osgi bundle is by
>>> including the grizzly-servlet-webserver-1.8.0.jar inside the bundle
>>> archive
>>> and using Bundle-Classpath attribute in the manifest.
>>
>> OK I will try that. It's an holiday here so I will not be able to try it
>> until next Tuesday. But your information help...Grizzly classloader is
>> build using:
>>
>>> ClassLoader urlClassloader = new URLClassLoader(urls,
>>> Thread.currentThread().getContextClassLoader());
>>> Thread.currentThread().setContextClassLoader(urlClassloader);
>> It looks like the ClassLoader starting the application doesn't have
>> javax.management.* in its list. I guess it needs to be explicitly
>> listed....that's really strange. If you add to the Bundle-Classpath the
>> location of the jdk rt.jar, does it make a difference (it doesn't make
>> any sense, but just to see...)
>>
>>
>> Thanks
>>
>> -- Jeanfrancois
>>
>>
>>
>>
>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>>
>>
>