org.dom4j.DocumentException: file:\E:\work-plugins\console\plugins\power7000.dcp

做osgi应用时,在插件业务中访问资源,报异常。

[color=red]Nested exception:
java.io.FileNotFoundException: file:\E:\work-plugins\console\plugins\power7000.dcp.protocol.gdwDriver_1.0.0.201701011807.jar\conf\driver.xml (文件名、目录名或卷标语法不正确。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at org.dom4j.io.SAXReader.read(SAXReader.java:243)
at power7000.dcp.protocol.gdwdriver.impl.helper.XmlHelper.buildDocument(XmlHelper.java:55)
at power7000.dcp.protocol.gdwdriver.impl.helper.XmlHelper.buildDecodeRule(XmlHelper.java:106)
at power7000.dcp.protocol.gdwdriver.impl.GdwDriverServiceImpl.decode(GdwDriverServiceImpl.java:35)
at power7000.dcp.framewrok.common.helper.BundleHelper.handleDecReference(BundleHelper.java:165)
at power7000.dcp.framewrok.common.helper.ByteHelper.handleDecode(ByteHelper.java:107)
at power7000.dcp.framewrok.tcp.codec.MessageDecoder.decode(MessageDecoder.java:52)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:227)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:140)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:74)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:138)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:320)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:127)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:485)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:452)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:346)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:794)
at java.lang.Thread.run(Thread.java:745)[/color]

解决方案如下:可行, :idea: :D
[color=blue]SAXReader reader = new SAXReader();
Enumeration<URL> e = Activator.context.getBundle().findEntries("/conf/", "driver.xml", true);
if(e != null) {
while(e.hasMoreElements()) {
URL url = e.nextElement();
if(url != null) {
InputStream in;
try {
in = url.openStream();
doc = reader.read(in);
break;
} catch (IOException | DocumentException e1) {
e1.printStackTrace();
}
}
}
}[/color]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值