FileNotFoundException after packing in executable jar - plugins

After using maven shade plugin and running the executable jar, my application failed due to FileNotFoundException. During the application development I put my files in src/main/resources and so my path was defined like this "src/main/resources/maps/map.shp". Should I change all my paths in the code and how should I do that? Why does this happen?
Exception in thread "main" java.io.FileNotFoundException: C:\Users\ilija\Desktop
\MavenizedCP\cp-map\target\src\main\resources\maps\ParcelsCountyRDMFinal5.shp (T
he system cannot find the path specified)

Related

Spark Scala Unit test getting failed

I am getting this below error while running the test for maven. I have HADOOP_HOME, hadoop.dll file , everything is set up in my local machine and path , environmental variables for my machine. Previously it was running fine. While I had to clone a different repository I started getting this error. Can anyone help me with this.
org.apache.spark.sql.AnalysisException: java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.createDirectoryWithMode0(Ljava/lang/String;I)V;
at org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:108)
at org.apache.spark.sql.hive.HiveExternalCatalog.databaseExists(HiveExternalCatalog.scala:196)
at org.apache.spark.sql.internal.SharedState.externalCatalog$lzycompute(SharedState.scala:114)
at org.apache.spark.sql.internal.SharedState.externalCatalog(SharedState.scala:102)
at org.apache.spark.sql.hive.HiveSessionStateBuilder.externalCatalog(HiveSessionStateBuilder.scala:39)
at org.apache.spark.sql.hive.HiveSessionStateBuilder.catalog$lzycompute(HiveSessionStateBuilder.scala:54)
at org.apache.spark.sql.hive.HiveSessionStateBuilder.catalog(HiveSessionStateBuilder.scala:52)
at org.apache.spark.sql.hive.HiveSessionStateBuilder$$anon$1.<init>(HiveSessionStateBuilder.scala:69)
at org.apache.spark.sql.hive.HiveSessionStateBuilder.analyzer(HiveSessionStateBuilder.scala:69)
at org.apache.spark.sql.internal.BaseSessionStateBuilder$$anonfun$build$2.apply(BaseSessionStateBuilder.scala:293)
...
Cause: java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.createDirectoryWithMode0(Ljava/lang/String;I)V
at org.apache.hadoop.io.nativeio.NativeIO$Windows.createDirectoryWithMode0(Native Method)
at org.apache.hadoop.io.nativeio.NativeIO$Windows.createDirectoryWithMode(NativeIO.java:524)
at org.apache.hadoop.fs.RawLocalFileSystem.mkOneDirWithMode(RawLocalFileSystem.java:465)
at org.apache.hadoop.fs.RawLocalFileSystem.mkdirsWithOptionalPermission(RawLocalFileSystem.java:518)
at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:496)
at org.apache.hadoop.fs.FilterFileSystem.mkdirs(FilterFileSystem.java:316)
at org.apache.hadoop.hive.ql.session.SessionState.createPath(SessionState.java:694)
at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:613)
at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:547)
at org.apache.spark.sql.hive.client.HiveClientImpl.newState(HiveClientImpl.scala:180)
The problem is that you havenĀ“t set the library path. Try to set the java.library.path java property with the folder where the hadoop.dll is located. If you execute your tests with maven you can set the property of the forked jvm that executes the tests with the argLine option:
mvn -DargLine="-Djava.library.path=[hadoop_dll_dir_path]"

Asset folder not found when running jar

I'm trying to run a jar which accesses a save file from a predefined directory. It runs properly when running with IntelliJ, but When I run it with "java -jar", I get a NullPointerException pointing to the third line in the following snippet:
val dir = new File("./statFiles")
dir.listFiles
.filter(_.getName.takeRight(3) == "cmf")
.map(_.getName)
I get the same exception from IntelliJ if I remove the directory, so it's probably caused by the directory not being found. I'm assuming IntelliJ does something automatically that I should do manually, but I can't tell what the issue is.
edit: I've tried running the jar both from a folder that also houses the 'statFiles' folder as well as from the path in which IntelliJ creates the jar ({project root}/classes/artifacts/{name}_jar).
Stacktrace:
Exception in thread "main" java.lang.ExceptionInInitializerError
at cmsoft.ui.GUI.main(GUI.scala)
Caused by: java.lang.NullPointerException
at scala.collection.ArrayOps$.filter$extension(ArrayOps.scala:191)
at cmsoft.io.FileHandler$.findSavedStats(FileHandler.scala:24)
at cmsoft.io.FileHandler$.findSavedStat(FileHandler.scala:32)
at cmsoft.Control$.startup(Control.scala:30)
at cmsoft.ui.GUI$.<clinit>(GUI.scala:340)
... 1 more

Intellij class path setting when build a jar for maven project

when running the jar in command line, throw this exception:
java.lang.ClassNotFoundException
When building jar in intellij, we need set the manifest properties, like main class, class path, where could I find the right setting for this? it is not in the manifest file

RAD / WebSphere: NoClassDefFoundError

When I deploy my application to the integrated WebSphere server, I get NoClassDefFoundErrors for two classes that are contained in the same project.
Note: I call the missing class com.my.package.MyClass here.
The consuming project contains Session Beans and imports the exporting project in "Configure Build path". The exporting project is listed as "EAR library" if the consuming project in the Enterprise Explorer.
The exporting project is a normal java project that contains com.my.package.MyClass. It exports its source folders.
The exceptions look like that:
com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is com.ibm.ejs.container.ContainerEJBException: Unable to initialize deferred EJB.; nested exception is: java.lang.NoClassDefFoundError: com.my.package.MyClass]
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:1033)
at com.ibm.ws.naming.urlbase.UrlContextHelper.processBoundObjectForLookup(UrlContextHelper.java:175)
at com.ibm.ws.naming.urlbase.UrlContextImpl.processBoundObjectForLookup(UrlContextImpl.java:1736)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1249)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1225)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1276)
at javax.naming.InitialContext.lookup(Unknown Source)
...
or like that
[22.03.13 14:56:12:994 CET] 00000025 EJBContainerI E WSVR0068E: Attempt to start EnterpriseBean MyEar#MyJar.jar#MyBean failed with exception: java.lang.NoClassDefFoundError: com.my.package.MyClass
at java.lang.Class.getDeclaredMethodsImpl(Native Method)
at java.lang.Class.getDeclaredMethods(Class.java:673)
at com.ibm.ws.metadata.ejb.EJBMDOrchestrator.processTimeoutMetaData(EJBMDOrchestrator.java:6494)
at com.ibm.ws.metadata.ejb.EJBMDOrchestrator.finishBMDInit(EJBMDOrchestrator.java:1488)
at com.ibm.ws.runtime.component.EJBContainerImpl.finishDeferredBeanMetaData(EJBContainerImpl.java:5036)
at com.ibm.ws.runtime.component.EJBContainerImpl.initializeDeferredEJB(EJBContainerImpl.java:4845)
at com.ibm.ejs.container.HomeOfHomes$1.run(HomeOfHomes.java:406)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ejs.container.HomeOfHomes.getHome(HomeOfHomes.java:403)
at com.ibm.ejs.container.HomeOfHomes.getHome(HomeOfHomes.java:339)
at com.ibm.ejs.container.util.EJBLocalInterfaceObjectFactory.getObjectInstance(EJBLocalInterfaceObjectFactory.java:139)
at javax.naming.spi.NamingManager.getObjectInstanceByFactoryInReference(Unknown Source)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:927)
at com.ibm.ws.naming.urlbase.UrlContextHelper.processBoundObjectForLookup(UrlContextHelper.java:175)
at com.ibm.ws.naming.urlbase.UrlContextImpl.processBoundObjectForLookup(UrlContextImpl.java:1736)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1249)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1225)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1276)
at javax.naming.InitialContext.lookup(Unknown Source)
...
I'm using IBM Rational Application Developer for WebSphere in Version 8.0.4
and IBM WebSphere Application Server in Version 7.0.0.11
My workspace has no errors in the Problems view.
What I already tried:
- Starting RAD with the -clean parameter
- Refreshing all projects in the Enterprise Explorer
- Project > Clean
- In the Server view: stopping, restarted, cleaning, publishing
- Closing and restarting RAD
First I had a second problem: in RAD I wasn't able to find com.my.package.MyClass by Ctrl + Shift + T.
I solved it by deleting files (*.index files and the "savedIndexNames.txt") in
/.metadata/.plugins/org.eclipse.jdt.core.
But unfortunately that didn't solve the problem at runtime / deploy time. :-(
Can somebody give me hints?
Thanks in advance!
what you need to do is add the Java Project as a Deployment Assembly for the EAR project.
This will than automatically add the $PROJECT.jar from your Java Project under /lib/ folder for thie .ear
WebSphere automatically pics .jar files from lib folder and add them to the classpath and these .jar can be found by all EJB.jar and .war packaged inside the .ear file.
So, right click your EAR project, go to properties, and than selec "Deployment Assembly" than add your Java Project there, you should than see the generated jar under lib folder.

Eclipse VM Argument and external JAR file error

I just added "-Djava.library.path=" to the "VM Arguments" under Run Configuration in Eclipse and everything works fine until I tried to add an external JAR file. I get the following error:
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
Am I not setting something properly in Eclipse?
If your interested I forked RXTXserial a while back since thier update "schedule" sucks. I have just ported it over to the Android platform too. We decided to move the native libs into the jar and use reflection to deploy them. The API is the same as RXTX, but everything just works. You can find jars and full project sources at:
http://code.google.com/p/nrjavaserial/
The exception indicates that the class gnu.io.RXTXCommDriver tries to load a native library, which would be named rxtxSerial.dll on Windows and rxtxSerial.so on Linux, and the JVM cannot find it in the directories listed in java.library.path. Have you tried to add a JAR containing the library to java.library.path? I don't think that's possible, it has to be a directory containing the extracted library file.
Appearently that external library has a dependancy with another class gnu.io.RXTXCommDriver
. Perhaps you will need to add that library to class path.