白云哥

身披半件长工衣,怀揣一颗地主心

 

使用NetBeans调试SmartFoxServer的Extension

结束了两个星期的用trace进行SmartFoxserver Extension调试的痛苦历史之后,我决定再来尝试一下怎么在IED环境下进行远程调试。

上一次打算在Eclipse下进行,不知道哪一个环节出错,没能成功,这次改用NetBeans吧,正好赶上NetBeans新版本发布,来试用一次。

 

按照这里描述的方法,很快把Eclipse下创建的工程导入到了NetBeans下,不过遇到了点小问题,一堆的乱码。检查了下发现,Eclipse下创建的文件编码为ANSI,在NetBeans下不识别其中的中文注释,把文件改成UTF-8后问题解决,可后来我再试图在Eclipse下打开这些文件时问题又出现了,Eclipse只识别ANSI编码的文件?似乎不大可能吧,不过一时也没找到解决方法,暂时放弃,改用NetBeans吧。

 

按照论坛上的方法做就行,不过可能因为版本更新的原因,实际做的时候还是有点差别

 

Step 1
Download the
Netbeans IDE for java development. (47mb SE version should be fine!)

这一步就是这样了


Step 2
Install and open Netbeans. Create a project from existing java source pointing to where your extensions are. Should be placed in src subfolder to be nice.
(I for sure could not make it work if the source was not in a subfolder)
Right click on project and choose properties->libraries. Add all jar files from your smartfox installation lib dir.

在NetBeans下导入原来Eclipse创建的文件,只需要src目录即可

导入libraries时注意,按照这里的方法,只需要导入3个jar文件,就是这样

nb5


Step 3
Goto Files tab. Expand nbbuild.xml. Click on -post-compile target.
Copy and paste the following code: (Note: adjust todir to point to your smartfox program extension directory)
<copy todir="C:\Programmer\SmartFoxServerPRO_1.6.6\Server\javaExtensions">
<fileset dir="${build.dir}/classes/"/>
</copy>

我的NetBeans下没有nbbuild.xml,倒是有一个build.xml,不过里面没内容 悲伤

再看了下,原来引用的build-impl.xml,上面有个简单的介绍,在build.xml里添加如下内容即可:

<target name="-post-compile">
        <copy todir="D:\SmartFoxServer\Server\javaExtensions">
            <fileset dir="${build.dir}/classes/"/>
        </copy>
</target>

根据你的SmartFoxServer安装目录进行修改即可


Step 4
Create a new batchfile called SmartFoxDebug?.bat
Copy and paste the following content into it: (Again adjust to your installation directory)
C:\Programmer\SmartFoxServerPRO_1.6.6\Server\wrapper.exe -c "C:\Programmer\SmartFoxServerPRO_1.6.6\Server\conf\wrapper.conf"

这一步不需要,在我安装的目录下直接有个smarfoxService.bat批处理文件,用它就行了


Step 5
Add the following lines to your wrapper.conf

Code:

# runtimedebug
wrapper.java.additional.3=-Xdebug
wrapper.java.additional.4=-Xnoagent
wrapper.java.additional.5=-Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n

这里的意思是要在SmartFoxServer里开户远程调试的监听,在我安装的SFS版本里原来比这多了一项配置,所以最终是这样的:

# Java Additional Parameters
wrapper.java.additional.1=-server
wrapper.java.additional.2=-Dfile.encoding=UTF-8
wrapper.java.additional.3=-Djava.util.logging.config.file=logging.properties
wrapper.java.additional.4=-Xdebug
wrapper.java.additional.5=-Xnoagent
wrapper.java.additional.6=-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

 

Step 6
Choose Run->Build main project (F11) in Netbeans.
If build is ok, click the batch file. Now select debug->attach debugger and choose port 8888. Debugger console should say "User program running".
Now you can place breakpoints and trigger your extensions normally.

这里就是最终我们要实现的效果了,挂接SmartFoxServer的远程JVM进行调试,配置项在 调试(D) 下的 连接调试器(A) ,如果你跟我一样安装的是中文版NetBeans的话 微笑

贴张图,就是这样,注意端口号,是上面配置的那个,不是SFS对客户端连接的监听商品号9393哦

config

 

 

好了,先启动SFS,用上面说的那个批处理文件,你会看到一行提示信息,JVM远程调试的监听已打开

然后连接调试器

在NetBeans里打个断点看看,O了



posted on 2010-07-22 08:12 白云哥 阅读(1974) 评论(0)  编辑 收藏 引用 所属分类: Bada


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

统计

常用链接

留言簿(4)

随笔分类

随笔档案

相册

我的链接

搜索

最新评论

阅读排行榜

评论排行榜