java.lang.NoClassDefFoundError:当我向控制器发送无效值时,javax / el / PropertyNotFoundException

前端之家收集整理的这篇文章主要介绍了java.lang.NoClassDefFoundError:当我向控制器发送无效值时,javax / el / PropertyNotFoundException前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用MockMvc进行我的控制器测试
  1. @Test
  2. public void updateEvent() throws Exception{
  3. MockHttpServletRequestBuilder request = MockMvcRequestBuilders
  4. .post("/updateEvent");
  5. request.param("selectedEventStatusId","1");
  6. request.param("selectedEventTypeId","1");
  7.  
  8.  
  9.  
  10. Event eventFromDb = createAndSaveEvent();
  11. request.param("idEvent",eventFromDb.getId().toString());
  12. request.param("name",eventFromDb.getName());
  13. request.param("description",eventFromDb.getDescription() +"____");//the reason of problem. if I will write request.param("description",eventFromDb.getDescription() ); its good work mapping if this field below
  14. request.param("date",new SimpleDateFormat("yyyy-MM-dd").format(eventFromDb.getDate()));
  15. request.param("eventDate",new SimpleDateFormat("yyyy-MM-dd").format(eventFromDb.getEventDate()));
  16.  
  17.  
  18. ResultActions result = mockMvc.perform(request).andDo(MockMvcResultHandlers.print());
  19.  
  20. result.andExpect(MockMvcResultMatchers.view().name("redirect:eventDetails"));
  21. result.andExpect(MockMvcResultMatchers.model().attributeExists("idEvent"));
  22. result.andExpect(MockMvcResultMatchers.model().attributeExists("message"));
  23.  
  24. }

描述字段标记

  1. @Size(min=5)
  2. @Pattern(regexp="[a-zA-Z]*")
  3. private String description;

执行后我看到下一个stackTrace:

  1. org.springframework.web.util.NestedServletException: Handler processing Failed; nested exception is java.lang.NoClassDefFoundError: javax/el/PropertyNotFoundException
  2. at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259)
  3. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
  4. at ....

在生产模式下,它的工作不错,但在测试中我看到错误,如果我没有值的值

控制器方式:

  1. @RequestMapping(value = "/updateEvent",method = RequestMethod.POST)
  2. public String updateEvent(Model model,@Valid @modelattribute("existedEvent") Event event,BindingResult result,@modelattribute("linkedCandidates") Set<Candidate> candidates,@modelattribute("linkedvacancies") Set<Vacancy> vacancies,@RequestParam(required = true,value = "selectedEventStatusId")Integer EventStatusId,value = "selectedEventTypeId")Integer EventTypeId,RedirectAttributes attributes) {
  3. if (result.hasErrors()) {
  4. //model.addAttribute("idEvent",event.getId());
  5. event.setCandidates(candidates);
  6. event.setVacancies(vacancies);
  7. return "eventDetails";
  8. }
  9. eventService.updateEventAndLinkedEntities(event,candidates,vacancies,EventTypeId,EventStatusId);
  10. attributes.addAttribute("idEvent",event.getId() );
  11. attributes.addAttribute("message","submitted correctly at "+new Date());
  12. return "redirect:eventDetails";
  13. }

如果我更换

  1. request.param("description",eventFromDb.getDescription() +"____");

  1. request.param("description",eventFromDb.getDescription();//valid value here

这是好的作品

你可以帮忙解决吗?

UPDATE

pom.xml(子模块 – 这里运行的测试)

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>com.epam.hhs</groupId>
  5. <artifactId>ui</artifactId>
  6. <name>hhsystem ui</name>
  7. <packaging>war</packaging>
  8. <version>1.0.0-SNAPSHOT</version>
  9. <properties>
  10. <java-version>1.6</java-version>
  11. <org.springframework-version>3.2.3.RELEASE</org.springframework-version>
  12. <org.springsecurity-version>3.1.3.RELEASE</org.springsecurity-version>
  13. <org.aspectj-version>1.6.10</org.aspectj-version>
  14. <org.slf4j-version>1.6.6</org.slf4j-version>
  15. <!-- Spring -->
  16. <spring-framework.version>3.2.3.RELEASE</spring-framework.version>
  17. </properties>
  18. <dependencies>
  19. <!-- Spring -->
  20. <dependency>
  21. <groupId>org.springframework</groupId>
  22. <artifactId>spring-context</artifactId>
  23. <version>${org.springframework-version}</version>
  24. <exclusions>
  25. <!-- Exclude Commons Logging in favor of SLF4j -->
  26. <exclusion>
  27. <groupId>commons-logging</groupId>
  28. <artifactId>commons-logging</artifactId>
  29. </exclusion>
  30. </exclusions>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.springframework</groupId>
  34. <artifactId>spring-webmvc</artifactId>
  35. <version>${org.springframework-version}</version>
  36. </dependency>
  37.  
  38. <dependency>
  39. <groupId>org.springframework</groupId>
  40. <artifactId>spring-beans</artifactId>
  41. <version>${org.springframework-version}</version>
  42. </dependency>
  43.  
  44. <!-- Spring Security -->
  45. <dependency>
  46. <groupId>org.springframework.security</groupId>
  47. <artifactId>spring-security-web</artifactId>
  48. <version>${org.springsecurity-version}</version>
  49. </dependency>
  50. <dependency>
  51. <groupId>org.springframework.security</groupId>
  52. <artifactId>spring-security-config</artifactId>
  53. <version>${org.springsecurity-version}</version>
  54. </dependency>
  55. <dependency>
  56. <groupId>org.springframework.security</groupId>
  57. <artifactId>spring-security-core</artifactId>
  58. <version>${org.springsecurity-version}</version>
  59. </dependency>
  60. <dependency>
  61. <groupId>org.springframework.security</groupId>
  62. <artifactId>spring-security-taglibs</artifactId>
  63. <version>${org.springsecurity-version}</version>
  64. <exclusions>
  65. <exclusion>
  66. <artifactId>spring-aop</artifactId>
  67. <groupId>org.springframework</groupId>
  68. </exclusion>
  69. </exclusions>
  70. </dependency>
  71.  
  72. <!-- Validation -->
  73. <dependency>
  74. <groupId>javax.validation</groupId>
  75. <artifactId>validation-api</artifactId>
  76. <version>1.1.0.Final</version>
  77. </dependency>
  78. <dependency>
  79. <groupId>org.hibernate</groupId>
  80. <artifactId>hibernate-validator</artifactId>
  81. <version>5.0.1.Final</version>
  82. </dependency>
  83.  
  84. <!-- Core -->
  85. <dependency>
  86. <groupId>com.epam.hhs</groupId>
  87. <artifactId>core</artifactId>
  88. <version>1.0.9-SNAPSHOT</version>
  89. </dependency>
  90. <dependency>
  91. <groupId>com.epam.hhs</groupId>
  92. <artifactId>core</artifactId>
  93. <version>1.0.9-SNAPSHOT</version>
  94. <classifier>tests</classifier>
  95. </dependency>
  96.  
  97. <!-- AspectJ -->
  98. <dependency>
  99. <groupId>org.aspectj</groupId>
  100. <artifactId>aspectjrt</artifactId>
  101. <version>${org.aspectj-version}</version>
  102. </dependency>
  103.  
  104. <!-- Logging -->
  105. <dependency>
  106. <groupId>org.slf4j</groupId>
  107. <artifactId>slf4j-api</artifactId>
  108. <version>${org.slf4j-version}</version>
  109. </dependency>
  110. <dependency>
  111. <groupId>org.slf4j</groupId>
  112. <artifactId>jcl-over-slf4j</artifactId>
  113. <version>${org.slf4j-version}</version>
  114. <scope>runtime</scope>
  115. </dependency>
  116. <dependency>
  117. <groupId>org.slf4j</groupId>
  118. <artifactId>slf4j-log4j12</artifactId>
  119. <version>${org.slf4j-version}</version>
  120. <scope>runtime</scope>
  121. </dependency>
  122. <dependency>
  123. <groupId>log4j</groupId>
  124. <artifactId>log4j</artifactId>
  125. <version>1.2.15</version>
  126. <exclusions>
  127. <exclusion>
  128. <groupId>javax.mail</groupId>
  129. <artifactId>mail</artifactId>
  130. </exclusion>
  131. <exclusion>
  132. <groupId>javax.jms</groupId>
  133. <artifactId>jms</artifactId>
  134. </exclusion>
  135. <exclusion>
  136. <groupId>com.sun.jdmk</groupId>
  137. <artifactId>jmxtools</artifactId>
  138. </exclusion>
  139. <exclusion>
  140. <groupId>com.sun.jmx</groupId>
  141. <artifactId>jmxri</artifactId>
  142. </exclusion>
  143. </exclusions>
  144. <scope>runtime</scope>
  145. </dependency>
  146.  
  147. <!-- @Inject -->
  148. <dependency>
  149. <groupId>javax.inject</groupId>
  150. <artifactId>javax.inject</artifactId>
  151. <version>1</version>
  152. </dependency>
  153.  
  154. <!-- Servlet -->
  155. <dependency>
  156. <groupId>javax.servlet</groupId>
  157. <artifactId>servlet-api</artifactId>
  158. <version>2.5</version>
  159. <scope>provided</scope>
  160. </dependency>
  161. <dependency>
  162. <groupId>javax.servlet.jsp</groupId>
  163. <artifactId>jsp-api</artifactId>
  164. <version>2.1</version>
  165. <scope>provided</scope>
  166. </dependency>
  167. <dependency>
  168. <groupId>javax.servlet</groupId>
  169. <artifactId>jstl</artifactId>
  170. <version>1.2</version>
  171. <scope>provided</scope>
  172. </dependency>
  173. <dependency>
  174. <groupId>javax.el</groupId>
  175. <artifactId>el-api</artifactId>
  176. <version>2.2</version>
  177. <scope>provided</scope>
  178. </dependency>
  179.  
  180.  
  181. <!-- Test -->
  182. <dependency>
  183. <groupId>junit</groupId>
  184. <artifactId>junit</artifactId>
  185. <version>4.7</version>
  186. <scope>test</scope>
  187. </dependency>
  188. <dependency>
  189. <groupId>org.mockito</groupId>
  190. <artifactId>mockito-all</artifactId>
  191. <version>1.9.5</version>
  192. </dependency>
  193. <!-- Mock MVC Test -->
  194. <!-- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test-mvc</artifactId>
  195. <version>1.0.0.M2</version> <scope>test</scope> </dependency> -->
  196. <dependency>
  197. <groupId>org.springframework</groupId>
  198. <artifactId>spring-test</artifactId>
  199. <version>${spring-framework.version}</version>
  200. <scope>test</scope>
  201. </dependency>
  202. <dependency>
  203. <groupId>org.hamcrest</groupId>
  204. <artifactId>hamcrest-all</artifactId>
  205. <version>1.3</version>
  206. <scope>test</scope>
  207. </dependency>
  208. <!-- <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId>
  209. <version>4.10</version> <scope>test</scope> <exclusions> <exclusion> <artifactId>hamcrest-core</artifactId>
  210. <groupId>org.hamcrest</groupId> </exclusion> </exclusions> </dependency> -->
  211. <!-- <dependency> <groupId>com.github.springtestdbunit</groupId> <artifactId>spring-test-dbunit</artifactId>
  212. <version>1.0.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.dbunit</groupId>
  213. <artifactId>dbunit</artifactId> <version>2.4.8</version> <scope>test</scope>
  214. </dependency> -->
  215.  
  216. </dependencies>
  217.  
  218. <repositories>
  219. <repository>
  220. <id>spring-milestone</id>
  221. <name>Spring Portfolio Milestone Repository</name>
  222. <url>http://repo.springsource.org/milestone/</url>
  223. </repository>
  224. </repositories>
  225.  
  226. <build>
  227. <plugins>
  228. <plugin>
  229. <artifactId>maven-eclipse-plugin</artifactId>
  230. <version>2.9</version>
  231. <configuration>
  232. <additionalProjectnatures>
  233. <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
  234. </additionalProjectnatures>
  235. <additionalBuildcommands>
  236. <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
  237. </additionalBuildcommands>
  238. <downloadSources>true</downloadSources>
  239. <downloadJavadocs>true</downloadJavadocs>
  240. </configuration>
  241. </plugin>
  242. <plugin>
  243. <groupId>org.apache.maven.plugins</groupId>
  244. <artifactId>maven-compiler-plugin</artifactId>
  245. <version>2.5.1</version>
  246. <configuration>
  247. <source>1.6</source>
  248. <target>1.6</target>
  249. <compilerArgument>-Xlint:all</compilerArgument>
  250. <showWarnings>true</showWarnings>
  251. <showDeprecation>true</showDeprecation>
  252. </configuration>
  253. </plugin>
  254. <plugin>
  255. <groupId>org.codehaus.mojo</groupId>
  256. <artifactId>exec-maven-plugin</artifactId>
  257. <version>1.2.1</version>
  258. <configuration>
  259. <mainClass>org.test.int1.Main</mainClass>
  260. </configuration>
  261. </plugin>
  262. <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId>
  263. <version>2.12</version> <configuration> <forkMode>always</forkMode> </configuration>
  264. </plugin> -->
  265. </plugins>
  266. </build>
  267. </project>

pom.xml(父模块)

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <groupId>com.epam.hhs</groupId>
  6. <artifactId>core</artifactId>
  7. <version>1.0.9-SNAPSHOT</version>
  8.  
  9. <name>hhsystem core</name>
  10. <!--<packaging>war</packaging> -->
  11.  
  12. <properties>
  13.  
  14. <!-- Generic properties -->
  15. <java.version>1.6</java.version>
  16. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  17. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  18.  
  19. <!-- Spring -->
  20. <spring-framework.version>3.2.3.RELEASE</spring-framework.version>
  21. <spring-data-jpa.version>1.3.2.RELEASE</spring-data-jpa.version>
  22. <org.springsecurity-version>3.1.3.RELEASE</org.springsecurity-version>
  23.  
  24. <!-- Java EE / Java SE dependencies -->
  25. <jsp.version>2.2</jsp.version>
  26. <jstl.version>1.2</jstl.version>
  27. <servlet.version>2.5</servlet.version>
  28. <jaxb-impl.version>2.2.7</jaxb-impl.version>
  29.  
  30. <!-- Hibernate / JPA -->
  31. <hibernate.version>4.2.1.Final</hibernate.version>
  32.  
  33. <!-- Bean validation -->
  34. <hibernate-validator.version>4.3.1.Final</hibernate-validator.version>
  35.  
  36. <!-- Database access -->
  37. <tomcat-jdbc.version>7.0.37</tomcat-jdbc.version>
  38. <ehcache.version>2.6.6</ehcache.version>
  39. <hsqldb.version>2.2.9</hsqldb.version>
  40.  
  41. <!-- AOP -->
  42. <aspectj.version>1.7.2</aspectj.version>
  43.  
  44. <!-- Logging -->
  45. <logback.version>1.0.13</logback.version>
  46. <slf4j.version>1.7.5</slf4j.version>
  47.  
  48. <!-- RSS -->
  49. <rome.version>1.0</rome.version>
  50.  
  51. <!-- Test -->
  52. <junit.version>4.11</junit.version>
  53. <hamcrest.version>1.3</hamcrest.version>
  54.  
  55. <!-- Dates -->
  56. <jodatime-hibernate.version>1.3</jodatime-hibernate.version>
  57. <jodatime-jsptags.version>1.1.1</jodatime-jsptags.version>
  58. <jodatime.version>2.2</jodatime.version>
  59. <jadira-usertype-core.version>3.1.0.CR6</jadira-usertype-core.version>
  60.  
  61.  
  62. <!-- Web dependencies -->
  63. <webjars-bootstrap.version>2.3.0</webjars-bootstrap.version>
  64. <webjars-jquery-ui.version>1.9.2</webjars-jquery-ui.version>
  65. <webjars-jquery.version>1.9.0</webjars-jquery.version>
  66. <dandelion.datatables.version>0.8.14</dandelion.datatables.version>
  67.  
  68. <MysqL.version>5.1.22</MysqL.version>
  69.  
  70. </properties>
  71.  
  72. <dependencies>
  73. <dependency>
  74. <groupId>log4j</groupId>
  75. <artifactId>log4j</artifactId>
  76. <version>1.2.17</version>
  77. </dependency>
  78.  
  79. <dependency>
  80. <groupId>org.mule.transports</groupId>
  81. <artifactId>mule-transport-http</artifactId>
  82. <version>3.4.0</version>
  83. </dependency>
  84.  
  85.  
  86. <dependency>
  87. <groupId>log4j</groupId>
  88. <artifactId>log4j</artifactId>
  89. <version>1.2.17</version>
  90. </dependency>
  91.  
  92. <dependency>
  93. <groupId>org.springframework</groupId>
  94. <artifactId>spring-beans</artifactId>
  95. <version>3.2.1.RELEASE</version>
  96. </dependency>
  97.  
  98. <!-- <dependency>
  99. <groupId>javax.servlet</groupId>
  100. <artifactId>jstl</artifactId>
  101. <version>${jstl.version}</version>
  102. </dependency>
  103. <dependency>
  104. <groupId>javax.servlet</groupId>
  105. <artifactId>servlet-api</artifactId>
  106. <version>${servlet.version}</version>
  107. <scope>provided</scope>
  108. </dependency>
  109. <dependency>
  110. <groupId>javax.servlet.jsp</groupId>
  111. <artifactId>jsp-api</artifactId>
  112. <version>${jsp.version}</version>
  113. <scope>provided</scope>
  114. </dependency> -->
  115. <dependency>
  116. <groupId>com.sun.xml.bind</groupId>
  117. <artifactId>jaxb-impl</artifactId>
  118. <version>${jaxb-impl.version}</version>
  119. <scope>provided</scope>
  120. </dependency>
  121. <!-- SPRING,SPRING,SPRINGITY SPRING -->
  122. <dependency>
  123. <groupId>org.springframework.data</groupId>
  124. <artifactId>spring-data-jpa</artifactId>
  125. <version>${spring-data-jpa.version}</version>
  126. <exclusions>
  127. <exclusion>
  128. <groupId>org.springframework</groupId>
  129. <artifactId>*</artifactId>
  130. </exclusion>
  131. </exclusions>
  132. </dependency>
  133.  
  134. <dependency>
  135. <groupId>org.springframework</groupId>
  136. <artifactId>spring-jdbc</artifactId>
  137. <version>${spring-framework.version}</version>
  138. </dependency>
  139. <dependency>
  140. <groupId>org.springframework</groupId>
  141. <artifactId>spring-aop</artifactId>
  142. <version>${spring-framework.version}</version>
  143. </dependency>
  144. <dependency>
  145. <groupId>org.springframework</groupId>
  146. <artifactId>spring-webmvc</artifactId>
  147. <version>${spring-framework.version}</version>
  148. </dependency>
  149. <dependency>
  150. <groupId>org.springframework</groupId>
  151. <artifactId>spring-tx</artifactId>
  152. <version>${spring-framework.version}</version>
  153. </dependency>
  154. <!-- used for EhCacheCacheManager -->
  155. <dependency>
  156. <groupId>org.springframework</groupId>
  157. <artifactId>spring-context-support</artifactId>
  158. <version>${spring-framework.version}</version>
  159. </dependency>
  160. <dependency>
  161. <groupId>org.springframework</groupId>
  162. <artifactId>spring-orm</artifactId>
  163. <version>${spring-framework.version}</version>
  164. </dependency>
  165. <dependency>
  166. <groupId>org.springframework</groupId>
  167. <artifactId>spring-oxm</artifactId>
  168. <version>${spring-framework.version}</version>
  169. <exclusions>
  170. <exclusion>
  171. <groupId>commons-lang</groupId>
  172. <artifactId>commons-lang</artifactId>
  173. </exclusion>
  174. </exclusions>
  175. </dependency>
  176. <dependency>
  177. <groupId>org.springframework</groupId>
  178. <artifactId>spring-jms</artifactId>
  179. <version>${spring-framework.version}</version>
  180. </dependency>
  181.  
  182.  
  183. <!-- Database connection pool See here for more details on commons-dbcp
  184. versus tomcat-jdbc: http://blog.ippon.fr/2013/03/13/improving-the-performance-of-the-spring-petclinic-sample-application-part-3-of-5/ -->
  185. <dependency>
  186. <groupId>org.apache.tomcat</groupId>
  187. <artifactId>tomcat-jdbc</artifactId>
  188. <version>${tomcat-jdbc.version}</version>
  189. <scope>runtime</scope>
  190. </dependency>
  191.  
  192. <!-- For MysqL only -->
  193. <!-- <dependency> <groupId>MysqL</groupId> <artifactId>MysqL-connector-java</artifactId>
  194. <version>${MysqL.version}</version> </dependency> -->
  195. <dependency>
  196. <groupId>com.microsoft.sqlserver</groupId>
  197. <artifactId>sqljdbc4</artifactId>
  198. <version>3.0</version>
  199. </dependency>
  200. <!-- <dependency> <groupId>MysqL</groupId> <artifactId>MysqL-connector-java</artifactId>
  201. <version>${MysqL.version}</version> </dependency> -->
  202. <!-- HIBERNATE -->
  203. <dependency>
  204. <groupId>org.hibernate</groupId>
  205. <artifactId>hibernate-core</artifactId>
  206. <version>${hibernate.version}</version>
  207. </dependency>
  208. <dependency>
  209. <groupId>org.hibernate</groupId>
  210. <artifactId>hibernate-entitymanager</artifactId>
  211. <version>${hibernate.version}</version>
  212. </dependency>
  213. <dependency>
  214. <groupId>org.hibernate</groupId>
  215. <artifactId>hibernate-validator</artifactId>
  216. <version>${hibernate-validator.version}</version>
  217. </dependency>
  218.  
  219. <dependency>
  220. <groupId>org.hibernate</groupId>
  221. <artifactId>hibernate-ehcache</artifactId>
  222. <version>${hibernate.version}</version>
  223. </dependency>
  224.  
  225. <dependency>
  226. <groupId>MysqL</groupId>
  227. <artifactId>MysqL-connector-java</artifactId>
  228. <version>5.1.25</version>
  229. </dependency>
  230.  
  231. <!-- Webjars (static dependencies distributed as JAR files) -->
  232. <dependency>
  233. <groupId>org.webjars</groupId>
  234. <artifactId>bootstrap</artifactId>
  235. <version>${webjars-bootstrap.version}</version>
  236. </dependency>
  237. <dependency>
  238. <groupId>org.webjars</groupId>
  239. <artifactId>jquery-ui</artifactId>
  240. <version>${webjars-jquery-ui.version}</version>
  241. </dependency>
  242. <dependency>
  243. <groupId>org.webjars</groupId>
  244. <artifactId>jquery</artifactId>
  245. <version>${webjars-jquery.version}</version>
  246. </dependency>
  247.  
  248. <!-- Test Artifacts -->
  249. <dependency>
  250. <groupId>org.springframework</groupId>
  251. <artifactId>spring-test</artifactId>
  252. <version>${spring-framework.version}</version>
  253. <scope>test</scope>
  254. </dependency>
  255. <dependency>
  256. <groupId>junit</groupId>
  257. <artifactId>junit</artifactId>
  258. <version>${junit.version}</version>
  259. <scope>test</scope>
  260. </dependency>
  261. <!-- used by Spring MVC Test framework -->
  262. <dependency>
  263. <groupId>org.hamcrest</groupId>
  264. <artifactId>hamcrest-library</artifactId>
  265. <version>${hamcrest.version}</version>
  266. <scope>test</scope>
  267. </dependency>
  268.  
  269. <dependency>
  270. <groupId>org.aspectj</groupId>
  271. <artifactId>aspectjrt</artifactId>
  272. <version>${aspectj.version}</version>
  273. </dependency>
  274. <dependency>
  275. <groupId>org.aspectj</groupId>
  276. <artifactId>aspectjweaver</artifactId>
  277. <version>${aspectj.version}</version>
  278. <scope>runtime</scope>
  279. </dependency>
  280.  
  281. <!-- Spring Security -->
  282. <dependency>
  283. <groupId>org.springframework.security</groupId>
  284. <artifactId>spring-security-web</artifactId>
  285. <version>${org.springsecurity-version}</version>
  286. </dependency>
  287. <dependency>
  288. <groupId>org.springframework.security</groupId>
  289. <artifactId>spring-security-config</artifactId>
  290. <version>${org.springsecurity-version}</version>
  291. </dependency>
  292. <dependency>
  293. <groupId>org.springframework.security</groupId>
  294. <artifactId>spring-security-core</artifactId>
  295. <version>${org.springsecurity-version}</version>
  296. </dependency>
  297. <dependency>
  298. <groupId>org.ow2.easybeans</groupId>
  299. <artifactId>easybeans-uberjar-eclipselink</artifactId>
  300. <version>1.2.0-M1</version>
  301. </dependency>
  302. </dependencies>
  303.  
  304. <!-- Maven plugin versions are mentioned in order to guarantee the build
  305. reproducibility in the long term -->
  306. <build>
  307. <defaultGoal>install</defaultGoal>
  308. <testResources>
  309. <testResource>
  310. <!-- declared explicitly so Spring config files can be placed next to
  311. their corresponding JUnit test class (see example with ValidatorTests) -->
  312. <directory>${project.basedir}/src/test/java</directory>
  313. </testResource>
  314. <testResource>
  315. <directory>${project.basedir}/src/test/resources</directory>
  316. </testResource>
  317. </testResources>
  318. <plugins>
  319. <plugin>
  320. <groupId>org.apache.maven.plugins</groupId>
  321. <artifactId>maven-compiler-plugin</artifactId>
  322. <version>3.0</version>
  323. <configuration>
  324. <compilerArguments>
  325. <Xlint />
  326. </compilerArguments>
  327. <verbose>true</verbose>
  328. <source>${java.version}</source>
  329. <target>${java.version}</target>
  330. <showWarnings>true</showWarnings>
  331. </configuration>
  332. </plugin>
  333. <plugin>
  334. <groupId>org.apache.maven.plugins</groupId>
  335. <artifactId>maven-surefire-plugin</artifactId>
  336. <configuration>
  337. </configuration>
  338. </plugin>
  339. <plugin>
  340. <groupId>org.apache.maven.plugins</groupId>
  341. <artifactId>maven-eclipse-plugin</artifactId>
  342. <version>2.9</version>
  343. <configuration>
  344. <downloadSources>true</downloadSources>
  345. <downloadJavadocs>true</downloadJavadocs>
  346. <wtpversion>2.0</wtpversion>
  347. <sourceIncludes>
  348. <sourceInclude>**/*.*</sourceInclude>
  349. </sourceIncludes>
  350. <additionalBuildcommands>
  351. <buildCommand>
  352. <name>org.springframework.ide.eclipse.core.springbuilder</name>
  353. </buildCommand>
  354. <buildCommand>
  355. <name>org.eclipse.m2e.core.maven2Builder</name>
  356. </buildCommand>
  357. </additionalBuildcommands>
  358. <additionalProjectnatures>
  359. <projectnature>org.eclipse.jdt.core.javanature</projectnature>
  360. <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
  361. <projectnature>org.eclipse.m2e.core.maven2Nature</projectnature>
  362. </additionalProjectnatures>
  363. </configuration>
  364. </plugin>
  365. <plugin>
  366. <groupId>org.apache.maven.plugins</groupId>
  367. <artifactId>maven-assembly-plugin</artifactId>
  368. <version>2.4</version>
  369. <configuration>
  370. <descriptorRefs>
  371. <descriptorRef>jar-with-dependencies</descriptorRef>
  372. </descriptorRefs>
  373. </configuration>
  374. </plugin>
  375. <plugin>
  376. <groupId>org.apache.tomcat.maven</groupId>
  377. <artifactId>tomcat7-maven-plugin</artifactId>
  378. <version>2.0</version>
  379. <configuration>
  380. <server>tomcat-development-server</server>
  381. <port>9966</port>
  382. <path>/petclinic</path>
  383. </configuration>
  384. </plugin>
  385. <plugin>
  386. <groupId>org.apache.maven.plugins</groupId>
  387. <artifactId>maven-jar-plugin</artifactId>
  388. <version>2.4</version>
  389. <executions>
  390. <execution>
  391. <goals>
  392. <goal>test-jar</goal>
  393. </goals>
  394. </execution>
  395. </executions>
  396. </plugin>
  397. </plugins>
  398. </build>
  399.  
  400. </project>

我重新启动我的电脑,现在我看到其他错误(也许我改变的东西但我发布了实际的dtate的pom.xml)

  1. org.springframework.web.util.NestedServletException: Handler processing Failed; nested exception is java.lang.NoSuchMethodError: javax.el.ExpressionFactory.newInstance()Ljavax/el/ExpressionFactory;
  2. at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259)
  3. at ...

如果我在2.2上更改jsp-api版本

我看到下一个痕迹:

  1. updateEvent(com.epam.hhsystem.web.controllers.EventMenuControllerTest) Time elapsed: 0.398 sec <<< ERROR!
  2. org.springframework.web.util.NestedServletException: Handler processing Failed; nested exception is java.lang.ExceptionInInitializerError
  3. at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259)
  4. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
  5. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
  6. ....
  7. Caused by: java.lang.ExceptionInInitializerError
  8. at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateExpression(ResourceBundleMessageInterpolator.java:227)
  9.  
  10. ....
  11. Caused by: javax.el.ELException: Provider com.sun.el.ExpressionFactoryImpl not found
  12. at javax.el.FactoryFinder.newInstance(FactoryFinder.java:97)
  13.  
  14. ...
  15. Caused by: java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl
  16. at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
@H_301_50@

解决方法

我遇到同样的问题,添加以下依赖关系解决了这个问题.

当遇到javax / el / PropertyNotFoundException时,这意味着你错过了el-api依赖,可以添加以下jar

  1. <dependency>
  2. <groupId>javax.el</groupId>
  3. <artifactId>el-api</artifactId>
  4. <version>2.2</version>
  5. <scope>provided</scope>
  6. </dependency>

要么

  1. <dependency>
  2. <groupId>javax.el</groupId>
  3. <artifactId>javax.el-api</artifactId>
  4. <version>3.0.0</version>
  5. <scope>test</scope>
  6. </dependency>

那么你遇到了ClassNotFoundException:com.sun.el.E​​xpressionFactoryImpl,你错过了el-impl jar:

  1. <dependency>
  2. <groupId>org.glassfish.web</groupId>
  3. <artifactId>el-impl</artifactId>
  4. <version>2.2</version>
  5. <scope>test</scope>
  6. </dependency>
@H_301_50@ @H_301_50@

猜你在找的Java相关文章