我正在尝试创建ActiveMQSslConnection
。我将信任库文件(.jks)作为分布式jar的一部分。但是,ActiveMQ无法读取文件并抛出FileNotFoundException
。我验证了jar文件,并看到了相应的文件,如下结构所示。
sample.jar
:
我以调试模式运行程序,看到ActiveMQ无法在jar中找到文件。我将文件路径更改为外部jar,并且可以读取文件。确切地说,它位于org.apache.activemq.ActiveMQSslConnectionFactory
中的下面位置。
protected InputStream getInputStream(String urlOrResource) throws IOException { try { File ifile = new File(urlOrResource); // only open the file if and only if it exists if (ifile.exists()) { // **This condition failed** return new FileInputStream(ifile); } } catch (Exception e) { } InputStream ins = null; try { URL url = new URL(urlOrResource); ins = url.openStream(); //**Throwing exception here. Obviously could not find the file in jar.** if (ins != null) { return ins; } } catch (MalformedURLException ignore) { } ... }
我想知道为什么ActiveMQ不使用
getClass().getResourceAsStream()
。我认为应该可行。
如何通过从罐子中读取.jks来解决此问题?
我正在尝试创建ActiveMQSslConnection。我将信任库文件(.jks)作为分布式jar的一部分。但是,ActiveMQ无法读取文件并抛出FileNotFoundException。我...
由于您使用的ActiveMQ 5.x版本显然不支持您要查找的行为,所以我认为此时“解决此问题”的唯一方法是修改ActiveMQ源代码并重建代理。