JB, I'm not sure how you can help me here, except maybe to type in
some diagnostic suggestions -- or to tell me where there's a working
example of using the hibernate-validator feature that is included in
Karaf that I can crib from.
Let me explain how I got here. I needed to use bean validation.
The hibernate-validation feature in karaf enterprise seemed like what
I wanted, but I don't have the necessary maven repos to touch the
enterprise feature collection. So I made my own feature with the same
bundles, and included the code I sent along to avoid fussing with the
SPI.
Thus, my feature includes the bundle from glassfish that contains the
EL implementation with com.sun.el in it.
Meanwhile, all this goes into a Karaf assembly that also has pax-web.
As we have seen, pax-web also has
com/sun/el/ExpressionFactoryImpl.class. But it does not seem to export
it.
However, package:exports says:
karaf@root>package:exports | grep com.sun.el
com.sun.el | 2.2.4
| 174 | org.glassfish.web.javax.el
Note the lack of '-d'.
bundle:headers for the pax-web bundle does not show an export of com.sun.el.
Here's one more backtrace: bundle 65 does not import com.sun.el, so I
don't see how it can possibly find it.
All the code I have here works in a simpler pax-exam test which does
not involve a web service; but it's all the same bundles.
Caused by: javax.el.ELException: Provider
com.sun.el.ExpressionFactoryImpl not found
at
javax.el.FactoryFinder.newInstance(FactoryFinder.java:101)[65:javax.el-api:2.2.4]
at javax.el.FactoryFinder.find(FactoryFinder.java:197)[65:javax.el-api:2.2.4]
at
javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:189)[65:javax.el-api:2.2.4]
at
javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:160)[65:javax.el-api:2.2.4]
at
org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm.<clinit>(InterpolationTerm.java:60)
... 63 more
Caused by: java.lang.ClassNotFoundException:
com.sun.el.ExpressionFactoryImpl not found by
org.apache.cxf.cxf-rt-transports-http [102]
at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1558)
at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1998)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_60]
at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1919)
at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:959)
at
org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176)[205:org.ops4j.pax.web.pax-web-jetty:4.2.2]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)[:1.8.0_60]
at
org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:192)[205:org.ops4j.pax.web.pax-web-jetty:4.2.2]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_60]
at
javax.el.FactoryFinder.newInstance(FactoryFinder.java:87)[65:javax.el-api:2.2.4]
... 67 more
On Sun, Nov 8, 2015 at 1:53 PM, Jean-Baptiste Onofré <[email protected]> wrote:
> Avoid the -d option on exports and it should show you both.
>
> It's what I suspected: multiple bundles providing the package.
>
> How can I help you there ? Please let me know I have some time tonight ;)
>
> Regards
> JB
>
>
> On 11/08/2015 07:29 PM, Benson Margulies wrote:
>>
>> I think I see the direction; I didn't know that bundle:find-class
>> requires slashes, not dots.
>>
>> So, how do I sort out Pax Web versus the glassfish bundle where I
>> expected it to turn up? And why does package:exports -d not reveal the
>> combination of 174 and 187?
>>
>>
>>
>> karaf@root>bundle:find-class ExpressionFactoryImpl
>>
>> Expression Language 2.2 Implementation (174)
>> com/sun/el/ExpressionFactoryImpl.class
>>
>> OPS4J Pax Web - Jetty (185)
>> org/apache/el/ExpressionFactoryImpl.class
>>
>> OPS4J Pax Web - Jsp Support (186)
>> org/apache/el/ExpressionFactoryImpl.class
>>
>> OPS4J Pax Web - Runtime (187)
>> com/sun/el/ExpressionFactoryImpl.class
>>
>> On Sun, Nov 8, 2015 at 1:24 PM, Benson Margulies <[email protected]>
>> wrote:
>>>
>>> I tried bundle:tree-show on the hibernate bundle
>>> (https://gist.github.com/benson-basis/d76e7c79e3a277a27efa). Maybe the
>>> fact that it isn't showing me anything I recognize about javax.el is
>>> the root of the trouble?
>>>
>>>
>>> On Sun, Nov 8, 2015 at 1:21 PM, Benson Margulies <[email protected]>
>>> wrote:
>>>>
>>>> Felix is the framework.
>>>>
>>>> I do not have any PackageAdmin code.
>>>>
>>>> I don't have a great way to make this available to you right now. I am
>>>> considering trying to switch to the cxf bean validation feature
>>>> instead of the code I posted.
>>>>
>>>> I think the following is the most relevant backtrace:
>>>>
>>>> Caused by: java.lang.ClassNotFoundException:
>>>> com.sun.el.ExpressionFactoryImpl not found by
>>>> org.apache.cxf.cxf-rt-transports-http [102]
>>>> at
>>>> org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1558)
>>>> at
>>>> org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
>>>> at
>>>> org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1998)
>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>>>> at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1919)
>>>> at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:959)
>>>> at
>>>> org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176)
>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>>>> at
>>>> org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:192)
>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>>>> at javax.el.FactoryFinder.newInstance(FactoryFinder.java:87)
>>>> at javax.el.FactoryFinder.find(FactoryFinder.java:197)
>>>> at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:189)
>>>> at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:160)
>>>> at
>>>> org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm.<clinit>(InterpolationTerm.java:60)
>>>>
>>>>
>>>>
>>>>
>>>> On Sun, Nov 8, 2015 at 1:11 PM, Benson Margulies <[email protected]>
>>>> wrote:
>>>>>
>>>>> package:exports -d does not think that more than one bundle is
>>>>> exporting the package.
>>>>>
>>>>> Here's the class I built to stay out of the SPI.
>>>>>
>>>>> public final class OSGIValidationFactory {
>>>>> private OSGIValidationFactory() {
>>>>> //
>>>>> }
>>>>>
>>>>> static class OSGIServiceDiscoverer implements
>>>>> ValidationProviderResolver {
>>>>>
>>>>> @Override
>>>>> public List<ValidationProvider<?>> getValidationProviders() {
>>>>> List<ValidationProvider<?>> providers = new ArrayList<>();
>>>>> providers.add(new HibernateValidator());
>>>>> return providers;
>>>>> }
>>>>> }
>>>>>
>>>>> public static ValidatorFactory newHibernateValidatorFactory() {
>>>>> javax.validation.Configuration<?> config =
>>>>> Validation.byDefaultProvider()
>>>>> .providerResolver(new OSGIServiceDiscoverer())
>>>>> .configure();
>>>>>
>>>>> return config.buildValidatorFactory();
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> On Sun, Nov 8, 2015 at 1:10 PM, Benson Margulies <[email protected]>
>>>>> wrote:
>>>>>>
>>>>>> Karaf 4.0.2.
>>>>>>
>>>>>> I'm not sure what you mean by 'framework'. I'm just running karaf, I
>>>>>> am not messing with the system bundle. I pulled together my own little
>>>>>> bundle for validation that uses a custom locator to avoid the SPI, and
>>>>>> it works in an isolated test in karaf, but when I put the whole thing
>>>>>> together, blam. How would I investigate the possibility of multiple
>>>>>> bundles?
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Sun, Nov 8, 2015 at 1:06 PM, Jean-Baptiste Onofré <[email protected]>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi Benson,
>>>>>>>
>>>>>>> don't you have multiple bundle providing the same package ?
>>>>>>> I suspect two bundles providing com.sun.el package (or the system
>>>>>>> package).
>>>>>>>
>>>>>>> What's the Karaf version (and framework in use) ?
>>>>>>>
>>>>>>> Regards
>>>>>>> JB
>>>>>>>
>>>>>>>
>>>>>>> On 11/08/2015 07:04 PM, Benson Margulies wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>> I'm getting a ClassNotFoundException trying to use bean validation.
>>>>>>>>
>>>>>>>> karaf@root>package:exports | grep com.sun.el
>>>>>>>> com.sun.el | 2.2.4
>>>>>>>> | 174 | org.glassfish.web.javax.el
>>>>>>>>
>>>>>>>> But:
>>>>>>>>
>>>>>>>> karaf@root> bundle:find-class com.sun.el.ExpressionFactoryImpl
>>>>>>>> karaf@root>
>>>>>>>>
>>>>>>>> even though the class is sitting right there in the jar file for
>>>>>>>> that
>>>>>>>> bundle.
>>>>>>>>
>>>>>>>> karaf@root>bundle:classes 174 | grep Expr
>>>>>>>> com/sun/el/ExpressionFactoryImpl.class
>>>>>>>>
>>>>>>>> what's up?
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Jean-Baptiste Onofré
>>>>>>> [email protected]
>>>>>>> http://blog.nanthrax.net
>>>>>>> Talend - http://www.talend.com
>
>
> --
> Jean-Baptiste Onofré
> [email protected]
> http://blog.nanthrax.net
> Talend - http://www.talend.com