dev@glassfish.java.net

Re: felix classloading problem for META-INF/services file

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Wed, 24 Sep 2008 15:31:13 -0700

Hi Richard,

Thanks for the responses. Some background:

With Jerome's help, our web applications (admingui.war -- which
administers GF v3) can access OSGi bundles in the modules directory. We
do this in 2 ways from our META-INF/MANIFEST file of our .war file:

    1) HK2-Import-Bundles -- allows us to staticly define bundles which
we need access to from the .war file;
    2) Glassfish-require-services -- allows us to dynamically find
bundles which implement a particular HK2 @Service (we use this to locate
our plugins).

All this works great (so far). Our classes in WEB-INF/lib/* can access
classes from the bundles which are found by one of the 2 methods above.

Here's what I'm having trouble with... I want to rebundle a part of
Woodstock to provide a new theme (FYI, Woodstock is a JSF component
library which supports "theming" their gui components). I am inlining
the contents of "webui-suntheme.jar" which I want in my OSGi bundle,
along with some of my own files (i.e. the class that implements the HK2
@Service required for #2 above, and some other files). It all seems to
work as expected, except that part of the WS theme .jar file is a
META-INF/services/ file which we need to read... this is done by the
Woodstock framework. It works if we don't use OSGi (i.e. we put it in
the WEB-INF/lib directory), but since we want to to work as a plugin...
it doesn't work.

I don't have a good way to change their code to use bundle entry-related
methods. They are using the "sun.misc.Service" class to read this file. :(

What (if anything) can I do?

Thanks,

Ken

Richard S. Hall wrote:
> Responding again...
>
> I realize since this is in META-INF, then it is likely not going to be
> an export. So, the only way to access this would be via the bundle
> entry-related methods. Not sure what the console-theme-plugin bundle
> is doing here.
>
> -> richard
>
> Ken Paulsen wrote:
>>
>>
>> Hi everyone,
>>
>> I am trying to use the "console-theme-plugin-10.0.0-SNAPSHOT.jar"
>> bundle. When the code attempts to retrieve the file:
>> "META-INF/services/com.sun.webui.theme.ThemeService" from the jar, it
>> cannot find it (see trace below).
>>
>> I am completely lost on how to fix this. Ideas? File exists in the
>> bundle, not sure if I need a special export for it -- do I? I am
>> accessing this via Jerome's "Glassfish-require-services" feature from
>> the webapp classloader. MANIFEST.MF is also attached.
>>
>> Thanks!
>>
>> Ken
>>
>>
>> SEVERE: StandardWrapperValve[FacesServlet]: PWC1406:
>> Servlet.service() for servlet FacesServlet threw exception
>> java.lang.IllegalArgumentException: Failed to set property (height)
>> with value (1), which is of type (java.lang.String). Expected type
>> (int). This occured on the component named (sun_image5) of type
>> (com.sun.webui.jsf.component.ImageComponent).
>> at
>> com.sun.jsftemplating.component.ComponentUtil.setOption(ComponentUtil.java:482)
>>
>> at
>> com.sun.jsftemplating.component.factory.ComponentFactoryBase.setOption(ComponentFactoryBase.java:134)
>>
>> at
>> com.sun.jsftemplating.component.factory.ComponentFactoryBase.setOptions(ComponentFactoryBase.java:106)
>>
>> at
>> com.sun.jsftemplating.component.factory.sun.ImageComponentFactory.create(ImageComponentFactory.java:65)
>>
>> at
>> com.sun.jsftemplating.component.ComponentUtil.createChildComponent(ComponentUtil.java:400)
>>
>> at
>> com.sun.jsftemplating.layout.descriptors.LayoutComponent.getChild(LayoutComponent.java:290)
>>
>> at
>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:552)
>>
>> at
>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:581)
>>
>> at
>> com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:581)
>>
>> at
>> com.sun.jsftemplating.layout.LayoutViewHandler.createView(LayoutViewHandler.java:251)
>>
>> at
>> com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:205)
>>
>> at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
>> at
>> com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
>>
>> at
>> com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
>> at
>> com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.execute(PartialTraversalLifecycle.java:80)
>>
>> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:431)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:337)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:218)
>>
>> at
>> com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
>> at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:250)
>>
>> at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:218)
>>
>> at
>> org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:460)
>>
>> at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139)
>>
>> at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
>>
>> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
>> at
>> com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
>>
>> at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
>>
>> at
>> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
>> at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
>>
>> at
>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
>>
>> at
>> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
>> at
>> org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:307)
>>
>> at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
>>
>> at
>> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
>>
>> at
>> com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:610)
>>
>> at
>> com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:547)
>>
>> at
>> com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:783)
>>
>> at
>> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
>>
>> at
>> com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
>>
>> at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
>>
>> at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
>>
>> at
>> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
>>
>> at
>> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
>>
>> at
>> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
>>
>> at
>> com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
>>
>> at
>> com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
>> Caused by: javax.faces.FacesException:
>> java.lang.NoClassDefFoundError: com/sun/webui/theme/ThemeService
>> at
>> javax.faces.component.UIComponentBase$AttributesMap.put(UIComponentBase.java:1651)
>>
>> at
>> javax.faces.component.UIComponentBase$AttributesMap.put(UIComponentBase.java:1526)
>>
>> at
>> com.sun.jsftemplating.component.ComponentUtil.setOption(ComponentUtil.java:480)
>>
>> ... 53 more
>> Caused by: java.lang.NoClassDefFoundError:
>> com/sun/webui/theme/ThemeService
>> at java.lang.ClassLoader.defineClass1(Native Method)
>> at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
>> at
>> org.apache.felix.framework.searchpolicy.ContentClassLoader.findClass(ContentClassLoader.java:214)
>>
>> at
>> org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClassFromModule(ContentClassLoader.java:85)
>>
>> at
>> org.apache.felix.framework.searchpolicy.ContentLoaderImpl.getClass(ContentLoaderImpl.java:162)
>>
>> at
>> org.apache.felix.framework.searchpolicy.R4Wire.getClass(R4Wire.java:101)
>> at
>> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.searchImports(R4SearchPolicyCore.java:505)
>>
>> at
>> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClassOrResource(R4SearchPolicyCore.java:466)
>>
>> at
>> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(R4SearchPolicyCore.java:185)
>>
>> at
>> org.apache.felix.framework.searchpolicy.R4SearchPolicy.findClass(R4SearchPolicy.java:45)
>>
>> at
>> org.apache.felix.moduleloader.ModuleImpl.getClass(ModuleImpl.java:179)
>> at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1503)
>> at
>> org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:358)
>> at
>> org.jvnet.hk2.osgiadapter.OSGiModuleImpl$2.loadClass(OSGiModuleImpl.java:315)
>>
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>> at
>> org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1413)
>>
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>> at java.lang.Class.forName0(Native Method)
>> at java.lang.Class.forName(Class.java:247)
>> at sun.misc.Service$LazyIterator.next(Service.java:271)
>> at
>> com.sun.webui.theme.SPIThemeFactory.findThemeServiceReferences(SPIThemeFactory.java:611)
>>
>> at
>> com.sun.webui.theme.SPIThemeFactory.findThemeReferences(SPIThemeFactory.java:544)
>>
>> at
>> com.sun.webui.theme.SPIThemeFactory.getThemeResources(SPIThemeFactory.java:464)
>>
>> at
>> com.sun.webui.theme.SPIThemeFactory.getTheme(SPIThemeFactory.java:178)
>> at
>> com.sun.webui.jsf.util.ThemeUtilities.getTheme(ThemeUtilities.java:138)
>> at
>> com.sun.webui.jsf.component.ImageComponent.getTheme(ImageComponent.java:919)
>>
>> at
>> com.sun.webui.jsf.component.ImageComponent.initThemeImage(ImageComponent.java:914)
>>
>> at
>> com.sun.webui.jsf.component.ImageComponent.getHeight(ImageComponent.java:286)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at
>> javax.faces.component.UIComponentBase$AttributesMap.put(UIComponentBase.java:1636)
>>
>> ... 55 more
>> Caused by: java.lang.ClassNotFoundException:
>> com.sun.webui.theme.ThemeService
>> at
>> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(R4SearchPolicyCore.java:198)
>>
>> at
>> org.apache.felix.framework.searchpolicy.R4SearchPolicy.findClass(R4SearchPolicy.java:45)
>>
>> at
>> org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClass(ContentClassLoader.java:109)
>>
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>> ... 91 more
>> Caused by: java.lang.ClassNotFoundException:
>> com.sun.webui.theme.ThemeService
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>> at
>> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.searchDynamicImports(R4SearchPolicyCore.java:602)
>>
>> at
>> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClassOrResource(R4SearchPolicyCore.java:478)
>>
>> at
>> org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(R4SearchPolicyCore.java:185)
>>
>> ... 95 more
>>
>>
>>
>> FYI.... I worked-around my previous problem, although I'm not happy
>> with the work-a-round. I marked 2 packages that the bundle was
>> importing & exporting as "optional" imports to get the bundle to load
>> -- removing the version information from import in the Manifest also
>> fixed the problem, but I couldn't figure out how to create a pom.xml
>> that dropped the version information. If anyone knows what was wrong
>> w/ previous pom.xml or MANIFEST that prevented it from finding
>> classes in the same bundle which imported/exported them, let me
>> know. - Ken
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>