1. 程式人生 > >分布式網上商城項目-項目查詢功能錯誤

分布式網上商城項目-項目查詢功能錯誤

ces price PC fabric default fir 運行 spa isp

1、Jdbc內存泄露問題

 1 嚴重: The web application [] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
 2 
 3 6月 02, 2018 2:42:06 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
4 5 嚴重: The web application [] registered the JDBC driver [com.alibaba.druid.mock.MockDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 6 7 6月 02, 2018 2:42:06 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
8 9 嚴重: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 10 11 6月 02, 2018 2:42:06 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
12 13 嚴重: The web application [] registered the JDBC driver [com.mysql.fabric.jdbc.FabricMySQLDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 14 15 6月 02, 2018 2:42:06 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 16 17 嚴重: The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. 18 19 6月 02, 2018 2:42:06 下午 org.apache.coyote.AbstractProtocol start

網上查詢之後知道得到錯誤原因是DruidDriver內存泄漏,

要避免這個信息,應用或框架應該自己來保證在銷毀時將JDBC Driver反註冊掉。

我想DruidDriver應該有解決辦法,於是改變關鍵詞繼續百度,發現最新版本的DruidDriver已經修復了這個bug,於是將版本更新為1.1.9

更新之後還是失敗,

最後找到原因是pageHelper和逆向工程沖突使得沒有辦法銷毀jdbc

2、web層接收數據錯誤

 1 com.alibaba.dubbo.remoting.RemotingException: Failed to send response: Response [id=2, version=2.0.0, status=20, event=false, error=null, result=RpcResult [result=cn.thyonline.taotao.common.pojo.EasyUIDataGridResult@348d42a0, exception=null]], cause: java.lang.IllegalStateException: Serialized class cn.thyonline.taotao.common.pojo.EasyUIDataGridResult must implement java.io.Serializable
 2 
 3 java.lang.IllegalStateException: Serialized class cn.thyonline.taotao.common.pojo.EasyUIDataGridResult must implement java.io.Serializable
 4 
 5          at com.alibaba.com.caucho.hessian.io.SerializerFactory.getDefaultSerializer(SerializerFactory.java:261)
 6 
 7          at com.alibaba.com.caucho.hessian.io.SerializerFactory.getSerializer(SerializerFactory.java:233)
 8 
 9          at com.alibaba.com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:406)
10 
11          at com.alibaba.dubbo.common.serialize.support.hessian.Hessian2ObjectOutput.writeObject(Hessian2ObjectOutput.java:92)
12 
13          at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCodec.encodeResponseData(DubboCodec.java:200)
14 
15          at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.encodeResponse(ExchangeCodec.java:276)
16 
17          at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:77)
18 
19          at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:39)
20 
21          at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:81)
22 
23          at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.doEncode(OneToOneEncoder.java:66)
24 
25          at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:59)
26 
27          at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
28 
29          at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:784)
30 
31          at org.jboss.netty.channel.SimpleChannelHandler.writeRequested(SimpleChannelHandler.java:292)
32 
33          at com.alibaba.dubbo.remoting.transport.netty.NettyHandler.writeRequested(NettyHandler.java:99)
34 
35          at org.jboss.netty.channel.SimpleChannelHandler.handleDownstream(SimpleChannelHandler.java:254)
36 
37          at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591)
38 
39          at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:582)
40 
41          at org.jboss.netty.channel.Channels.write(Channels.java:704)
42 
43          at org.jboss.netty.channel.Channels.write(Channels.java:671)
44 
45          at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:248)
46 
47          at com.alibaba.dubbo.remoting.transport.netty.NettyChannel.send(NettyChannel.java:98)
48 
49          at com.alibaba.dubbo.remoting.transport.AbstractPeer.send(AbstractPeer.java:51)
50 
51          at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:171)
52 
53          at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
54 
55          at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
56 
57          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
58 
59          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
60 
61          at java.base/java.lang.Thread.run(Thread.java:844)

java.io.Serializable可以發現因為在dubbo中傳遞的數據類型為EasyUIDataGridResult不是字節流形式傳遞,需要序列化操作

序列化是什麽:

序列化就是將一個對象的狀態(各個屬性量)保存起來,然後在適當的時候再獲得。

序列化分為兩大部分:序列化和反序列化。序列化是這個過程的第一部分,將數據分解成字節流,以便存儲在文件中或在網絡上傳輸。反序列化就是打開字節流並重構對象。對象序列化不僅要將基本數據類型轉換成字節表示,有時還要恢復數據。恢復數據要求有恢復數據的對象實例

3、pageHelper出錯

 1 警告: Hessian/Burlap: ‘com.github.pagehelper.Page‘ is an unknown class in WebappClassLoader
 2 
 3   context:
 4 
 5   delegate: false
 6 
 7   repositories:
 8 
 9     /WEB-INF/classes/
10 
11 ----------> Parent Classloader:
12 
13 ClassRealm[plugin>org.apache.tomcat.maven:tomcat7-maven-plugin:2.2, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@4629104a]
14 
15 :
16 
17 java.lang.ClassNotFoundException: com.github.pagehelper.Page


com.github.pagehelper.Page是一個沒有找到的類。Google之後發現原因是

service層有pageHelper的依賴,但是web層沒有,所以傳遞過來的pageHelper的數據沒有找對對應的類,解決辦法就是在web層中加入pageHelper的依賴

4、頁面沒有顯示查詢列表,但是後端數據測試知道已經傳遞到前端

 1 Uncaught TypeError: Cannot read property ‘length‘ of undefined
 2 
 3     at Object.render (jquery.easyui.min.js:9903)
 4 
 5     at _5f6 (jquery.easyui.min.js:8837)
 6 
 7     at jquery.easyui.min.js:9422
 8 
 9     at Object.success (jquery.easyui.min.js:10128)
10 
11     at j (jquery.min.js:2)
12 
13     at Object.fireWith [as resolveWith] (jquery.min.js:2)
14 
15     at x (jquery.min.js:4)
16 
17     at XMLHttpRequest.b (jquery.min.js:4)


技術分享圖片

查看網頁的響應會發現數據已經在網頁端接收到

所以可以推斷整個架構沒有問題。但是沒能在頁面正常顯示。查看靜態頁面的寫好的數據:

 1 {"total":28,"rows":[
 2 
 3          {"productid":"FI-SW-01","unitcost":10.00,"status":"P","listprice":36.50,"attr1":"Large","itemid":"EST-1"},
 4 
 5          {"productid":"K9-DL-01","unitcost":12.00,"status":"P","listprice":18.50,"attr1":"Spotted Adult Female","itemid":"EST-10"},
 6 
 7          {"productid":"RP-SN-01","unitcost":12.00,"status":"P","listprice":28.50,"attr1":"Venomless","itemid":"EST-11"},
 8 
 9          {"productid":"RP-SN-01","unitcost":12.00,"status":"P","listprice":26.50,"attr1":"Rattleless","itemid":"EST-12"},
10 
11          {"productid":"RP-LI-02","unitcost":12.00,"status":"P","listprice":35.50,"attr1":"Green Adult","itemid":"EST-13"},
12 
13          {"productid":"FL-DSH-01","unitcost":12.00,"status":"P","listprice":158.50,"attr1":"Tailless","itemid":"EST-14"},
14 
15          {"productid":"FL-DSH-01","unitcost":12.00,"status":"P","listprice":83.50,"attr1":"With tail","itemid":"EST-15"},
16 
17          {"productid":"FL-DLH-02","unitcost":12.00,"status":"P","listprice":63.50,"attr1":"Adult Female","itemid":"EST-16"},
18 
19          {"productid":"FL-DLH-02","unitcost":12.00,"status":"P","listprice":89.50,"attr1":"Adult Male","itemid":"EST-17"},
20 
21          {"productid":"AV-CB-01","unitcost":92.00,"status":"P","listprice":63.50,"attr1":"Adult Male","itemid":"EST-18"}
22 
23 ],"footer":[
24 
25          {"unitcost":19.80,"listprice":60.40,"productid":"Average:"},
26 
27          {"unitcost":198.00,"listprice":604.00,"productid":"Total:"}
28 
29 ]}

檢查傳來數據的名稱和json需要的數據的名稱可以發現EasyUIDataGridResult裏面的參數寫成了row然後轉成json數據傳遞。但是在頁面需要的數據為rows則不匹配。

於是將EasyUIDataGridResult中的數據名稱修改,再次運行則成功顯示。

分布式網上商城項目-項目查詢功能錯誤