3

I am using spring boot and my POM looks like this :

<dependencyManagement>
 <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.0.8.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
 </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.0.8.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>2.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>5.2.4.Final</version>
    </dependency>
    <!--<dependency>-->
        <!--<groupId>org.springframework.boot</groupId>-->
        <!--<artifactId>spring-boot-starter-validation</artifactId>-->
    <!--</dependency>-->
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.el</artifactId>
        <version>3.0.1-b08</version>
        <exclusions>
            <exclusion>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jsp</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!--<dependency>-->
        <!--<groupId>javax.el</groupId>-->
        <!--<artifactId>javax.el-api</artifactId>-->
        <!--<version>3.0.1-b06</version>-->
    <!--</dependency>-->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
    </dependency>


        <!-- Test Dependencies -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
    <version>2.0.8.RELEASE</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
    <version>2.0.8.RELEASE</version>
  <scope>test</scope>
</dependency>
</dependencies>

I am seeing below error while running it from IntelliJ :

Caused by: javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:123)
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:47)
at org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultMessageInterpolator(ConfigurationImpl.java:474)
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:272)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1753)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1690)
... 32 more

I tried including the commented-out POM dependencies (javax.el-api and spring-boot-starter-validation) but it doesn't make any differnece.

I also verified that javax.el-3.0.1-b08.jar is bundled in the fat jar so not sure what is going wrong.

Here is what I already referred but nothing works in this case:

  1. javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory' when using WebTestClient
  2. javax.validation.ValidationException: HV000183: Unable to load 'javax.el.ExpressionFactory'
  3. Hibernate validation "Unable to initialize javax.el.ExpressionFactory" error

Any suggestions will be appreciated in this regard.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
tom
  • 719
  • 1
  • 11
  • 30
  • One observation: The above error disappears when I use spring boot version : 1.5.8.RELEASE and javax.validation validation-api 1.0.0.GA For EL I use below dependencies : org.glassfish javax.el 3.0.1-b09 javax.el javax.el-api 3.0.1-b06 – tom Feb 19 '19 at 03:39
  • Try [this](https://stackoverflow.com/a/74781584/11092008), maybe it will solve your problem. – Shapur Dec 13 '22 at 08:02
  • @Ali I fixed that already using the method mentioned here : https://stackoverflow.com/a/54779341/3266029 – tom Dec 14 '22 at 09:22

1 Answers1

2

So I referred this to fix this issue.

I executed mvn dependency:tree on my spring boot project and saw that it was getting jsp-api and jsp-api-2.1 as transitive dependencies. Excluded these and the app executed just fine using the main method in Intellij:

             <exclusion>
                 <groupId>javax.servlet.jsp</groupId>
                 <artifactId>jsp-api</artifactId>
             </exclusion>
             <exclusion>
                 <groupId>org.mortbay.jetty</groupId>
                 <artifactId>jsp*</artifactId>
             </exclusion>
tom
  • 719
  • 1
  • 11
  • 30