JRebel施用(一)eclipse调试tomcat6.0.18

JRebel应用(一)eclipse调试tomcat6.0.18
JRebel应用(一)eclipse调试tomcat6.0.18

最近启动一次TOMCAT巨慢的速度。所以想整个修改了class不用重启的东东来用。很早以前就听说过这个东东了。不过貌似以前发现时收费的,所以
就没有什么兴趣,就没有使用。这次却是项目需要,而且一个同事也配置试验成功了。所以我也去下载过来使用一下。

首页
http://www.zeroturnaround.com/jrebel/
参考别人的BLOG破解
http://www.blogjava.net/beansoft/archive/2009/10/21/299250.html
http://www.blogjava.net/usherlight/archive/2009/10/15/298449.html
安装eclipse插件的文档
http://www.zeroturnaround.com/jrebel/eclipse-jrebel-tutorial/

先在首页上下载了原版本的jrebel,版本是jrebel-2.1.1.zip,先自己反编译一个最新版

反编译工具
http://java.decompiler.free.fr/
如果用GUI工具,下载过来名字为jd-gui-0.3.1.windows.zip,解开压缩直接运行。
eclipse插件在线安装地址
http://java.decompiler.free.fr/jd-eclipse/update
如果用ECLIPSE插件,下载过来名字是jdeclipse_update_site.zip,按照plugins的方式安装

看了看,也没有看到文章上说的代码。也可能是我这里反编译出来的问题,或者是版本是2.2.1的问题。没有时间去自己破解了。
我就直接用同事发的破解版本了:)

安装jrebel的eclipse插件
http://www.zeroturnaround.com/update-site/

设置插件window----Preferences-------JavaRebel
在Path to javarebel.jar上选上我本机的路径D:\eclipse-plugins\jrebel\jrebel-3.0-M1.jar
设置eclipse工具Window----Preferences------Java-----Debug-----Step Filtering
勾中User Step Filters,Filter synthetic methods 和Step through filters和Filter synthetic methods
点击Add Filters添加
com.zeroturnaround.*
org.zeroturnaround.*

设置项目
选中项目名称,点击Generate rebel.xml,生成的内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">
<classpath>
   <dir name="D:/project/CPMIS-Core/Code/Trunk/main/web/WEB-INF/classes">
   </dir>
</classpath>
<web>
   <link target="/">
    <dir name="D:/project/CPMIS-Core/Code/Trunk/main/web">
    </dir>
   </link>
</web>
</application>

将应用改成Publishing -----Never publish automatically

点击Run Configuration------Apache Tomcat-------JavaRebel
勾上 Enable JavaRebel agent
这个勾上相当于在JAVA启动参数中增加了-javaagent:your_location/javarebel.jar

晕,启动命令行打印出错:
JRebel: Please rename 'jrebel-3.0-M1.jar' to 'jrebel.jar'
JRebel: or add '-Xbootclasspath/a:D:\eclipse-plugins\jrebel\jrebel-3.0-M1.jar' to the command line!

唉,我切按照要求把名字改成jrebel.jar试试,可以了。
不过启动了很久,都没有启动起来,看来是我分给tomcat的内存太小,做了如下修改后,重新启动:
Window-->Preference-->MyEclipse-->Application Servers-->Tomcat-->Tomcat 6.x-->JDK-->Optional Java VM arguments下填上:
-Xms100m -Xmx200m -XX:PermSize=256m -XX:MaxPermSize=600m
或者双击server的名字,点击Open launch configuration-------Arguments------VM arguments里面添加
-Xms100m -Xmx200m -XX:PermSize=256m -XX:MaxPermSize=600m

修改了一个js,发现没有生效,改换下这个设置再试试
将应用去掉Publishing -----Never publish automatically,选择另外一个,好了,JS也可以不同重启TOMCAT了:)

修改了classes之后,tomcat自动重启了。。。汗,修改如下配置再试试
<Context docBase="main" path="/cpmis" reloadable="false" source="org.eclipse.jst.jee.server:main"/>
其中的reloadable改为false

OK啦,修改了JSP或者classes后的日志:
JRebel: Reloading class 'org.apache.jsp.um.editPwd_jsp'.
JRebel: Reloading class 'org.apache.jsp.um.editPwd_jsp'.

完全测试成功,节省了不少开发时间:)