环境

Websphere 8.5.5.11
JDK 1.8
DWR
SpringMVC
Oracle DBMS


我们最近升级了我们的项目,并从

spring.jar,
spring-web.jar,
spring-webmvc.jar
dwr.jar


升级到

spring version 5.1.7
dwr version 3.0.2


我们开始面临多个问题

1. DWR servlet didn't get initialized properly; and complains about Duplicate name found while loading the context, and another problem
   our web.xml trying to inialize both servlets i.e. DispacterServlet and DwrSpringServlet
2. After removing spring, spring-web and spring-webmvc and upgrading to latest versions;
   web project during compilation and loading complains about missing classes;
   spcially one of the .forName methods called during DWR inialization i.e.

   java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.forName(Ljava.......

3. engine.js not found where it supposed to be i.e. this error being thrown
   'You must include DWR engine before including this file'.


您可以在“答案”部分中找到上述答案。

最佳答案

环境

Websphere 8.5.5.11
JDK 1.8
DWR
SpringMVC
Oracle DBMS



您需要严格按照以下http://www.butterdev.com/category/dwr/示例在web.xml和spring-servlet.xml中配置DWR和Spring(MVC或非MVC)
并且您必须仅加载/配置一个servlet。
找不到重复的名称问题,这是由于spring-servlet.xml加载了两次;
这篇https://www.conqtech.com/blog/?p=85帖子有助于解决问题。
您必须包括以下所有罐子。

spring-beans-5.1.7.RELEASE.jar
spring-context-5.1.7.RELEASE.jar
spring-context-support-5.1.7.RELEASE.jar
spring-core-5.1.7.RELEASE.jar
spring-dao-2.0.8.jar
spring-expression-5.1.7.RELEASE.jar
spring-jdbc-5.1.7.RELEASE.jar
spring-tx-5.1.7.RELEASE.jar
spring-web-5.1.7.RELEASE.jar
spring-webmvc-5.1.7.RELEASE.jar
dwr-3.0.2.jar
spring-aop-5.1.7.RELEASE.jar

他们(DWR)团队;进行了更改,以便在对jsp / html页面中的远程引用的.js文件进行远程处理之前,应该声明/导入engine.js文件。
这篇文章有助于解决问题;
https://readthefuckingmanual.net/error/4678/Error-You-must-include-DWR-engine-before-including-this-file


除了上述所有编码技巧外,即使已经定义了SimpleUrlHandlerMapping,也必须如下定义。

<bean
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property value="true" name="alwaysUseFullPath"></property>
<property name="mappings">
  <props>
    <prop key="/dwr/**/*">dwrController</prop>
    <prop key="/interface/**">dwrController</prop>
  </props>
</property>
</bean>


我们按照以下示例解决了上述问题;

http://www.butterdev.com/category/dwr/

我们确实遇到了其他一些编译问题;但是它们是常见的理解和解决方法。

编码愉快!

关于java - DWR 3.0.2 Spring 5.1.7升级'您必须在包含此文件之前包含DWR引擎',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56675041/

10-10 09:20