please I need help. I'm trying to package my maven build and also include environment variables but my program cannot find the .env file. How can I resolve this issue? I have been using eclipse, but I don't know where I can configure the path to the .env file. I used io.github.cdimascio to read environment variables. The program works fine on my IDE. The trouble starts when I run the program outside the IDE. What should I do?
Exception in thread "Thread-1" Exception in thread "Thread-0" java.lang.ExceptionInInitializerError
at com.arcalitegames.Main$2.run(Main.java:29)
at java.lang.Thread.run(Unknown Source)
Caused by: io.github.cdimascio.dotenv.DotEnvException: Could not find ./.env on the classpath
at io.github.cdimascio.dotenv.internal.ClasspathHelper.loadFileFromClasspath(ClassPathHelper.kt:37)
at io.github.cdimascio.dotenv.internal.DotenvReader.read(DotenvReader.kt:36)
at io.github.cdimascio.dotenv.internal.DotenvParser.parse(DotenvParser.kt:26)
at io.github.cdimascio.dotenv.DotenvBuilder.load(Dotenv.kt:119)
at com.arcalitegames.connector.Devs.getDotenv(Devs.java:10)
at com.arcalitegames.connector.Connector.<clinit>(Connector.java:14)
... 2 more
I had this same problem when I tried to deploy my program to Glassfish. You need to specify a location on the file system like ~ and place your .env file there.
Here is an example on how to do this:
Dotenv env = Dotenv.configure().directory(System.getProperty("user.home")).load();
Dotenv should now be able to find the file if you've placed it at ~/.env.
Related
I am trying to set up On Demand Server in my local machine and when ever I am deploying the application on tomcat server I am getting below error message on browser. I have updated the PATH variable also.
root cause
java.lang.UnsatisfiedLinkError: ars3wapi32 (Not found in java.library.path)
java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1007)
java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:971)
java.lang.System.loadLibrary(System.java:470)
com.ibm.edms.od.ArsWWWInterface.<clinit>(ArsWWWInterface.java:15)
java.lang.J9VMInternals.initializeImpl(Native Method)
java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
com.ibm.edms.od.ODServer.<init>(ODServer.java:45)
com.ibm.edms.od.ODServer.<init>(ODServer.java:61)
com.uklife.web.ondemand.utils.DownloadUtils.getAFPDocumentFromOnDemand(DownloadUtils.java:80)
com.uklife.web.ondemand.utils.Utils.getDocument(Utils.java:288)
com.uklife.web.ondemand.servlet.OnDemandDocAccess.doGet(OnDemandDocAccess.java:81)
javax.servlet.http.HttpServlet.s`enter code here`ervice(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722
)
Here is a guide the solution (for Windows and OnDemand V9.5).
First of all, you need to install ODWEK on the machine where you want to run your java app. Please install in the default folder, this whole thing is tricky enough as it is...
Set the environment variable "PATH" in Windows, add "C:\Program Files\IBM\OnDemand\V9.5\bin"
Set CLASSPATH in your development environment - point out the ODApi.jar file and ALSO point "Native library..." to the \bin folder above. (You can also call the program and setting the CLASSPATH in the call as a parameter: -Djava.library.path="C:\Program Files\IBM\OnDemand\V9.5\www\api\ODapi.jar"
Copy the file ars3wapi64.dll from C:\Program Files\IBM\V9.5\www to C:\Program Files\IBM\OnDemand\V9.5\bin
Ensure that all of these files are in the bin-catalog above:
**ars3wapi64.dll**
icudt53.dll
icuin53.dll
icuio53.dll
icule53.dll
iculx53.dll
icuuc53.dll
arsgsk64.dll
If you are getting the error "java.lang.UnsatisfiedLinkError: ars3wapi32 (Not found in java.library.path)" one of the above is most likely incorrect.
OR you could be using different versions of ODWEK and OnDemand.
More on how to set CLASSPATH in Eclipse: How to set the java.library.path from Eclipse
I'm trying to instrument jar file (from Spacewalk project) so I can measure code coverage of mine testing, but it is failing:
# /opt/cobertura-2.1.1/cobertura-instrument.sh --datafile /tmp/out /usr/share/rhn/lib/rhn.jar
Exception in thread "main" java.lang.NoClassDefFoundError: net.sourceforge.cobertura.instrument.InstrumentMain
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.instrument.InstrumentMain
at java.net.URLClassLoader.findClass(URLClassLoader.java:432)
at java.lang.ClassLoader.loadClass(ClassLoader.java:676)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:642)
Could not find the main class: net.sourceforge.cobertura.instrument.InstrumentMain. Program will exit.
I have tried to provide one random class (in the ideal state I want to instrument all of them) from that jar as well, but with same result:
# jar tf rhn.jar | tail
org/cobbler/CobblerConnection.class
[...]
# /opt/cobertura-2.1.1/cobertura-instrument.sh --datafile /tmp/out /usr/share/rhn/lib/rhn.jar org.cobbler.CobblerConnection
I'm pretty sure I'm just missing something what it is trying to tell me.
I'm using cobertura-2.1.1 downloaded from SourceForge and extracted into /opt, running on Red Hat Enterprise Linux 6.
OK, this was simple:
# dos2unix /opt/cobertura-2.1.1/cobertura-instrument.sh
also it is missing bash shebang (#!/bin/bash), so you might need to add it to the beginning of the file (I do not know why it worked for me even without that).
Attempting to build sikuli-slides-1.5.0 with the command "mvn clean install", I am getting the above referenced stack trace. I am using Windows 7 and have attempted the instructions I have come across for various solutions proposed on here to no avail. My Path and CLASSPATH variables for both user and system defined variables include:
"C:\opencv\build\x64\vc10\bin"
and I have restarted my machine multiple times.
In addition, I have added javacv.jar, javacv.windows-x86.jar, javacv.windows-x86_64.jar to my project's build path and have javacv-0.9.jar in my pom.xml. I have also included javacpp-0.9.jar in my pom as well. I can visually see all of the above referenced jars on my build path and can import the jniopencv_core into any of my classes. Any assistance would be greatly appreciated. While executing the JUnit test AutomationExecutorExceptionTest.java, the test fails and creates an orphaned java.exe process that must be manually shut down.
The full stack trace is listed below.
Exception in thread "Thread-60" java.lang.UnsatisfiedLinkError: no jniopencv_core in >java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:410)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.opencv_core.(opencv_core.java:10)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.create(openc
v_core.java:909)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom(o
pencv_core.java:999)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom(o
pencv_core.java:971)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom(o
pencv_core.java:968)
at org.sikuli.core.cv.ImagePreprocessor.createGrayscale(ImagePreprocesso
r.java:43)
at org.sikuli.core.search.TemplateMatcher.findMatchesByGrayscaleAtOrigin
alResolution(TemplateMatcher.java:71)
at org.sikuli.api.ImageTarget.getUnorderedMatches(ImageTarget.java:127)
at org.sikuli.api.DefaultTarget.doFindAll(DefaultTarget.java:128)
at org.sikuli.api.DefaultScreenRegion.findAll(DefaultScreenRegion.java:7
4)
at org.sikuli.slides.api.sikuli.CrossSearchStrategy.testHypotheses(Cross
SearchStrategy.java:85)
at org.sikuli.slides.api.sikuli.CrossSearchStrategy.perform(CrossSearchS
trategy.java:39)
at org.sikuli.slides.api.sikuli.ContextImageTarget.doFindAll(ContextImag
eTarget.java:122)
at org.sikuli.api.DefaultScreenRegion._find(DefaultScreenRegion.java:88)
at org.sikuli.api.DefaultScreenRegion.find(DefaultScreenRegion.java:80)
at org.sikuli.slides.api.actions.TargetAction.execute(TargetAction.java:
26)
at org.sikuli.slides.api.actions.RetryAction.execute(RetryAction.java:51
)
at org.sikuli.slides.api.actions.ParallelAction$Worker.run(ParallelActio
n.java:35)
at java.lang.Thread.run(Thread.java:745)
Your stack trace contains the following line:
Exception in thread "Thread-60" java.lang.UnsatisfiedLinkError: no jniopencv_cor e in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
Notice the space between jniopencv_cor and e?
One of your configuration files contain a space where it shouldn't.
The directions are highly confusing for the javacv files. The issue was that I had to actually explode the contents of the jar file and expose the DLLs in the directory. The instructions packaged with the jars of javacv instructed me to simply place the binaries on the classpath.
I had the same problem and I solved it by adding the following dependency in my Maven project for Sikuli Slides 1.5.1:
GroupId: org.bytedeco.javacpp-presets
AritfactId: opencv
Version: 2.4.9-0.9
Type: jar
Classifier: windows-x86_64
In my case I was using Windows 7 64-bit. After adding this dependency I was able to successfully build Sikuli Slides.
I'm trying to embed zeroMQ in my app, I followed this guideline to install ZMQ, so till here everything works fine.
I have this line of code in my app:
ZMQ.Context m_context = ZMQ.context(1);
but above line of code raise below exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/libjzmq-812339378390536247.lib: libzmq.so.3: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1825)
at java.lang.Runtime.load0(Runtime.java:792)
at java.lang.System.load(System.java:1059)
at org.zeromq.EmbeddedLibraryTools.loadEmbeddedLibrary(EmbeddedLibraryTools.java:136)
at org.zeromq.EmbeddedLibraryTools.<clinit>(EmbeddedLibraryTools.java:22)
at org.zeromq.ZMQ.<clinit>(ZMQ.java:38)
at com.castaclip.verticals.Messenger.<init>(Messenger.java:125)
at com.castaclip.verticals.PushMessenger.<init>(PushMessenger.java:30)
at com.castaclip.verticals.pushserver.App.setup(App.java:60)
at com.castaclip.verticals.pushserver.App.main(App.java:41)
The error is exactly pointing to this line.
P.S: its a little bit difficult to fully explain this question.. if you have any question plz let me know. thanks.
If you've successfully built libzmq and jzmq in that order, I would run:
$ sudo ldconfig
to update the system library cache. Then I would check to see if LD_LIBRARY_PATH is defined like Raffian mentioned, or set your library path explicitly to something like:
$ java -Djava.library.path=/usr/lib:/usr/local/lib
Finally I tried to figure out the problem.
I was using zeromq-2.1.10 and this was part of the problem.
So I installed zeromq-3.2.3 from the source and problem resolved.
I encountered a mystifying instance of this message when I:
# java -Djava.library.path=/usr/hf/zmq/lib/ -cp '/usr/hf/lib/*:.' com.zmqtest.MA
Exception in thread "main"
java.lang.UnsatisfiedLinkError: /usr/hf/zmq/lib/libjzmq.so:
libzmq.so.3: cannot open shared object file: No such file or directory
which was fixed with a solution that makes no sense at all to me:
# LD_LIBRARY_PATH=/usr/hf/zmq/lib/ java -Djava.library.path=/usr/hf/zmq/lib/ -cp '/usr/hf/lib/*:.' com.zmqtest.MA
wierd.
I am coding a RMI program with 3 JAR:
RMIServer, contains server-side classes
RMIClient contains client-side classes
RMIResource contains server & client shared content (interfaces, custom exceptions)
To make separate JAR files, I created 3 projects in NetBeans, then I declared the shared Jar in the "Libraries/Build" section of the other 2 projects.
Everything just build-up fine, no error.
But when I try to launch the server through the command-line, which was simple before I had the idea to put the shared files in a distinct JAR, this is suddenly pain in the a**...
Here are a few examples of commands I tried:
Keeping the ClassPath pointing to the server resources, but using dual CodeBase
java -cp ~/NetBeansProjects/RMIServer/dist/RMIServer.jar -Djava.rmi.server.codebase="file:/home/myuser/netbeansprojects/rmiserver/dist/rmiserver.jar file:/home/myuser/netbeansprojects/rmiserver/dist/lib/rmiresource.jar" rmiserver.Shop
Result:
Network exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: rmiresource.BookingManager
...
Using dual ClassPath but keeping the CodeBase pointing to the server resources
java -cp "~/NetBeansProjects/RMIServer/dist/RMIServer.jar;~/NetBeansProjects/RMIServer/dist/lib/RMIResource.jar" -Djava.rmi.server.codebase=file:/home/myuser/netbeansprojects/rmiserver/dist/rmiserver.jar rmiserver.Shop
Result:
Exception in thread "main" java.lang.NoClassDefFoundError: rmiserver/Shop
Caused by: java.lang.ClassNotFoundException: rmiserver.Shop
...
Using dual ClassPath & dual CodeBase
java -cp "~/NetBeansProjects/RMIServer/dist/RMIServer.jar;~/NetBeansProjects/RMIServer/dist/lib/RMIResource.jar" -Djava.rmi.server.codebase="file:/home/myuser/netbeansprojects/rmiserver/dist/rmiserver.jar file:/home/myuser/netbeansprojects/rmiserver/dist/lib/rmiresource.jar" rmiserver.Shop
Result:
Exception in thread "main" java.lang.NoClassDefFoundError: rmiserver/Shop
Caused by: java.lang.ClassNotFoundException: rmiserver.Shop
...
EDIT:
I am working on the local computer, simulating distant connections. Thus I use 'file' protocol and not 'http'.
Am I missing something? Thanks for any help you would provide
I tested out again my 1st solution since it was the most promising:
java -cp ~/NetBeansProjects/RMIServer/dist/RMIServer.jar -Djava.rmi.server.codebase="file:/home/myuser/netbeansprojects/rmiserver/dist/rmiserver.jar file:/home/myuser/netbeansprojects/rmiserver/dist/lib/rmiresource.jar" rmiserver.Shop
It still failed.
Then I tested out on Windows:
Setup the rmiregistry with an empty classpath (and cd to the java/bin directory)
set CLASSPATH=""; export CLASSPATH
start rmiregistry
Launch the server with an equal command as before (moduo the Win env changes)
java -cp c:/NetBeansProjects/RMIServer/dist/RMIServer.jar -Djava.rmi.server.codebase="file:/c:/netbeansprojects/rmiserver/dist/rmiserver.jar file:/c:/netbeansprojects/rmiserver/dist/lib/rmiresource.jar" rmiserver.Shop
And... It worked!
I cleaned-up/rebuilt the solution both on Linux & Windows and it is still not working on Linux and working on Windows... I use the same Netbeans version on both!
Can someone explain that to me? I am using the JDK 6 on Linux & JDK 7 on Windows: would that have an impact?
A file: codebase can't work out of the local machine. You need to use HTTP. You could possibly use a file: URL pointing to a shared directory, such that the URL makes sense at a client, but this won't work outside the LAN.
Unless you are using the codebase feature, the RMI Registry needs access to the shared classes via its classpath: rmiregistry -J-Dclasspath=... It's simpler to use LocateRegistry.createRegistry(), then it's in the same JVM as your remote objects and uses the same classpath of course.