use EL in wildfly module

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

use EL in wildfly module

Carl Harris
This may not be the right place to ask this question -- feel free to redirect me as appropriate.

I have a CDI extension packaged as a Wildfly module. The extension evaluates some EL expressions. In order to evaluate the expressions it calls javax.el.ExpressionFactory.newInstance() to get an ExpressionFactory. However, when calling this method an exception is thrown:

Caused by: javax.el.ELException: Provider com.sun.el.ExpressionFactoryImpl not found
        at javax.el.FactoryFinder.newInstance(FactoryFinder.java:102)
        at javax.el.FactoryFinder.find(FactoryFinder.java:186)
        at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:197)
        at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:168)
        at javax.el.ELUtil.<clinit>(ELUtil.java:99)
        ... 50 more
Caused by: java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl from [Module \"javax.el.api:main\" from local module loader @18ef96 (finder: local module finder @6956de9 (roots: /tmp/wildfly-10.0.0.Final/modules,/tmp/wildfly-10.0.0.Final/modules/system/layers/base))]


I *think* the module descriptor has the right dependencies, but evidently I’m missing something.

<module xmlns="urn:jboss:module:1.0" name="org.soulwing.pinject" slot="main">
  <resources>
    <resource-root path="pinject-extension-1.2.0-SNAPSHOT.jar" />
  </resources>

  <dependencies>
    <module name="org.soulwing.pinject.api" />
    <module name="org.glassfish.javax.el" />
    <module name="javax.inject.api" />
    <module name="javax.enterprise.api"/>
    <module name="javax.mail.api" />
    <module name="javax.el.api" />
    <module name="javax.api" />
  </dependencies>

</module>

I’ve looked at some other Wildfly modules that use EL (e.g. Hibernate Validator), but I haven’t been able to discern what they’re doing differently.

carl


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: use EL in wildfly module

Stuart Douglas
You probably need to import services:

    <module name="org.glassfish.javax.el" services="import" />

Stuart

On Sun, Aug 28, 2016 at 8:40 PM, Carl Harris <[hidden email]> wrote:
This may not be the right place to ask this question -- feel free to redirect me as appropriate.

I have a CDI extension packaged as a Wildfly module. The extension evaluates some EL expressions. In order to evaluate the expressions it calls javax.el.ExpressionFactory.newInstance() to get an ExpressionFactory. However, when calling this method an exception is thrown:

Caused by: javax.el.ELException: Provider com.sun.el.ExpressionFactoryImpl not found
        at javax.el.FactoryFinder.newInstance(FactoryFinder.java:102)
        at javax.el.FactoryFinder.find(FactoryFinder.java:186)
        at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:197)
        at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:168)
        at javax.el.ELUtil.<clinit>(ELUtil.java:99)
        ... 50 more
Caused by: java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl from [Module \"javax.el.api:main\" from local module loader @18ef96 (finder: local module finder @6956de9 (roots: /tmp/wildfly-10.0.0.Final/modules,/tmp/wildfly-10.0.0.Final/modules/system/layers/base))]


I *think* the module descriptor has the right dependencies, but evidently I’m missing something.

<module xmlns="urn:jboss:module:1.0" name="org.soulwing.pinject" slot="main">
  <resources>
    <resource-root path="pinject-extension-1.2.0-SNAPSHOT.jar" />
  </resources>

  <dependencies>
    <module name="org.soulwing.pinject.api" />
    <module name="org.glassfish.javax.el" />
    <module name="javax.inject.api" />
    <module name="javax.enterprise.api"/>
    <module name="javax.mail.api" />
    <module name="javax.el.api" />
    <module name="javax.api" />
  </dependencies>

</module>

I’ve looked at some other Wildfly modules that use EL (e.g. Hibernate Validator), but I haven’t been able to discern what they’re doing differently.

carl


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: use EL in wildfly module

Carl Harris

> On Aug 30, 2016, at 12:05 AM, Stuart Douglas <[hidden email]> wrote:
>
> You probably need to import services:
>
>     <module name="org.glassfish.javax.el" services="import" />

Doesn’t seem to make a difference. Interestingly, there doesn’t seem to be a META-INF/services entry of any kind in the module.

After doing some more investigating I think I’ve sorted it out.

My CDI extension creates an ExpressionFactory lazily, during a CDI ProcessInjectionPoint event callback.

In Wildfly 10, when my CDI extension’s ProcessInjectionPoint event observers are being called, the TCCL is not set.

In Wildfly 9, the TCCL was set to the deployment class loader. Looking at the source for the Glassfish EL implementation, it seems to want to use the TCCL to locate the ExpressionFactory implementation.

I’m thinking that my extension worked in Wildfly 9 only because there was an EL provider on the deployment class loader (since that’s the TCCL) — it really didn’t matter whether my module declared a dependency on the EL provider, since the module’s class loader wasn’t involved.

I changed my extension so that it sets the TCCL to the module class loader before creating the EL ExpressionFactory. Now it uses the correct class loader and it doesn’t matter whether a deployment has an EL provider on its class loader; the declared dependency on the Glassfish EL provider in my module descriptor is all that’s needed.

carl
_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Loading...