Having Trouble Starting Jenkins: "Java.Io.Filenotfoundexception: /Usr/Share/Java/Jenkins/War/Meta-Inf/Manifest.Mf (No Such File or Directory)"

Jenkins service not starting anymore after system update

We fixed this by looking at systemctl parameters which were wrong. Restart jenkins after correcting that solved the problem

java.io.FileNotFoundException: the system cannot find the file specified

Put the word.txt directly as a child of the project root folder and a peer of src

Project_Root
src
word.txt

Disclaimer: I'd like to explain why this works for this particular case and why it may not work for others.

Why it works:

When you use File or any of the other FileXxx variants, you are looking for a file on the file system relative to the "working directory". The working directory, can be described as this:

When you run from the command line

C:\EclipseWorkspace\ProjectRoot\bin > java com.mypackage.Hangman1

the working directory is C:\EclipseWorkspace\ProjectRoot\bin. With your IDE (at least all the ones I've worked with), the working directory is the ProjectRoot. So when the file is in the ProjectRoot, then using just the file name as the relative path is valid, because it is at the root of the working directory.

Similarly, if this was your project structure ProjectRoot\src\word.txt, then the path "src/word.txt" would be valid.

Why it May not Work

For one, the working directory could always change. For instance, running the code from the command line like in the example above, the working directory is the bin. So in this case it will fail, as there is not bin\word.txt

Secondly, if you were to export this project into a jar, and the file was configured to be included in the jar, it would also fail, as the path will no longer be valid either.

That being said, you need to determine if the file is to be an embedded-resource (or just "resource" - terms which sometimes I'll use interchangeably). If so, then you will want to build the file into the classpath, and access it via an URL. First thing you would need to do (in this particular) case is make sure that the file get built into the classpath. With the file in the project root, you must configure the build to include the file. But if you put the file in the src or in some directory below, then the default build should put it into the class path.

You can access classpath resource in a number of ways. You can make use of the Class class, which has getResourceXxx method, from which you use to obtain classpath resources.

For example, if you changed your project structure to ProjectRoot\src\resources\word.txt, you could use this:

InputStream is = Hangman1.class.getResourceAsStream("/resources/word.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(is));

getResourceAsStream returns an InputStream, but obtains an URL under the hood. Alternatively, you could get an URL if that's what you need. getResource() will return an URL

For Maven users, where the directory structure is like src/main/resources, the contents of the resources folder is put at the root of the classpath. So if you have a file in there, then you would only use getResourceAsStream("/thefile.txt")

Why is Jenkins suddenly unable to delete a workspace

This page still gets a lot of attention, and this is probably the correct answer to my original question.

I had the same problem, found some files with permission root:root in
the workspace directory. Running "sudo chown -R jenkins:jenkins
/var/lib/jenkins/workspace" solved the problem.

Thanks to Olivier Boudry

java.io.FileNotFoundException: (Access is denied)

You cannot open and read a directory, use the isFile() and isDirectory() methods to distinguish between files and folders. You can get the contents of folders using the list() and listFiles() methods (for filenames and Files respectively) you can also specify a filter that selects a subset of files listed.

Issue in installing Jenkins when executing war file

Well, there's a few things that I'm seeing in your stack trace that seem very likely to cause a problem. notably these two:

Exception in thread "Jenkins initialization thread" java.lang.NoClassDefFoundError: hudson/util/HudsonFailedToLoad
Caused by: java.lang.ClassNotFoundException: hudson.util.HudsonFailedToLoad

and

java.io.IOException: Failed to start Jetty
Caused by: java.net.BindException: Address already in use: bind

Basically, there's two issues here, the first being that the port your Jenkins is trying to bind to is already in use, try and figure out what's using the port jetty would want to bind to (usually either 80 or 8080, if my memory serves).

The second is an issue saying it can't find a class for an exception it was trying to throw, I think.

I'm not sure how that'd happen, I'd free up the port and see if that issue goes away, and if not figure out why that class is missing from your classpath



Related Topics



Leave a reply



Submit