随笔分类 - Openfire/XMPP

本文提供了一个指向具体学习内容的链接,虽然没有详细描述,但旨在引导读者深入学习某个特定的技术主题。
http://www.cnblogs.com/hoojo/category/380029.html学习下
[root@yfw ~]# cd /opt/openfire [root@yfw openfire]# # 1. 停止服务 [root@yfw openfire]# systemctl stop openfire [root@yfw openfire]# [root@yfw openfire]# # 2. 清理缓存 [root@yfw openfire]# rm -rf /opt/openfire/work /opt/openfire/target [root@yfw openfire]# [root@yfw openfire]# # 3. 删除旧插件 [root@yfw openfire]# rm -rf /opt/openfire/plugins/hello-plugin [root@yfw openfire]# [root@yfw openfire]# # 4. 确保源码存在 [root@yfw openfire]# ls -p /root/openfire-plugin-build/src/main/java/com/example/restapi/RestApiPlugin.java || echo "源码不存在!" /root/openfire-plugin-build/src/main/java/com/example/restapi/RestApiPlugin.java [root@yfw openfire]# [root@yfw openfire]# # 5. 编译 Java 类(关键!) [root@yfw openfire]# mkdir -p /root/openfire-plugin-build/target/classes [root@yfw openfire]# [root@yfw openfire]# javac -cp "/opt/openfire/lib/*" \ > /root/openfire-plugin-build/src/main/java/com/example/restapi/RestApiPlugin.java \ > -d /root/openfire-plugin-build/target/classes /root/openfire-plugin-build/src/main/java/com/example/restapi/RestApiPlugin.java:3: error: cannot access Plugin import org.jivesoftware.openfire.container.Plugin; ^ bad class file: /opt/openfire/lib/xmppserver-4.9.2.jar(org/jivesoftware/openfire/container/Plugin.class) class file has wrong version 55.0, should be 52.0 Please remove or make sure it appears in the correct subdirectory of the classpath. [root@yfw openfire]# [root@yfw openfire]# # 6. 验证 class 文件生成 [root@yfw openfire]# if [ ! -f /root/openfire-plugin-build/target/classes/com/example/restapi/RestApiPlugin.class ]; then > echo "❌ 编译失败!class 文件未生成" > exit 1 > fi [root@yfw openfire]# [root@yfw openfire]# # 7. 打包 JAR(必须在 classes 目录下执行) [root@yfw openfire]# cd /root/openfire-plugin-build/target/classes [root@yfw classes]# jar cvf ../restapi.jar . added manifest adding: com/(in = 0) (out= 0)(stored 0%) adding: com/example/(in = 0) (out= 0)(stored 0%) adding: com/example/restapi/(in = 0) (out= 0)(stored 0%) adding: com/example/restapi/RestApiPlugin.class(in = 782) (out= 507)(deflated 35%) [root@yfw classes]# [root@yfw classes]# # 8. 创建插件目录结构 [root@yfw classes]# mkdir -p /opt/openfire/plugins/hello-plugin/{classes,lib,web} [root@yfw classes]# [root@yfw classes]# # 9. 写入 plugin.xml [root@yfw classes]# cat > /opt/openfire/plugins/hello-plugin/classes/plugin.xml << 'EOF' > <?xml version="1.0" encoding="UTF-8"?> > <plugin> > <className>com.example.restapi.RestApiPlugin</className> > <name>Hello Plugin</name> > <description>A minimal working plugin</description> > <version>1.0.0</version> > <author>Admin</author> > <minServerVersion>4.0.0</minServerVersion> > <maxServerVersion>5.0.0</maxServerVersion> > </plugin> > EOF [root@yfw classes]# [root@yfw classes]# # 10. 复制 JAR [root@yfw classes]# cp /root/openfire-plugin-build/target/restapi.jar /opt/openfire/plugins/hello-plugin/lib/ [root@yfw classes]# [root@yfw classes]# # 11. 设置权限 [root@yfw classes]# chown -R openfire:openfire /opt/openfire/plugins/hello-plugin [root@yfw classes]# [root@yfw classes]# # 12. 启动服务 [root@yfw classes]# systemctl start openfire [root@yfw classes]# [root@yfw classes]# # 13. 等待加载 [root@yfw classes]# sleep 15 [root@yfw classes]# [root@yfw classes]# # 14. 查看日志 [root@yfw classes]# tail -f /opt/openfire/logs/openfire.log | grep -i "hello-plugin\|found new plugin\|loaded plugin\|restapi"
10-04
[root@yfw ~]# cd /etc/systemd/system [root@yfw system]# sudo -u openfire tee /opt/openfire/conf/database.properties > /dev/null << 'EOF' > jdbcProvider.className=org.jivesoftware.database.HSQLDBConnectionProvider > jdbcProvider.connectionString=jdbc:hsqldb:hsql://localhost:9001 > jdbcProvider.username=sa > jdbcProvider.password= > EOF [root@yfw system]# jar -tf /opt/openfire/lib/xmppserver-5.0.2.jar | grep HSQLDBConnectionProvider [root@yfw system]# # 清空旧数据(防止冲突) [root@yfw system]# sudo rm -f /opt/openfire/embedded-db/* [root@yfw system]# [root@yfw system]# # 确保权限 [root@yfw system]# sudo chown -R openfire:openfire /opt/openfire/embedded-db [root@yfw system]# pkill -f openfire [root@yfw system]# /opt/openfire/bin/start.sh Using Java: /usr/lib/jvm/java-17-openjdk/bin/java Java Version: openjdk version "17.0.1" 2021-10-19 LTS OpenJDK Runtime Environment 21.9 (build 17.0.1+12-LTS) OpenJDK 64-Bit Server VM 21.9 (build 17.0.1+12-LTS, mixed mode, sharing) Classpath: /opt/openfire/lib/activation-1.1.jar:/opt/openfire/lib/apache-el-9.0.107.jar:/opt/openfire/lib/apache-jsp-9.0.107.jar:/opt/openfire/lib/asm-9.8.jar:/opt/openfire/lib/asm-commons-9.8.jar:/opt/openfire/lib/asm-tree-9.8.jar:/opt/openfire/lib/bcpg-jdk18on-1.78.1.jar:/opt/openfire/lib/bcpkix-jdk18on-1.78.1.jar:/opt/openfire/lib/bcprov-jdk18on-1.78.1.jar:/opt/openfire/lib/bcutil-jdk18on-1.78.1.jar:/opt/openfire/lib/caffeine-3.2.0.jar:/opt/openfire/lib/checker-qual-3.33.0.jar:/opt/openfire/lib/common-image-3.9.4.jar:/opt/openfire/lib/common-io-3.9.4.jar:/opt/openfire/lib/common-lang-3.9.4.jar:/opt/openfire/lib/commons-codec-1.15.jar:/opt/openfire/lib/commons-dbcp2-2.9.0.jar:/opt/openfire/lib/commons-ip-math-1.32.jar:/opt/openfire/lib/commons-lang3-3.18.0.jar:/opt/openfire/lib/commons-logging-1.2.jar:/opt/openfire/lib/commons-pool2-2.9.0.jar:/opt/openfire/lib/commons-text-1.10.0.jar:/opt/openfire/lib/dom4j-2.1.4.jar:/opt/openfire/lib/dwr-3.0.2-RELEASE.jar:/opt/openfire/lib/ecj-3.33.0.jar:/opt/openfire/lib/error_prone_annotations-2.18.0.jar:/opt/openfire/lib/failureaccess-1.0.1.jar:/opt/openfire/lib/guava-32.0.1-jre.jar:/opt/openfire/lib/hsqldb-2.7.1.jar:/opt/openfire/lib/httpclient-4.5.13.jar:/opt/openfire/lib/httpcore-4.4.13.jar:/opt/openfire/lib/i18n-5.0.2.jar:/opt/openfire/lib/imageio-bmp-3.9.4.jar:/opt/openfire/lib/imageio-core-3.9.4.jar:/opt/openfire/lib/istack-commons-runtime-3.0.11.jar:/opt/openfire/lib/j2objc-annotations-2.8.jar:/opt/openfire/lib/jakarta.activation-1.2.2.jar:/opt/openfire/lib/jakarta.annotation-api-1.3.5.jar:/opt/openfire/lib/jakarta.transaction-api-1.3.3.jar:/opt/openfire/lib/jakarta.xml.bind-api-2.3.3.jar:/opt/openfire/lib/jansi-1.18.jar:/opt/openfire/lib/javax.activation-api-1.2.0.jar:/opt/openfire/lib/javax.mail-1.6.2.jar:/opt/openfire/lib/jaxb-api-2.3.1.jar:/opt/openfire/lib/jaxb-runtime-2.3.3.jar:/opt/openfire/lib/jaxen-1.2.0.jar:/opt/openfire/lib/jcip-annotations-1.0.jar:/opt/openfire/lib/jcl-over-slf4j-2.0.9.jar:/opt/openfire/lib/jetty-ee-12.0.24.jar:/opt/openfire/lib/jetty-ee8-annotations-12.0.24.jar:/opt/openfire/lib/jetty-ee8-apache-jsp-12.0.24.jar:/opt/openfire/lib/jetty-ee8-nested-12.0.24.jar:/opt/openfire/lib/jetty-ee8-plus-12.0.24.jar:/opt/openfire/lib/jetty-ee8-security-12.0.24.jar:/opt/openfire/lib/jetty-ee8-servlet-12.0.24.jar:/opt/openfire/lib/jetty-ee8-webapp-12.0.24.jar:/opt/openfire/lib/jetty-ee8-websocket-jetty-api-12.0.24.jar:/opt/openfire/lib/jetty-ee8-websocket-jetty-common-12.0.24.jar:/opt/openfire/lib/jetty-ee8-websocket-jetty-server-12.0.24.jar:/opt/openfire/lib/jetty-ee8-websocket-servlet-12.0.24.jar:/opt/openfire/lib/jetty-http-12.0.24.jar:/opt/openfire/lib/jetty-io-12.0.24.jar:/opt/openfire/lib/jetty-jmx-12.0.24.jar:/opt/openfire/lib/jetty-jndi-12.0.24.jar:/opt/openfire/lib/jetty-plus-12.0.24.jar:/opt/openfire/lib/jetty-security-12.0.24.jar:/opt/openfire/lib/jetty-server-12.0.24.jar:/opt/openfire/lib/jetty-servlet-api-4.0.6.jar:/opt/openfire/lib/jetty-session-12.0.24.jar:/opt/openfire/lib/jetty-util-12.0.24.jar:/opt/openfire/lib/jetty-websocket-core-common-12.0.24.jar:/opt/openfire/lib/jetty-websocket-core-server-12.0.24.jar:/opt/openfire/lib/jetty-xml-12.0.24.jar:/opt/openfire/lib/jmdns-1.0.jar:/opt/openfire/lib/jsmpp-2.3.10.jar:/opt/openfire/lib/json-20231013.jar:/opt/openfire/lib/jspecify-1.0.0.jar:/opt/openfire/lib/jsr305-3.0.2.jar:/opt/openfire/lib/jtds-1.3.1.jar:/opt/openfire/lib/jzlib-1.1.3.jar:/opt/openfire/lib/libidn-1.35.jar:/opt/openfire/lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/opt/openfire/lib/log4j-api-2.20.0.jar:/opt/openfire/lib/log4j-core-2.20.0.jar:/opt/openfire/lib/log4j-slf4j2-impl-2.20.0.jar:/opt/openfire/lib/mssql-jdbc-9.4.1.jre11.jar:/opt/openfire/lib/mysql-connector-j-8.2.0.jar:/opt/openfire/lib/netty-all-4.1.118.Final.jar:/opt/openfire/lib/netty-buffer-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-dns-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-haproxy-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-http2-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-http-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-memcache-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-mqtt-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-redis-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-smtp-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-socks-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-stomp-4.1.118.Final.jar:/opt/openfire/lib/netty-codec-xml-4.1.118.Final.jar:/opt/openfire/lib/netty-common-4.1.118.Final.jar:/opt/openfire/lib/netty-handler-4.1.118.Final.jar:/opt/openfire/lib/netty-handler-proxy-4.1.118.Final.jar:/opt/openfire/lib/netty-handler-ssl-ocsp-4.1.118.Final.jar:/opt/openfire/lib/netty-resolver-4.1.118.Final.jar:/opt/openfire/lib/netty-resolver-dns-4.1.118.Final.jar:/opt/openfire/lib/netty-resolver-dns-classes-macos-4.1.118.Final.jar:/opt/openfire/lib/netty-resolver-dns-native-macos-4.1.118.Final-osx-aarch_64.jar:/opt/openfire/lib/netty-resolver-dns-native-macos-4.1.118.Final-osx-x86_64.jar:/opt/openfire/lib/netty-transport-4.1.118.Final.jar:/opt/openfire/lib/netty-transport-classes-epoll-4.1.118.Final.jar:/opt/openfire/lib/netty-transport-classes-kqueue-4.1.118.Final.jar:/opt/openfire/lib/netty-transport-native-epoll-4.1.118.Final-linux-aarch_64.jar:/opt/openfire/lib/netty-transport-native-epoll-4.1.118.Final-linux-riscv64.jar:/opt/openfire/lib/netty-transport-native-epoll-4.1.118.Final-linux-x86_64.jar:/opt/openfire/lib/netty-transport-native-kqueue-4.1.118.Final-osx-aarch_64.jar:/opt/openfire/lib/netty-transport-native-kqueue-4.1.118.Final-osx-x86_64.jar:/opt/openfire/lib/netty-transport-native-unix-common-4.1.118.Final.jar:/opt/openfire/lib/netty-transport-rxtx-4.1.118.Final.jar:/opt/openfire/lib/netty-transport-sctp-4.1.118.Final.jar:/opt/openfire/lib/netty-transport-udt-4.1.118.Final.jar:/opt/openfire/lib/ojdbc11-23.7.0.25.01.jar:/opt/openfire/lib/ons-23.7.0.25.01.jar:/opt/openfire/lib/oraclepki-23.7.0.25.01.jar:/opt/openfire/lib/orai18n-23.7.0.25.01.jar:/opt/openfire/lib/postgresql-42.7.7.jar:/opt/openfire/lib/rsi-23.7.0.25.01.jar:/opt/openfire/lib/shaj-0.5.jar:/opt/openfire/lib/simplefan-23.7.0.25.01.jar:/opt/openfire/lib/sitemesh-2.5.0.jar:/opt/openfire/lib/slf4j-api-2.0.9.jar:/opt/openfire/lib/startup.jar:/opt/openfire/lib/taglibs-standard-impl-1.2.5.jar:/opt/openfire/lib/taglibs-standard-spec-1.2.5.jar:/opt/openfire/lib/tinder-2.1.0.jar:/opt/openfire/lib/txw2-2.3.3.jar:/opt/openfire/lib/ucp-23.7.0.25.01.jar:/opt/openfire/lib/xdb-23.7.0.25.01.jar:/opt/openfire/lib/xmppserver-5.0.2.jar:/opt/openfire/lib/xpp3-1.1.4c.0.jar Starting OpenFire... OpenFire started (PID 1111365) Check logs: tail -f /opt/openfire/logs/nohup.out [root@yfw system]# tail -f /opt/openfire/logs/nohup.out DEBUG: User = openfire DEBUG: Current dir = /opt/openfire DEBUG: OPENFIRE_HOME = /opt/openfire DEBUG: Java executable = /usr/lib/jvm/java-17-openjdk/bin/java openjdk version "17.0.1" 2021-10-19 LTS OpenJDK Runtime Environment 21.9 (build 17.0.1+12-LTS) OpenJDK 64-Bit Server VM 21.9 (build 17.0.1+12-LTS, mixed mode, sharing) DEBUG: Launching OpenFire... Database setup or configuration error: Please verify your database settings and check the logs/openfire.log file for detailed error messages. java.lang.IllegalArgumentException: java.sql.SQLException: ConnectionManager.getConnection() failed to obtain a connection after 11 attempts. The exception from the last attempt is as follows: java.sql.SQLException: Check JDBC properties; data source was not be initialised at org.jivesoftware.openfire.XMPPServer.verifyDataSource(XMPPServer.java:1020) at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:666) at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:221) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) at java.base/java.lang.Class.newInstance(Class.java:645) at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:92) at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) Caused by: java.sql.SQLException: ConnectionManager.getConnection() failed to obtain a connection after 11 attempts. The exception from the last attempt is as follows: java.sql.SQLException: Check JDBC properties; data source was not be initialised at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager.java:204) at org.jivesoftware.openfire.XMPPServer.verifyDataSource(XMPPServer.java:1010) ... 11 more Error starting the server. Please check the log files for more information. 需要配置 openfire 数据库吗
11-16
[root@yfw ~]# cd /opt/openfire [root@yfw openfire]# sudo systemctl stop openfire [root@yfw openfire]# rm -rf /opt/openfire/embedded-db [root@yfw openfire]# sudo chown -R openfire:openfire /opt/openfire/conf [root@yfw openfire]# sudo chown -R openfire:openfire /opt/openfire/logs [root@yfw openfire]# sudo chown -R openfire:openfire /opt/openfire/plugins [root@yfw openfire]# sudo chown -R openfire:openfire /opt/openfire/lib [root@yfw openfire]# sudo chown -R openfire:openfire /opt/openfire/conf [root@yfw openfire]# sudo chown -R openfire:openfire /opt/openfire/logs [root@yfw openfire]# sudo chown -R openfire:openfire /opt/openfire/plugins [root@yfw openfire]# sudo chown -R openfire:openfire /opt/openfire/lib [root@yfw openfire]# ls -l /opt/openfire/conf/openfire.xml -rw-r--r-- 1 openfire openfire 874 Nov 15 16:25 /opt/openfire/conf/openfire.xml [root@yfw openfire]# rm -f /opt/openfire/logs/openfire.pid [root@yfw openfire]# sudo systemctl start openfire [root@yfw openfire]# tail -f /opt/openfire/logs/nohup.out at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown Source) ~[derby-10.14.2.0.jar:?] at org.apache.derby.impl.jdbc.EmbedPreparedStatement42.<init>(Unknown Source) ~[derby-10.14.2.0.jar:?] at org.apache.derby.jdbc.Driver42.newEmbedPreparedStatement(Unknown Source) ~[derby-10.14.2.0.jar:?] at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source) ~[derby-10.14.2.0.jar:?] at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source) ~[derby-10.14.2.0.jar:?] at org.apache.commons.dbcp2.DelegatingConnection.prepareStatement(DelegatingConnection.java:696) ~[commons-dbcp2-2.9.0.jar:2.9.0] at org.apache.commons.dbcp2.DelegatingConnection.prepareStatement(DelegatingConnection.java:696) ~[commons-dbcp2-2.9.0.jar:2.9.0] at org.jivesoftware.openfire.XMPPServer.verifyDataSource(XMPPServer.java:1011) ~[xmppserver-5.0.2.jar:5.0.2] ... 11 more 启动服务器时出错。有关详细信息,请查看日志文件。
11-16
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值