spring :cannot be resolved to absolute file path because it does not reside in the file system: jar

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/wljk506/article/details/98481884

class path resource [test-es-index.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/opt/app.jar!/BOOT-INF/classes!/test-es-index.txt

spring boot 打包后 jar文件,执行jar 后,内部程序访问 jar 中的 test-es-index.txt 报错。
打印各种日志发现,都存在,使用的是 resource.getFile(),一直报 上面错误。

换成文件流读取就没有问题了

ClassPathResource resource = new ClassPathResource("test-es-index.txt");
            if(!resource.exists()){
                log.info("test-es-index.txt 文件不存在");
            }else{
            String mapping = IOUtils.toString(inputStream,"utf-8");;
}

IOUtils 使用的是 apache 工具包

import org.apache.commons.io.IOUtils;
展开阅读全文

class path resource [spring/] cannot be resolved to URL because it does not

12-19

2011-12-19 8:09:30 org.apache.catalina.core.StandardContext listenerStartrn严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerrnorg.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition resource pattern [classpath:/spring/applicationContext*.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/] cannot be resolved to URL because it does not existrn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:190)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)rn at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)rn at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:516)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:566)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:585)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)rnCaused by: java.io.FileNotFoundException: class path resource [spring/] cannot be resolved to URL because it does not existrn at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:162)rn at org.springframework.core.io.support.PathMatchingResourcePatternResolver.isJarResource(PathMatchingResourcePatternResolver.java:406)rn at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:338)rn at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:276)rn at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1019)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:177)rn ... 24 morern 论坛

class path resource [log4j.xml] cannot be resolved to URL because it does not ex

08-03

log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.Bootstrap).rnlog4j:WARN Please initialize the log4j system properly.rnjava.io.FileNotFoundException: class path resource [log4j.xml] cannot be resolved to URL because it does not existrn at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:163)rn at org.springframework.core.io.ClassPathResource.getFile(ClassPathResource.java:175)rn at com.huawei.bme.commons.util.ResourceUtils.getResource(ResourceUtils.java:322)rn at com.huawei.bme.commons.util.debug.InitLog4j.init(InitLog4j.java:52)rn at com.huawei.bme.commons.util.debug.LogFactory.getDebugLog(LogFactory.java:28)rn at com.huawei.bme.system.listener.ActiveOperatorListener.(ActiveOperatorListener.java:58)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)rn at java.lang.reflect.Constructor.newInstance(Unknown Source)rn at java.lang.Class.newInstance0(Unknown Source)rn at java.lang.Class.newInstance(Unknown Source)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3713)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:927)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:890)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:448)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:552)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)rn===============================================================================rnStarting business container...rnrnjava.lang.NullPointerExceptionrn at com.huawei.bme.container.control.config.ConfigReader.getInitConfigData(ConfigReader.java:77)rn at com.huawei.bme.container.control.policy.AbstractFixturePolicy.(AbstractFixturePolicy.java:61)rn at com.huawei.bme.container.control.policy.SimpleFixturePolicy.(SimpleFixturePolicy.java:27)rn at com.huawei.bme.container.control.ContainerControl.(ContainerControl.java:38)rn at com.huawei.bme.container.control.ContainerContextLoaderListener.createController(ContainerContextLoaderListener.java:148)rn at com.huawei.bme.container.control.ContainerContextLoaderListener.contextInitialized(ContainerContextLoaderListener.java:74)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:927)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:890)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:448)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:552)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)rnClosing business container...rnrnrnrnclass path resource [log4j.xml] cannot be resolved to URL because it does not existrn类路径资源的log4j.xml]不能被解析到URL,因为它不存在!rnrnrn这个怎么解决!!!! 论坛

File not found: File does not exist: reduce.xml

03-24

用hive往elasticsearch中导数据出错(用的命令是INSERT OVERWRITE TABLE doc SELECT s.id,s.name FROM user_f s;)n错误代码如下n16/03/24 13:22:54 [main]: INFO exec.Utilities: File not found: File does not exist: /tmp/hive/hadoop/cf07a2cb-f401-440b-b230-3adb69d7ce9a/hive_2016-03-24_13-22-52_349_3866738858790764474-1/-mr-10001/4166b8bf-0706-4bda-9912-3cab4e82bcde/reduce.xmln at org.apache.hadoop.hdfs.server.namenode.INodeFile.valueOf(INodeFile.java:71)n at org.apache.hadoop.hdfs.server.namenode.INodeFile.valueOf(INodeFile.java:61)n at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getBlockLocationsInt(FSNamesystem.java:1828)n at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getBlockLocations(FSNamesystem.java:1799)n at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getBlockLocations(FSNamesystem.java:1712)n at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.getBlockLocations(NameNodeRpcServer.java:587)n at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.getBlockLocations(ClientNamenodeProtocolServerSideTranslatorPB.java:365)n at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)n at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:616)n at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:969)n at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2049)n at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2045)n at java.security.AccessController.doPrivileged(Native Method)n at javax.security.auth.Subject.doAs(Subject.java:415)n at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)n at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2043)nn16/03/24 13:22:54 [main]: INFO exec.Utilities: No plan file found: hdfs://ubuntu:9000/tmp/hive/hadoop/cf07a2cb-f401-440b-b230-3adb69d7ce9a/hive_2016-03-24_13-22-52_349_3866738858790764474-1/-mr-10001/4166b8bf-0706-4bda-9912-3cab4e82bcde/reduce.xmln 问答

A file descriptor does not refer to an open file

06-24

现在用java写了一个ftp下载程序,他总是时不时的报这个错rnrn很多时候都是没有问题,就是偶尔会报rnrn2008-06-24 12:34:22 INFO - Execute the task LJ_ctl_demoCopy.文件下载. rn2008-06-24 12:34:22 INFO - Start time for executing the task 文件下载: 2008-06-24 12:34:22 rn2008-06-24 12:34:22 INFO - Initialize the FTP connection client. rnrnjava.net.SocketException: A file descriptor does not refer to an open file.rn at java.net.PlainSocketImpl.socketAvailable(Native Method)rn at java.net.PlainSocketImpl.available(PlainSocketImpl.java:547)rn at java.net.SocketInputStream.available(SocketInputStream.java:246)rn at java.io.BufferedInputStream.available(BufferedInputStream.java:386)rn at org.apache.commons.net.io.FromNetASCIIInputStream.available(FromNetASCIIInputStream.java:196)rn at org.apache.commons.net.io.FromNetASCIIInputStream.read(FromNetASCIIInputStream.java:159)rn at java.io.BufferedInputStream.fill(BufferedInputStream.java:229)rn at java.io.BufferedInputStream.read(BufferedInputStream.java:246)rn at org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetInputStream.java:114)rn at org.apache.commons.net.telnet.TelnetInputStream.run(TelnetInputStream.java:535)rn ... 1 morern2008-06-24 12:34:24 INFO - Return status of the task 文件下载: Errorrnrn开始以为网络有问题,后来加上一个shell即ftp命令同时下载测试,发现下同一个文件的时候rnshell成功下载,但是java的ftp却还是报这个错rnrn难道shell的ftp命令和java 的ftp实现底层是不同的吗?rn因为对网络编程不熟悉,很想知道什么时候会报A file descriptor does not refer to an open filernTCP/IP大概也有套错误码来对应把rnrn我尝试将一个文件vi打开,然后用java程序的ftp来下,却还是成功的,rn实在不清楚什么时候会出现A file descriptor does not refer to an open filernrn大虾指教啊rn 论坛

没有更多推荐了,返回首页