标签: filenotfoundexception

无法使用外部DLL:FileNotFoundException

我有2个项目.第一个只生成一个DLL.

第二个需要第一个DLL.但是当我从DLL调用一个方法时,我有一个FileNotFoundException,带有以下消息:

BDD,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null

我确定该文件存在.哪里我错了?

c# dll filenotfoundexception

2
推荐指数
1
解决办法
2326
查看次数

java.io.FileNotFoundException:无法打开类路径资源[timex-servlet.properties],因为它不存在

我尝试启动Spring Web应用程序时收到以下错误消息:

2012-04-12 13:53:20,491 ERROR [org.springframework.web.servlet.DispatcherServlet] - 

Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [timex-servlet.properties] cannot be opened because it does not exist
java.io.FileNotFoundException: class path resource [timex-servlet.properties] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:137)
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:172)
Run Code Online (Sandbox Code Playgroud)

我正在通过eclipse运行Tomcat(版本6.x).我尝试将timex-servlet.properties放在以下目录中,但无济于事:

WebContent\WEB-INF
WebContent\WEB-INF\classes
WebContent\
Run Code Online (Sandbox Code Playgroud)

以下是timex-servlet.xml中timex-servlet.properties的引用:

    <bean id="placeholderConfig"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location"
        value="timex-servlet.properties" />
</bean>
Run Code Online (Sandbox Code Playgroud)

有几个SO线程处理相同的消息,表示放置类路径:在属性文件引用前面.所以我尝试了以下,但也没有用:

        <bean id="placeholderConfig"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location"
        value="classpath:timex-servlet.properties" />
</bean>
Run Code Online (Sandbox Code Playgroud)

spring filenotfoundexception properties-file timex

2
推荐指数
1
解决办法
5万
查看次数

使用Java中的filewriter打开文件时出现java.io.FileNotFoundException

我想写一些文件,像这样:

FileWriter fw = new FileWriter("somefile.txt", true);
Run Code Online (Sandbox Code Playgroud)

它由单个进程启动时正常工作.像这样:

java -jar XXXXXXX.jar
Run Code Online (Sandbox Code Playgroud)

但是当由另一个进程调用它时,将抛出IOException.例:

java.io.FileNotFoundException: 'somefile.txt' (No such file or directory)
    at java.io.FileOutputStream.openAppend(Native Method)                      
    at java.io.FileOutputStream.<init>(FileOutputStream.java:192)              
    at java.io.FileOutputStream.<init>(FileOutputStream.java:116)             
    at java.io.FileWriter.<init>(FileWriter.java:61)                       
Run Code Online (Sandbox Code Playgroud)

java filenotfoundexception

2
推荐指数
1
解决办法
2万
查看次数

java.io.FileNotFoundException:〜/ play-2.1.1/framework/sbt/boot/update.log(没有这样的文件或目录)

我写了一个Puppet来在运行CentOS 6.2的虚拟机上安装Play 2.1.1.

Puppet执行了以下两个命令:

/usr/bin/wget http://downloads.typesafe.com/play/2.1.1/play-2.1.1.zip

/usr/bin/unzip play-2.1.1.zip
Run Code Online (Sandbox Code Playgroud)

当我play在包中运行命令时,它显示以下错误消息:

java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:209)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:160)
    at java.io.FileWriter.<init>(FileWriter.java:90)
    at xsbt.boot.Update.<init>(Checks.java:51)
    at xsbt.boot.Launch.update(Launch.scala:275)
    at xsbt.boot.Launch$$anonfun$jnaLoader$1.apply(Launch.scala:120)
    at scala.Option.getOrElse(Option.scala:108)
    at xsbt.boot.Launch.jnaLoader$2f324eef(Launch.scala:115)
    at xsbt.boot.Launch.<init>(Launch.scala:94)
    at xsbt.boot.Launcher$.apply(Launch.scala:290)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:31)
    at xsbt.boot.Boot$.main(Boot.scala:20)
    at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)
Run Code Online (Sandbox Code Playgroud)

我没有更改目录中的单行代码play-2.1.1.我搜索了错误消息,但没有找到任何有用的答案.任何人都可以指出问题是什么?

java filenotfoundexception sbt playframework playframework-2.0

2
推荐指数
1
解决办法
2828
查看次数

log4j:错误无法解析文件

我浪费了很多时间来解决这个问题.但不能.可能很简单.

应用程序的jar文件无法加载log4j.xml文件,该文件是log4j的配置文件.
这是我正在使用的代码

import org.apache.log4j.xml.DOMConfigurator;
public class LoggerConfig {
    public void configLogger()
    {
        DOMConfigurator.configure("log4j.xml");
    }
}
Run Code Online (Sandbox Code Playgroud)

它是一个maven项目.我的目标结构是:

src
  main
    java
    |  com
    |  |  my
    |  |  |  abc
    |  |  |  |  test
    |  |  |  |  |  LoggerConfig.java
    resource
    |   com
    |   |  my 
    |   |  |  abc
    |   |  |  |  test
    |   |  |  |  |  log4j.xml
Run Code Online (Sandbox Code Playgroud)

我的classpath文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="target/classes" path="src/main/java"/>
    <classpathentry kind="src" output="target/classes" path="src/main/resources"/>  
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> …
Run Code Online (Sandbox Code Playgroud)

java log4j filenotfoundexception maven

2
推荐指数
1
解决办法
2万
查看次数

Clojure:战争编译失败,缺少数据文件依赖性

我正在开发一个依赖于某个数据文件的webapp,它在运行时会被混淆.没有数据文件,我似乎无法编译.为什么是这样?

这是我的core.clj

(def my-data (slurp "my-file.txt"))
Run Code Online (Sandbox Code Playgroud)

然后当我尝试编译时:

$ lein ring war
Run Code Online (Sandbox Code Playgroud)

我得到了这个例外

Exception in thread "main" java.io.FileNotFoundException: my-file.txt (No such file or directory), compiling:(core.clj:24:28)
Run Code Online (Sandbox Code Playgroud)

我该怎么编译我的战争?我不需要在编译时篡改文件甚至检查是否存在.提前致谢!

[UPDATE]

这不是特定于war文件打包或响铃,例如:

(ns slurp-test.core
    (:gen-class))

(def x (slurp "/tmp/foo.txt"))

(defn -main [& args]
    (println x))
Run Code Online (Sandbox Code Playgroud)

然后:

 $ lein uberjar
 Compiling slurp-test.core
 (ns slurp-test.core
 Exception in thread "main" java.io.FileNotFoundException: /tmp/foo.txt (No such file or directory), compiling:(core.clj:4:8)
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

slurp clojure filenotfoundexception leiningen

2
推荐指数
1
解决办法
384
查看次数

未找到 Python 文件错误

我有一个文件夹,里面有不同的子文件夹。我必须遍历所有文件并检查 John 和 Jose 的出现并分别替换为 Mikel 和 Mourinho。

这是我用 Python 编写的脚本。它工作正常但是当我遇到一个.gif文件时它给了我一个错误并且它没有进一步迭代。

你能告诉我为什么吗?

错误是

Traceback (most recent call last):
  File "C:\Users\sid\Desktop\script.py", line 33, in <module>
    os.chmod(path ,stat.S_IWRITE)
FileNotFoundError: [WinError 2] The system cannot find the file specified:'C:\Users\sid\Desktop\test\\images/ds_dataobject.gif.bak'
Run Code Online (Sandbox Code Playgroud)

我的代码:

import os,stat
import fileinput
import sys

rootdir ='C:\Users\spemmara\Desktop\test'
searchTerms={"John":"Mikel", "Jose":"Mourinho"}

def replaceAll(file,searchExp,replaceExp):
    for line in fileinput.input(file, inplace=1):
        if searchExp in line:
            line = line.replace(searchExp,replaceExp)
        sys.stdout.write(line)

for subdir, dirs, files in os.walk(rootdir):
    for file in files:
        path=subdir+'/'+file
        print(path)
        os.chmod(path ,stat.S_IWRITE)
        for key,value …
Run Code Online (Sandbox Code Playgroud)

python filenotfoundexception

2
推荐指数
1
解决办法
8965
查看次数

从android资产打开wav文件时出现FileNotFoundException

在我们的Android应用程序中,我们打开位于assets/config/notification.wav中的wav文件.要打开并播放声音,我们使用以下代码:

String soundClipPath = "config/notification.wav"
AssetFileDescriptor afd = mContext.getAssets().openFd(soundClipPath);
int soundID = mSoundPool.load(afd, 1);
Run Code Online (Sandbox Code Playgroud)

这已经解决了大约一年的任何问题.突然间,这已停止工作了.我们还没有更新构建之间的任何依赖关系.我能找到的唯一区别是,构建工作是从去年开始.如果我们在netbeans中本地构建apk,但是当我们使用hudson构建apk时它不起作用.我试过以下没有运气:

  • 将wav文件放在res/raw文件夹中
  • 添加-0到maven android插件
  • 验证了文件结构,文件在那里工作.

使用上面的代码时,我们得到以下stacktrace:

java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
at android.content.res.AssetManager.openAssetFd(Native Method)
at android.content.res.AssetManager.openFd(AssetManager.java:331)
...
Run Code Online (Sandbox Code Playgroud)

尝试从res/raw文件夹加载时,以下内容:

android.content.res.Resources$NotFoundException: File res/raw/notification.wav from drawable resource ID #0x7f040000
at android.content.res.Resources.openRawResourceFd(Resources.java:981)
at android.media.SoundPool.load(SoundPool.java:191)
...
Run Code Online (Sandbox Code Playgroud)

有人可以帮我们解决这个奇怪的问题....

最好的祝福,

亨里克

android filenotfoundexception android-assets android-maven-plugin

2
推荐指数
1
解决办法
1743
查看次数

java.io.FileNotFoundException,打开失败:ENOENT

出于某种原因,我在fileNotFoundException阅读时都得到了一个.值得注意的是Toast打印"File exists!".我使用BufferedReader底部来测试文件的内容是否正确.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_calendar, container, false);

    recipes = new ArrayMap<>();
    filename = "calendar_recipes.txt";

    bText= (EditText) v.findViewById(R.id.bEditText);
    lText= (EditText) v.findViewById(R.id.lEditText);
    dText= (EditText) v.findViewById(R.id.dEditText);

    cal = (CalendarView) v.findViewById(R.id.calendarView);
    date = cal.getDate();


    File file = getActivity().getFileStreamPath(filename);

    if(file.exists())
    {
        Toast.makeText(getActivity(), "File exists!", Toast.LENGTH_SHORT).show();
        try
        {
            FileInputStream fileInputStream = new FileInputStream(getActivity().getFilesDir()+filename);
            ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
            Map recipes = (Map)objectInputStream.readObject();
        }
        catch(ClassNotFoundException | IOException | ClassCastException e) {
            e.printStackTrace(); …
Run Code Online (Sandbox Code Playgroud)

java android filenotfoundexception

2
推荐指数
1
解决办法
2万
查看次数

尝试在Android中创建文件时出现FileNotFoundException

我正在尝试使用Jexcel API创建一个Excel文件,并使用手机上的应用程序对其进行写入。当我运行该应用程序时,它会抛出一个FileNotFoundException。我什至尝试根据另一个问题的答案来创建文本文件,但是会引发相同的错误。我已在清单中授予了适当的权限,但我似乎仍然无法查明问题所在。请帮忙。

这是我的代码

 public WritableWorkbook createWorkbook(String fileName){

    //Saving file in external storage
        File sdCard = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        File directory = new File(sdCard.getAbsolutePath() + "/bills");

        //create directory if not exist
        if(!directory.isDirectory()){
            directory.mkdirs();
        }

        //file path
        file= new File(directory, fileName);
        if (file.exists())
            Log.e(taf,"file created");
        else
        Log.e(taf,"file not created");

        WorkbookSettings wbSettings = new WorkbookSettings();
        wbSettings.setLocale(new Locale("en", "EN"));
        wbSettings.setUseTemporaryFileDuringWrite(true);
        WritableWorkbook workbook;
        workbook=null;

        try {
            workbook = Workbook.createWorkbook(file, wbSettings);
            Log.i(taf,"workbook created");
            //Excel sheet name. 0 represents first sheet
            WritableSheet sheet = workbook.createSheet("MyShoppingList", 0);

            try …
Run Code Online (Sandbox Code Playgroud)

file-io android filenotfoundexception

2
推荐指数
1
解决办法
1875
查看次数