Openfire source code debugging and compiling Development Environment

Source: Internet
Author: User
Tags i18n testng

Note:Development Environment (IDE): Eclipse 3.3.2 + jdk1.6 + ant 1.720.openfire_src_3_5_1.zip

1. IfCodeUsedImport testng. xxx statement, you need to import the testng-5.8-jdk15.jar class library;

2. Warning Information is irrelevant. This is because the warning information is generated only when JDK 1.5 or later is used. If JDK is used, the warning information is not displayed. Some of these codes are compiled using JDK 1.4, while JDK 1.5 does not support generics, while JDK and JDK 1.6 Support generics. The warning information mainly prompts you to change these non-generic code to a more advanced method-generic, so the warning information does not affect the code result.

If you want to modify it to a generic type, you can use the generic type to process related collection classes.

3. In useWhen ant is compiled, the following warning message may appear in the ant View:

Taskdef class com. install4j. install4jtask cannot found

This is mainly used to package Java applications.ProgramTo install the install4j.exe program in the default installation path. C: "Program Files" directory.

4. There is a package icon in the source code folder. Double-click the icon,Install4jIt will read your information in the build. xml file, complete the packaging work such as the interface.

Compiling and debugging environment (IDE ):Eclipse 3.3.2 + jdk1.6 + ant (built-in)+Openfire_src_2008-06-04.zip

Before compiling and debugging openfire in a Windows operating system, make sure that the http ssl Service has been started. Otherwise, various error messages will appear.

1.ObtainOpenfireSource code

Download the official website's source code openfire_src_2008-06-04.zip from the official website;

2.CreateOpenfire Project

After openfire_src_2008-06-04.zipis decompressed, the contents are excluded from the three webpage files reademe.html#license.htmland changelog.html, which have the following sub-directories.

BuildDirectory:The build directory contains the files required to generate the Installation File (for example, rpm), such as JRE.

ResourcesDirectory:The resources directory contains some encoding files (such as English, Chinese, French, and German) for internationalization (i18n) and localization ).

documentation directory: the documentation directory contains information about openfire installation and configuration, but the javadoc developed by openfire is required.

SRCDirectory:This SRC folder is the openfire source code we want. There are many folders below. We only need the Java folder. The core functions of openfire implemented here can be used to debug openfire.

If you are doing secondary development, you can use this method to customize your own server:

(1) create a project: file-> New-> Project-> JAVA project, click Next, enter the Project name: openfire in the Project Name text box, and click Finish

(2) decompress the obtained openfire_src_3_5_1 "src directory and copy all the content to the new project directory workspace" openfire.

(3) in the package explorer view, right-click the openfire project and select properties. In the displayed dialog box, choose libraries-> Add jars .., in the openfire_src_3_5_1/build/lib directory *. add all jar class libraries. Select the source tab, add folder .., select the check box before the src/Java directory, click OK, and click OK.

(In eclipse, the Java folder is used as the source code folder to create a project. After creating a new project, observe the packages imported by openfire. It is found that openfire uses many open-source tools, these libraries are added to the referenced libraries of the new project in the lib directory of the build directory mentioned above. Or if it is troublesome to add one by one, you can use the lib directory under the openfire Server Directory you have installed (for example, "D: "Program Files" openfire "lib" or "/usr/local/openfire/lib") Find openfire. jar, open it, delete ORG/jivesoftware, repackage it into a jar, and add it to the referenced libraries of the new project. This saves a lot of similar work .)

(4) but the newly created openfire project is not packaged and deployed, and developers need to complete the corresponding work on their own.

Note: Some warning information may appear after a new project is created, which is described below:

Warning Information is irrelevant. This is because the warning information is generated only when JDK 1.5 or later is used. If JDK is used, the warning information is not displayed. Some of these codes are compiled using JDK 1.4, while JDK 1.5 does not support generics, while JDK and JDK 1.6 Support generics. The warning information mainly prompts you to change these non-generic code to a more advanced method-generic, so the warning information does not affect the code result. If you want to modify it to a generic type, you can use the generic type to process related collection classes.

3.Compile the project

Openfire is usedAnt build, so you must first set so that every compilation in eclipse uses the built-in ant tool to ensure the correct execution of the compilation. At the same time, you must set JDK as JVM in eclipse. If JRE is used as JVM, compilation will fail.

Because openfireworks uses install4jto package an installation file in the .exe format in Windows, you need to install install4j. OtherwiseWhen ant is compiled, the following warning message may appear in the ant view: taskdef class com. install4j. install4jtask cannot found. Install the install4j.exe program of the Java application program and install it in the default installation path C: "Program Files" install4j.

Note:Sometimes, errors shown in the following figure may occur during Windows installation, leading to installation failure.

However, you only need to install the programInstall4j_windows_4_1_2_with_jre.exe copy to the directory indicated above for installation. For example, copy to C: "Documents and Settings" liaolonglong directory.

(1) In eclipse, click WINDOW> show View> ant to open the ant window;

(2) In the ant view, right-click and choose add buildfiles... from the shortcut menu ..;

(3) In the displayed dialog box, expand the openfire/build folder, select build. xml under the build directory, and click OK;

(4) In the ant view, expand openfire XMPP server and double-click openfire (default) to compile the project.

(5) If "build successful" is displayed in the console view, the compilation is successful.

7. Create a projectBuilder

(1) On the eclipse menu bar, choose run> open run dialog ..., in the pop-up dialog box, select Java application in the tree structure on the left, right-click, and select new to create the startup configuration.

(2) on the main Tab Of The Run window, modify the value in the name text box to the project name openfire containing the class to be started.

(3) on the main Tab Of The Run window, click the Browse button and select openfire

(4) on the main Tab Of The Run window, click Search and select main class

Org. jivesoftware. openfire. starter. serverstarter, and click Apply. (This is the startup class of openfire)

(5) Click the arguments tab and enter

-Dopenfirehome = "$ {workspace_loc: openfire}/target/openfire"

Click Apply. This is the parameter passed when eclipse executes the Java command, so that the openfire program can obtain the local location of openfire through system. getproperty ("openfirehome.

(6) Click the classpath tab and select user entries, so that advanced... is available. Click the advanced... button, select Add folders on the advanced options page, and click OK. (By default, the project openfire has been added here, and this operation is not required. If there are multiple projects, this operation is required .)

Select openfire "src" i18n and click OK to add the folder to the classpath tab. In the same way, add the jar folder under the openfire "src" Resources Directory to the classpath tab.

(11) on the common tab, select the run check box and click the Apply button.

After the settings are completed, the project will be run according to the correct configuration. The debug settings are similar to the run settings.

Note: The error message is as follows:

HTTP Error: 500

Internal_server_error

Requesturi =/Setup/index. jsp

Caused:

Java. Lang. nullpointerexception

At org. jivesoftware. admin. adminconsole. getappname (adminconsole. Java: 122)

At org. jivesoftware. openfire. admin. decorators. setup_jsp. _ jspservice (setup_jsp.java: 168)

At org. Apache. Jasper. runtime. httpjspbase. Service (httpjspbase. Java: 97)

At javax. servlet. http. httpservlet. Service (httpservlet. Java: 820)

At org. mortbay. Jetty. servlet. servletholder. Handle (servletholder. Java: 487)

At org. mortbay. Jetty. servlet. servlethandler. Handle (servlethandler. Java: 362)

At org. mortbay. Jetty. Security. securityhandler. Handle (securityhandler. Java: 216)

At org. mortbay. Jetty. servlet. sessionhandler. Handle (sessionhandler. Java: 181)

At org. mortbay. Jetty. handler. contexthandler. Handle (contexthandler. Java: 726)

At org. mortbay. Jetty. webapp. webappcontext. Handle (webappcontext. Java: 405)

At org. mortbay. Jetty. servlet. Dispatcher. Include (dispatcher. Java: 192)

At com. opensymphony. Module. sitemesh. Filter. pagefilter. applydecorator (pagefilter. Java: 156)

At com. opensymphony. Module. sitemesh. Filter. pagefilter. dofilter (pagefilter. Java: 59)

At org. mortbay. Jetty. servlet. servlethandler $ cachedchain. dofilter (servlethandler. Java: 1084)

At org. jivesoftware. util. localefilter. dofilter (localefilter. Java: 66)

At org. mortbay. Jetty. servlet. servlethandler $ cachedchain. dofilter (servlethandler. Java: 1084)

At org. jivesoftware. util. setcharacterencodingfilter. dofilter (setcharacterencodingfilter. Java: 42)

At org. mortbay. Jetty. servlet. servlethandler $ cachedchain. dofilter (servlethandler. Java: 1084)

At org. jivesoftware. admin. pluginfilter. dofilter (pluginfilter. Java: 70)

At org. mortbay. Jetty. servlet. servlethandler $ cachedchain. dofilter (servlethandler. Java: 1084)

At org. jivesoftware. admin. authcheckfilter. dofilter (authcheckfilter. Java: 99)

At org. mortbay. Jetty. servlet. servlethandler $ cachedchain. dofilter (servlethandler. Java: 1084)

At org. mortbay. Jetty. servlet. servlethandler. Handle (servlethandler. Java: 360)

At org. mortbay. Jetty. Security. securityhandler. Handle (securityhandler. Java: 216)

At org. mortbay. Jetty. servlet. sessionhandler. Handle (sessionhandler. Java: 181)

At org. mortbay. Jetty. handler. contexthandler. Handle (contexthandler. Java: 726)

At org. mortbay. Jetty. webapp. webappcontext. Handle (webappcontext. Java: 405)

At org. mortbay. Jetty. handler. contexthandlercollection. Handle (contexthandlercollection. Java: 206)

At org. mortbay. Jetty. handler. handlercollection. Handle (handlercollection. Java: 114)

At org. mortbay. Jetty. handler. handlerwrapper. Handle (handlerwrapper. Java: 152)

At org. mortbay. Jetty. server. Handle (server. Java: 324)

At org. mortbay. Jetty. httpconnection. handlerequest (HTTP connection. Java: 505)

At org. mortbay. Jetty. httpconnection $ requesthandler. headercomplete (httpconnection. Java: 829)

At org. mortbay. Jetty. httpparser. parsenext (httpparser. Java: 514)

At org. mortbay. Jetty. httpparser. parseavailable (httpparser. Java: 211)

At org. mortbay. Jetty. httpconnection. Handle (httpconnection. Java: 380)

At org. mortbay. Io. NiO. selectchannelendpoint. Run (selectchannelendpoint. Java: 395)

At org. mortbay. thread. queuedthreadpool $ poolthread. Run (queuedthreadpool. Java: 488)

Powered by Jetty ://

In this case, you needThe admin-sidebar.xml and openfire_i18n_en.properties files can be directly stored in the openfire "bin directory to solve this problem.

If this problem occurs again, you need to delete the work and target files in the openfire directory, and then release one again. Because the web content is not automatically updated, only. Class is automatically updated.

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.