DWR 3.0.2 Spring 5.1.7 Upgrade 'You must include DWR engine before including this file'

梦想与她 提交于 2020-01-25 10:44:28

问题


Environment

Websphere 8.5.5.11
JDK 1.8
DWR
SpringMVC
Oracle DBMS

We recently upgraded our project, and make updates from

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

upgraded to

spring version 5.1.7
dwr version 3.0.2

We started facing multiple issues

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'.

You can find the answers to above in answers section.


回答1:


Environment

Websphere 8.5.5.11
JDK 1.8
DWR
SpringMVC
Oracle DBMS
  1. You need to strictly follow these http://www.butterdev.com/category/dwr/ examples to configure DWR and Spring (either MVC or non MVC) in web.xml and spring-servlet.xml and you must load/configure one servlet only.
    Duplicate name not found problem was happening due to spring-servlet.xml getting loaded twice; this post https://www.conqtech.com/blog/?p=85 help to resolve the problem.
  2. You have to include all the jars below.

    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
    
  3. They (DWR) team; made a change so that engine.js file should be declared/imported before your remoting referenced .js files in your jsp/html pages. This post help to resolve the problem; https://readthefuckingmanual.net/error/4678/Error-You-must-include-DWR-engine-before-including-this-file.

In addition to all the coding tips above; you must have to define SimpleUrlHandlerMapping as below even you have one already defined.

<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>

And we followed below examples to fix the above problems;

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

We did faced some other compilation issues; but they are common to understand and resolve.

Happy coding!




回答2:


late response but resolved similar problem, may help others. The short answer is that Spring 5 and DWR 3.0.1 are not compatible. DWR 3.0.1 is using old class from Sprig 3 which is causing problem, you can switch to DWR 3.0.2 and try with it.



来源:https://stackoverflow.com/questions/56675041/dwr-3-0-2-spring-5-1-7-upgrade-you-must-include-dwr-engine-before-including-thi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!