archive for required library can not be read - java

I created my first maven project and I get Java build path problem in it.
Description Resource Path Location Type
Archive for required library: 'C:/Users/simran/.m2/repository/org/glassfish/extras/glassfish-embedded-web/3.1.1/glassfish-embedded-web-3.1.1.jar' in project 'RestfulMessenger' cannot be read or is not a valid ZIP file RestfulMessenger Build path Build Path Problem
This jar is present in the location mentioned, I tried deleteing it from there , cleaning the project and updating the maven but nothing fixed the error.
What seems wrong?

You should try doing
Maven -> Update Project and make sure you check Force Update of Snapshots/Releases

Deleting the corresponding .jar files from local repository and reissuing the maven command did the trick. It seems the .jar files got corrupted while downloading.

Related

How to access file in a JAR when running a Maven build

I want to run a liquibase update by the liquibase-maven-plugin, but the changeset yml file is inside a .jar that I pull in by dependency.
When I open the .jar with TotalCommander, it has the following structure:
xy.jar/changelog/changeset.yml.
I tried including it as a resource directory, but it failed telling me the .jar is not a directory.
I also tried building to a WAR and just setting the liquibase changeLogFile property to the path leading to the .jar, like {projectDir}/target/..war/..lib/..jar/changelog/myFile.yml
But maven could not find it this way.
Is it possible to access this file somehow?
You can read the file using below code.
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("changelog/myFile.yml");
Thanks for the reply, but the solution was simpler, I'm just rusty in this area :) I simply had to add the required JAR from the WAR as a Maven Dependency. This adds the JAR's content to the classpath in the Maven build process, so I can reference to it's files as they were on the project root path.
TLDR: add JAR as dependency in the pom and use the path:
<changeLogFile>changelog/xy.jar</changeLogFile>

Why this resource couldn't find error message appear?

I am opening a downloaded project in to my netbeans IDE. When I try to build this project following error message is appeared.
C:\Users\mymachine_name\Downloads\StoreKeeper-master\nbproject\jfx-impl.xml:1212:
Warning: Could not find resource file
"C:\Users\mymachine_name\Downloads\StoreKeeper-master\${libs.ControlsFx.classpath}"
to copy. BUILD FAILED (total time: 2 seconds)
I tried to resolve this by adding this missing controlfx jar file, But it didn't work
My project name - StoreKeeper-master
In the project folder there is a folder named library which contains all external jar files used in the project. Controlfx*.jar is also found in it. Include this jar file in your project library, then remove the ControlsFx library in the project.
the problem is netbean could not find some files to resolve it
go to properties >Library and remove the red files
watch this video https://www.youtube.com/watch?v=J4Oez0o_XUI

Ant Java Build Path set by Eclipse is Missing a Library at Compile Time

I'm using eclipse and ant to compile a java project. The ant compile script calls javac using a classpath refid of classpath, which is set based on System Property variable java.build.path.
My java.build.path variable is missing a library that was specified in
Project->Properties->Java Build Path->Libraries.
That is, the external jar was properly added to the list of libraries to add to the build path, is not missing or corrupt, and I have every expectation that eclipse would include the library in the build path. My build fails because java.build.path is missing this library.
Furthermore, the file <projectDir>/.classpath contains a valid classpathentry element for the missing jar file.
When building, javac fails at an import statement, claiming that the package does not exist. The value of java.build.classpath contains many of the libraries I set in the project properties, but does not include the missing library. Its as if the project property for that external jar was never set.
For what its worth, the missing library is jboss/lib/jbosssx.jar
Any help here would be appreciated.
At first,
Download jbosssx.jar jar file from this link
Then keep the jar file in the folder jboss/lib
Hope it will solve your issue.
UPDATE:
Sometimes jar files need to keep in lib folder physically. For this reason, you can put the jar file in your project lib folder.
I found where my configuration was messed up.
Using External Tools Configurations within eclipse, I found another Classpath settings tab for my ant build that did not contain my library.
Adding my library here caused the build to succeed!
Skywalker, thanks for the suggestion. :)

eclipse doesn't see java file generated during installation of maven module

I am working on a specific maven module. I have it imported into eclipse by m2eclipse plugin. The module uses our internal plugin to generate java files from some csv files. During install goal those files are being generated and put to target/generated-sources/folder_name.
Can you tell me how I can import these java files into eclipse so it stops showing me compilation errors saying that 'x' cannot be resolved to a type?
Now every module which uses those files has compilations errors in eclipse, everything works fine when I try to build from command line.
Thanks in advance.
UPDATE: Thanks a lot guys, I was trying similar solution but instead of adding source folder I was trying to add external classes :|
project -> properties -> java build path -> source -> add folder -> (search for target/generated-sources/folder_name, create it if deleted by maven) -> ok
now eclipse will only complain when you'll use mvn clean deleting target folder.
Eclipse refreshes file content on request, so any change made external to eclipse, eclipse doesn't know about that
You can make eclipse to use native hooks to detect external changes
preference > workspace > check refresh using native hooks
and add that directory to source path
You probably need to add the folder of the generated files as a Source folder in the project. Look in the Project Properties > Java Build Path > Source tab and add the folder.

Why a file always missing after build in Intellij with maven?

I have been stuck in the problem for quite a while.I use Intellij and maven not very long.
the problem like this:
the version of my Intellij is 12.1.4,I am making a project of Spring MVC with maven.So the output directory is 'target' in the project workspace.I have a mybatis xml file in my path.
once I found that the xml file did not change autoautomaticly in the target directory.so I delete it in the target directory.after I have done this,I rebuild the project,but the file never appear any more.
why?how should I do?
put that file in src/main/resources, maven copies all the resources from default resource directory to target/classes

Categories

Resources