java.lang.NoClassDefFoundError: javax/el/PropertyNotFoundException when I send invalid values to controller

后端 未结 4 2149
你的背包
你的背包 2021-02-07 22:54

I use MockMvc for my controller testing

@Test
    public void updateEvent() throws Exception{
        MockHttpServletRequestBuilder request = MockMvcRequestBuild         


        
相关标签:
4条回答
  • 2021-02-07 23:22

    Add the following to your pom.

    <dependency>
      <groupId>org.glassfish.web</groupId>
      <artifactId>el-impl</artifactId>
      <version>2.2.6</version>
      <scope>test</scope>
    </dependency>
    

    It will resolve the need for javax.el. Current version is 2.2.6

    0 讨论(0)
  • 2021-02-07 23:37

    I met the same problem, Add the following dependency resolved this problem.

    When you met javax/el/PropertyNotFoundException, That means you missed el-api dependency, you can add the following jar

        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>
    

    or

    <dependency>
      <groupId>javax.el</groupId>
      <artifactId>javax.el-api</artifactId>
      <version>3.0.0</version>
      <scope>test</scope>
    </dependency>
    

    Then you met ClassNotFoundException:com.sun.el.ExpressionFactoryImpl , You missed el-impl jar:

    <dependency>
      <groupId>org.glassfish.web</groupId>
      <artifactId>el-impl</artifactId>
      <version>2.2</version>
      <scope>test</scope>
    </dependency>
    
    0 讨论(0)
  • 2021-02-07 23:40

    You maybe just need to add the dependency in your test. Are you using maven? if so, can you try to add this to your pom? You may need a different jar/version, but something like this:

    <dependency>
      <groupId>javax.el</groupId>
      <artifactId>javax.el-api</artifactId>
      <version>3.0.0</version>
      <scope>test</scope>
    </dependency>
    
    0 讨论(0)
  • 2021-02-07 23:43

    I haven't el-impl in my pom.xml

     <dependency>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                    <version>2.5</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>javax.servlet.jsp</groupId>
                    <artifactId>jsp-api</artifactId>
                    <version>2.2</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>javax.servlet</groupId>
                    <artifactId>jstl</artifactId>
                    <version>1.2</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>javax.el</groupId>
                    <artifactId>el-api</artifactId>
                    <version>2.2</version>
                    <scope>provided</scope>
                </dependency>
    
                <dependency>
                    <groupId>org.glassfish.web</groupId>
                    <artifactId>el-impl</artifactId>
                    <version>2.2</version>
                </dependency>
    

    It is working state of pom.xml

    An more I delete

    servlet-api
    jsp-api
    jstl
    el-api
    

    jar files from tomcat/lib

    And copy from m2./repository.

    0 讨论(0)
提交回复
热议问题