Hi I have created one docker-compose.yml file as bellow configuration
version: '3'
services:
activemq:
image: webcenter/activemq:latest
ports:
- 8161:8161
- 61616:61616
- 61613:61613
environment:
ACTIVEMQ_NAME: amq
ACTIVEMQ_REMOVE_DEFAULT_ACCOUNT: 'True'
ACTIVEMQ_ADMIN_LOGIN: admin
ACTIVEMQ_ADMIN_PASSWORD: admin
volumes:
- /container_data/activemq/data:/data/activemq
- /container_data/activemq/log:/var/log/activemq
I have gradle configuration as following:
task startDocker(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', 'docker-compose', '-f', './docker-compose.yml', 'up', '-d'
} else {
commandLine 'docker-compose', '-f', './docker-compose.yml', 'up', '-d'
}
}
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'com.jms.MyServer'
}
}
when i am running my java application independently it runs fine as
i am using configuration from following command:
docker container inspect <container-id>
but when i run jar file it's not able find classes of jms
following is an error i'm getting when i ran using jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: javax/jms/Destination
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
How could i run jar file and resolve this error ?
I'm guessing you have jms dependencies which are not packed inside your jar so it can't be run as a standalone.
If you want to pack your dependencies inside your jar you can use something like shadow or one-jar or its also not to difficult to hand roll your own solution.
Another option is to use the application plugin to create a zip or a tar containing
your jar
the dependency jars
a startup script
Related
I'm trying to run Spring MVC app using gretty plugin for Gradle (JVM version is 14)
To deploy app I use tomcatRun task (tomcat version is 8.5.49).
If i use some preview feature (e.g. java.lang.String#formatted method) I have to add enable-preview flag to compileJava task:
compileJava {
options.compilerArgs += '--enable-preview'
}
However, if build.gradle contains such changes, something goes wrong and the following message appears in logs:
INFO: No Spring WebApplicationInitializer types detected on classpath
As a result all app endpoints aren't available.
In case of using jettyRun task the following exception is thrown:
17:14:38 WARN Failed startup of context o.a.g.JettyWebAppContext#2715644a
java.lang.UnsupportedClassVersionError: Preview features are not enabled for com/config/ApplicationDispatcherServletInitializer (class file version 58.65535). Try running with '--enable-preview'
Is it possible to use preview features with gretty plugin?
Solved by adding --enable-preview to the list of JVM arguments in gretty configuration:
build.gradle
gretty {
jvmArgs = ['--enable-preview']
}
Checked on both Jetty(9.4.24.v20191120) and Tomcat(8.5.49)
I'm working on an open-source project called "Cloudnet-v3". I am using a symlink /data on my local machine to the data-point in my IntelliJProjects-Folder.
I got the following startup command:
[java, -XX:+UseG1GC, -XX:MaxGCPauseMillis=50, -XX:-UseAdaptiveSizePolicy, -XX:CompileThreshold=100, -XX:+UnlockExperimentalVMOptions, -XX:+UseCompressedOops, -Dcom.mojang.eula.agree=true, -Djline.terminal=jline.UnsupportedTerminal, -Dfile.encoding=UTF-8, -Dio.netty.noPreferDirect=true, -Dclient.encoding.override=UTF-8, -Dio.netty.maxDirectMemory=0, -Dio.netty.leakDetectionLevel=DISABLED, -Dio.netty.recycler.maxCapacity=0, -Dio.netty.recycler.maxCapacity.default=0, -DIReallyKnowWhatIAmDoingISwear=true, -Dcloudnet.wrapper.receivedMessages.language=english, -Xmx372M, -javaagent: "/data/temp/caches/wrapper.jar", -cp, "/data/launcher/libs/io/kubernetes/client-java/4.0.0/client-java-4.0.0.jar:/data/launcher/libs/io/netty/netty-codec-http/4.1.36.Final/netty-codec-http-4.1.36.Final.jar:/data/launcher/libs/io/netty/netty-handler/4.1.36.Final/netty-handler-4.1.36.Final.jar:/data/launcher/libs/io/netty/netty-transport-native-epoll/4.1.36.Final/netty-transport-native-epoll-4.1.36.Final-linux-x86_64.jar:/data/launcher/libs/io/netty/netty-transport-native-kqueue/4.1.36.Final/netty-transport-native-kqueue-4.1.36.Final-osx-x86_64.jar:/data/launcher/libs/io/kubernetes/client-java-api/4.0.0/client-java-api-4.0.0.jar:/data/launcher/libs/io/kubernetes/client-java-proto/4.0.0/client-java-proto-4.0.0.jar:/data/launcher/libs/org/yaml/snakeyaml/1.19/snakeyaml-1.19.jar:/data/launcher/libs/commons-codec/commons-codec/1.11/commons-codec-1.11.jar:/data/launcher/libs/org/apache/commons/commons-compress/1.18/commons-compress-1.18.jar:/data/launcher/libs/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar:/data/launcher/libs/com/squareup/okhttp/okhttp-ws/2.7.5/okhttp-ws-2.7.5.jar:/data/launcher/libs/com/google/guava/guava/25.1-jre/guava-25.1-jre.jar:/data/launcher/libs/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/data/launcher/libs/org/bouncycastle/bcprov-ext-jdk15on/1.59/bcprov-ext-jdk15on-1.59.jar:/data/launcher/libs/org/bouncycastle/bcpkix-jdk15on/1.59/bcpkix-jdk15on-1.59.jar:/data/launcher/libs/com/google/protobuf/protobuf-java/3.4.0/protobuf-java-3.4.0.jar:/data/launcher/libs/com/google/code/gson/gson/2.8.2/gson-2.8.2.jar:/data/launcher/libs/io/netty/netty-codec/4.1.36.Final/netty-codec-4.1.36.Final.jar:/data/launcher/libs/io/netty/netty-transport-native-unix-common/4.1.36.Final/netty-transport-native-unix-common-4.1.36.Final.jar:/data/launcher/libs/io/netty/netty-transport/4.1.36.Final/netty-transport-4.1.36.Final.jar:/data/launcher/libs/io/netty/netty-buffer/4.1.36.Final/netty-buffer-4.1.36.Final.jar:/data/launcher/libs/io/netty/netty-resolver/4.1.36.Final/netty-resolver-4.1.36.Final.jar:/data/launcher/libs/io/netty/netty-common/4.1.36.Final/netty-common-4.1.36.Final.jar:/data/launcher/libs/io/sundr/builder-annotations/0.9.2/builder-annotations-0.9.2.jar:/data/launcher/libs/io/swagger/swagger-annotations/1.5.12/swagger-annotations-1.5.12.jar:/data/launcher/libs/com/squareup/okhttp/logging-interceptor/2.7.5/logging-interceptor-2.7.5.jar:/data/launcher/libs/com/squareup/okhttp/okhttp/2.7.5/okhttp-2.7.5.jar:/data/launcher/libs/joda-time/joda-time/2.9.3/joda-time-2.9.3.jar:/data/launcher/libs/org/joda/joda-convert/1.2/joda-convert-1.2.jar:/data/launcher/libs/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/data/launcher/libs/org/checkerframework/checker-qual/2.0.0/checker-qual-2.0.0.jar:/data/launcher/libs/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar:/data/launcher/libs/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar:/data/launcher/libs/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar:/data/launcher/libs/org/bouncycastle/bcprov-jdk15on/1.59/bcprov-jdk15on-1.59.jar:/data/launcher/libs/io/sundr/sundr-core/0.9.2/sundr-core-0.9.2.jar:/data/launcher/libs/io/sundr/sundr-codegen/0.9.2/sundr-codegen-0.9.2.jar:/data/launcher/libs/io/sundr/resourcecify-annotations/0.9.2/resourcecify-annotations-0.9.2.jar:/data/launcher/libs/com/squareup/okio/okio/1.6.0/okio-1.6.0.jar:/data/launcher/versions/3.0.0-RELEASE-e48128a/driver.jar:/data/temp/caches/wrapper.jar", de.dytanic.cloudnet.wrapper.Main, nogui]
And my current workdir is: /data/temp/services/Lobby-1#4a517311-09e6-4f77-89a5-64b4bc15399a
So whenever I am in the workdir and execute the given command, it fails with the following error: Error opening zip file or JAR manifest missing :
Error occurred during initialization of VM
agent library failed to init: instrument Full Log
Now I am wondering because it's working in the automatic-environment but there are no changes to the master-Branch Source e.g. a changed Path to /data/launcher instead of launcher (System.getProperty("cloudnet.launcher.dir", "/data/launcher"))[https://github.com/CloudNetService/CloudNet-v3/blob/master/cloudnet-launcher/src/main/java/de/dytanic/cloudnet/launcher/Constants.java].
A short lookup: ls -laR /Users/.../Documents/IdeaProjects/cloudnet-parent/data
javaagent option is misused. Correct syntax is
-javaagent:/data/temp/caches/wrapper.jar
I am new to JAVA9 modular architecture and trying to compile and run module inside a JAR from windows command line.
I have created simple HelloWorld.java main class and project architecture is as below :
I was successfully able to compile and create JAR file using following command.
Compile :
javac -d target/HelloWorld src/HelloWorld/com/java/modularity/test1/HelloWorld.java src/HelloWorld/module-info.java
Create a HelloWorld.jar file in "jarfile" directory :
jar -cfe jarfile/HelloWorld.jar com.java.modularity.test1.HelloWorld target/HelloWorld/module-info.class target/HelloWorld/com/java/modularity/test1/HelloWorld.class
Getting following error while trying to run module from JAR file :
D:\sts_workspace\java9tutorial>java -p jarfile -m HelloWorld
module HelloWorld does not have a ModuleMainClass attribute, use -m <module>/<main-class>
Getting following error while slide change in command :
D:\sts_workspace\java9tutorial>java -p jarfile -m target/HelloWorld/com.java.modularity.test1.HelloWorld
Error occurred during initialization of boot layer
java.lang.module.FindException: Module target not found
Here is my entry class HelloWorld.java :
package com.java.modularity.test1;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Testing first HelloWorld module ...");
}
}
Here is HelloWorld module description :
module HelloWorld {
}
I also tried by extracting my generated HelloWorld.jar file and "Main-Class" attribute is also present in MANIFEST.MF file :
Manifest-Version: 1.0
Created-By: 1.8.0_172 (Oracle Corporation)
Main-Class: com.java.modularity.test1.HelloWorld
Do I need to export the entry class in my module definition ? Any suggestion will help me to fix the issue.
Try changing
-m target/HelloWorld/com.java.modularity.test1.HelloWorld
to
-m HelloWorld/com.java.modularity.test1.HelloWorld
for the syntax is module[/mainclass]
I am trying to run my java source code using a jar file which I have created in Ubuntu and I am facing an issue of my jar files not being detected. I have copied all my jar files in a subfolder and placed my sourcecode jar outside. I am trying to call main function from my main jar and I am able to do it successfully but somehow relative jars that are inside my relative subfolders are not detectable. I tried everything including creating or testing a manifest file but it did not work out. My code is running fine in eclipse IDE. Below is my shell script code -
LIB=./ChainLib/
echo "$LIB"
echo ls "$LIB"
CLASSPATH=./ChainLib/*.jar
export CLASSPATH=./ChainLib/*.jar
echo Classpath_is "$CLASSPATH"
#$(JARS=("$LIB"/*.jar); IFS=:;
#echo "${JARS[*]}")
jarnames=`ls ./ChainLib/*.jar`
for eachfile in $jarnames
do
echo $eachfile
done
#java -cp TestBlockchainkaranl.jar Testing
xvfb-run -a java -jar TestBlock.jar
When I run above script I get below:
bash RunBlockchain.sh
./ChainLib/
ls ./ChainLib/
Classpath_is ./ChainLib/*.jar
./ChainLib/bcpkix-jdk14-1.57.jar
./ChainLib/bcprov-jdk15on-1.59.jar
./ChainLib/commons-codec-1.11.jar
./ChainLib/commons-compress-1.5.jar
./ChainLib/fabric-sdk-java-1.2.1.jar
./ChainLib/httpclient-4.1.1.jar
./ChainLib/httpclient-4.5.6.jar
./ChainLib/httpcore-4.4.10.jar
./ChainLib/javax.json-1.1.jar
./ChainLib/netty-common-5.0.0.Alpha2.jar
./ChainLib/org-apache-commons-logging.jar
u1 Username
Y Filestatus
Exception in thread "main" java.lang.NoClassDefFoundError: org/hyperledger/fabric/sdk/User
at Testing.main(Testing.java:26)
Caused by: java.lang.ClassNotFoundException: org.hyperledger.fabric.sdk.User
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
How can I make sure this issue doesn't occur and my jars get detected successfully?
Update: I am adding the manifest file which I had created and zipped it in the jar file
Here is the manifest code:
Manifest-Version: 1.0
Main-Class: Testing
Class-Path:/home/ubuntu/KaranHyperledger/java/Blockchaintool/ChainLib/*.jar
Class-Path:/home/ubuntu/KaranHyperledger/java/Blockchaintool/TestBlock.jar
Java doesn't check CLASSPATH environment variable. You have to pass it explicitly.
java -cp TestBlockchainkaranl.jar:$CLASSPATH Testing
I have a Spring Boot application that has application.properties file in resource folder. That file also includes:
server.ssl.key-store=classpath:certificate.jks .
When running boxfuse on my local machine (boxfuse run myJar.jar) everything is ok (Payload started in 01:02.631s -> https://127.0.0.1:8448) but when I try to do boxfuse run -env=dev myJar:1.0 the application fails to start due to vb-1d056c6c => java.io.FileNotFoundException: /app/certificate.jks (No such file or directory) . I do not think this is a problem with my app, but with Boxfuse. What should I do?
The problem was that I already had an image with version 1.1 so Boxfuse created a new version number. I was not paying atenttion to the log so when I ran the deploy to AWS command, I was actually deploying the old version. Got to pay attention to logs