我從Git-Repository(https://github.com/igniterealtime/Openfire)克隆Openfire-Source,將其設置到Eclipse中並對其進行了Ant構建。 Openfire正在運行我的自定義配置,並連接到一個MySQL數據庫,它存儲用戶,密碼...從Eclipse啓動服務器工作正常。將Openfire服務器集成(嵌入)到另一個Java項目
我的目標是從另一個Java項目(本例中是JavaFX)啓動Openfire「隱形」。如果可能,我想將兩個項目合併爲一個。
構建Openfire項目已添加到我的JavaFX應用程序的類路徑中。
1)首先,我試圖實例Openfires startup.jar文件在我現有的JavaFX的舞臺控制器,
public void initialize(URL url, ResourceBundle rb) {
initListener();
initContents();
org.jivesoftware.openfire.starter.ServerStarter.main(null);
...
}
像預期的那樣,VM參數缺少:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/knoop/Desktop/java/slf4j-1.7.13/slf4j-jdk14-1.7.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/knoop/Desktop/java/Openfire_git/build/lib/ant/slf4j-simple.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/knoop/Desktop/java/Openfire_git/build/lib/dist/slf4j-log4j12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
Jan 27, 2016 5:52:28 PM org.jivesoftware.util.Log warn
WARNUNG: Admin Lib Directory ../plugins/admin/webapp/WEB-INF/lib does not exist. Web admin console may not work.
Could not locate home
java.io.FileNotFoundException
at org.jivesoftware.openfire.XMPPServer.locateOpenfire(XMPPServer.java:827)
at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:304)
at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:440)
at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:169)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:105)
at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56)
at org.server_fx.GUI.controller.MainScreenController.initialize(MainScreenController.java:53)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at org.server_fx.GUI.controller.GUI_Shared.loadFXMLToStage(GUI_Shared.java:63)
at org.server_fx.GUI.fxml.Manager.start(Manager.java:24)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$149(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Jan 27, 2016 5:52:28 PM org.jivesoftware.openfire.XMPPServer start
SCHWERWIEGEND: null
java.io.FileNotFoundException
at org.jivesoftware.openfire.XMPPServer.locateOpenfire(XMPPServer.java:827)
at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:304)
at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:440)
at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:169)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:105)
at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56)
at org.server_fx.GUI.controller.MainScreenController.initialize(MainScreenController.java:53)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at org.server_fx.GUI.controller.GUI_Shared.loadFXMLToStage(GUI_Shared.java:63)
at org.server_fx.GUI.fxml.Manager.start(Manager.java:24)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$149(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Jan 27, 2016 5:52:28 PM org.jivesoftware.util.LocaleUtils getLocalizedString
SCHWERWIEGEND: Can't find bundle for base name openfire_i18n, locale de_DE
Critical Error! The home directory has not been configured,
which will prevent the application from working correctly.
startup.error
導致在缺少Openfire主目錄中。
2)Openfire.bat包含啓動服務器的特定參數(DopenfireHome =「%OPENFIRE_HOME%」)。
所以,我想:
public void initialize(URL url, ResourceBundle rb) {
initListener();
initContents();
try {
Process proc = Runtime.getRuntime().exec("java" -DopenfireHome=\"C:\\Users\\knoop\\Desktop\\java\\Openfire_git\\target\\openfire\" -jar C:\\Users\\knoop\\Desktop\\java\\Openfire_git\\target\\openfire\lib\startup.jar");
} catch (IOException e) { e.printStackTrace(); }
...
}
導致一無所獲。沒有例外或其他。
是否有另一種方法來從另一個Java-Project實例化OpenFire服務器,或者「無形」地使用正確的啓動參數在後臺啓動服務器?