Debug extension of smartfoxserver using netbeans

Source: Internet
Author: User
Tags netbeans

After two weeks of debugging with trace for smartfoxserver extension, I decided to try remote debugging in the IED environment.

The last attempt was made in eclipse. I don't know which part of the process went wrong and failed. I switched to netbeans this time, just in time for release of the new version of netbeans.

According to the method described here, I quickly imported the project created under eclipse to netbeans, but encountered a small problem, a bunch of garbage codes. Check the found that the file created under eclipse is encoded as ANSI, under netbeans does not recognize the Chinese notes, the file into a UTF-8 after the problem is solved, but then I tried to open these files in eclipse again. Does Eclipse only recognize ANSI-encoded files? It seems unlikely, but I haven't found a solution for the moment. I will give up temporarily. Use netbeans instead.

Just follow the methods on the Forum, but it may be because of version updates, but it is still a little different in practice.

Step 1
Download the netbeans IDE for Java Development. (47 MB se version shocould be fine !)

This step is like this.

Step 2
Install and open netbeans. Create a project from existing Java source pointing to where your extensions are. shoshould be placed in SRC subfolder to be nice.
(I for sure cocould 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.

Import the original file created by ECLIPSE under netbeans. You only need the src directory.

When importing libraries, note that you only need to import Three jar files according to the method here.

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)


There is no nbbuild. XML in netbeans, but there is a build. xml file, but there is no content in it.

Again, the original reference build-impl.xml, there is a simple introduction, add the following content in build. xml:





Modify the installation directory of your 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"

This step is not required. There is a smarfoxservice. bat batch file in the directory I have installed. Just use it.

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

This means that the remote debugging listener should be opened in smartfoxserver. In the SFS version I installed, there was an additional configuration, so the final result is as follows:

# 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 shocould say "user program running ".
Now you can place breakpoints and trigger your extensions normally.

Here is the final implementation result. It is attached to the remote JVM of smartfoxserver for debugging. The configuration item is connected to the debugger (a) under debugging (d ), if you install the Chinese version netbeans like me

Paste a picture, that is, pay attention to the port number, which is the one configured above, not the SFS listening product number 9393 for client connection.

Okay, start SFS first, and use the batch processing file mentioned above, you will see a line of prompt information, the JVM remote debugging listener has been opened

Connect to the debugger

Open a breakpoint in netbeans.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.