2

During my App Engine application's runtime, I receive the following exception:

java.lang.ExceptionInInitializerError
at
org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateExpression(ResourceBundleMessageInterpolator.java:227)

... (removed for brevity)

Caused by: java.lang.ClassNotFoundException: de.odysseus.el.ExpressionFactoryImpl

I had seen this error on my dev server and fixed it by including juel-impl in my pom.xml

When I use appcfg.sh to pull my application from the server, I see that it has juel-impl-2.2.7-20130801.163115-1.jar included in the WEB-INF/lib

I'm really not sure what to make of this.

sbsmith
  • 600
  • 1
  • 5
  • 16
  • 1
    I had limited time, so my solution to the problem was to use Apache BVal (http://bval.apache.org/) instead. – sbsmith Oct 12 '13 at 21:05

2 Answers2

3

Update: According to the GAE issue tracker, this has been fixed in version 1.9.7. For earlier versions, see below.


Hibernate Validator 5.x makes use of the Unified Expression Language. In particular, it uses a static API method that looks up an implementation of ExpressionFactory. A bug in App Engine 1.9.4 and earlier, however, seems to prevent the use of any expression factory implementation in production only.

Until this is fixed, there are two workarounds:

  1. If you don't need the Bean Validation 1.1 features, fall back to Hibernate Validator 4.3.1.Final. I have successfully tested this.

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.3.1.Final</version>
    </dependency>
    
  2. If you need Bean Validation 1.1, there have been reports to make this work with a repository snapshot of Apache BVal. I haven't tested this.


Update note: Specifying the expression language implementation as stated in my earlier response (Glassfish EL or JUEL) works fine in development and also in certain production use cases, but will still fail for some validations.

David Geiger
  • 316
  • 2
  • 10
  • Thanks, David. However, I had tried both of those options already - the jar mentioned in the question is the snapshot jar that should work on GAE. The strange thing was that both solutions worked on my dev server, but neither worked for me on GAE. Thankfully, BVal was a suitable replacement and included the same @Email tag as Hibernate. – sbsmith Nov 07 '13 at 15:27
  • If you go for using the Glassfish reference implementation you only need the glassfish dep. In that case the javax.el:javax.el-api dep is not needed. – Marcel Overdijk Nov 23 '13 at 15:21
  • @sbsmith: This configuration works fine for me on App Engine 1.8.8. In case you want to give it another try: I'm using javax.validation.validation-api 1.1.0.Final, org.hibernate.hibernate-validator 5.0.1.Final and the above Glassfish EL dependencies. – David Geiger Jan 10 '14 at 16:39
  • JUEL 2.2.7 is now available at Maven central. – chris Feb 06 '14 at 15:48
  • Since my current implementation works and I'm strapped for time, I won't be able to try the suggested fixes. Is it appropriate for me to mark this as the accepted answer even though I have not tested it? – sbsmith Feb 06 '14 at 19:22
  • @DavidGeigar I am struggling with the same issue. I have Jersey 5.2.1/Hibernate Validator 5.x.x on App Engine 1.8.9 as of today and it just does not work. I tried both implementations of UEL. In case of Glassfish reference implementation it still requires de.odysseus.el.ExpressionFactoryImpl. In case of JUEL implementation it works on local dev server but on App Engine it throws java.lang.ClassNotFoundException exception again. – pgiecek Feb 07 '14 at 10:38
  • Having run into this issue again and doing some more research, I haven't found a way to make Hibernate Validator 5.x work properly with GAE 1.9.4. It appears, however, that Google is working on it. Updated my answer and will update again once this is fixed. – David Geiger May 13 '14 at 12:44
0

I had the same problem. It helped to use hibernate-validator 4.3.1.Final instead of 5.0.1.Final. Ref: stackoverflow (avidD-s answer)

Community
  • 1
  • 1
mkalmo
  • 185
  • 1
  • 5