aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp-ft/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-xmpp-ft/src/main/java')
-rw-r--r--juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java
index 4a85b046..05f2b465 100644
--- a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java
+++ b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java
@@ -16,6 +16,8 @@ import rocks.xmpp.extensions.filetransfer.FileTransferManager;
import rocks.xmpp.extensions.oob.model.x.OobX;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.*;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -30,7 +32,21 @@ public class XMPPFTServer {
private static final Logger logger = LoggerFactory.getLogger(XMPPFTServer.class);
public XMPPFTServer(Environment env) {
- URL.setURLStreamHandlerFactory(new JuickURLStreamHandlerFactory());
+ try {
+ Class tomcathfc = Class.forName("org.apache.catalina.webresources.TomcatURLStreamHandlerFactory");
+ if (tomcathfc != null) {
+ try {
+ Method m = tomcathfc.getMethod("getInstance");
+ Object tomcathfo = m.invoke(null);
+ m = tomcathfo.getClass().getMethod("addUserFactory", URLStreamHandlerFactory.class);
+ m.invoke(tomcathfo, new JuickURLStreamHandlerFactory());
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ logger.error("init error", e);
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ URL.setURLStreamHandlerFactory(new JuickURLStreamHandlerFactory());
+ }
ExternalComponent component = ExternalComponent.create(env.getProperty("component_name", "files"),
env.getProperty("component_password", "secret"), env.getProperty("component_host", "localhost"),
NumberUtils.toInt(env.getProperty("component_port", "5347"), 5347));