Need some help.
We have a custom java agent written using javaassist that instruments Logger file from logback for info method. The agent works as standalone program from command line, when used with -javaagent option, while running target app/class. It also works if a sample maven project is created in Eclipse and executed by Providing run configuration having -javaagent in run configuration.
Premain is called - transformer is called - instruments the class file - prints the log as updated using instrumentation.
While pushing on PCF:
The agent in packaged into spring-boot app binary, under MyApp.jar\BOOT-INF\classes\ This is very Simple Hello Program with one controller
Issue is
Premain is called - transformer is called - instruments the class file, However does not print the log as updated using instrumentation.
Do we need any specific configuration to get this instrumented file back to PCF?
Appreciate your inputs/queries.
Here is manifest.yml
applications:
- name: KedarTestApp
memory: 2G
disk_quota: 1G
instances: 1
path: target/Hello-0.0.1-SNAPSHOT.jar
env:
SPRING_PROFILES_ACTIVE : "dev"
JAVA_OPTS: -javaagent:BOOT-INF/classes/Agent.jar
Dev Env:
JDK8, WIndows 10, cf version 6.26, cf cli
Posting in case anyone needs it for refrence :)
If the instrumentation library is not on the class path - PCF wont show error/warning,but also wont instrument your classes.
The instrumentation libraries will be part of your binary, but are not loaded when PCF starts the app with org.springframework.boot.loader.JarLauncher.
You will need to provide the path to instrumentation libraries as part of -cp argument on your manifest's command: option.
Related
I have the following problem after executing the Main class directly
ERROR : No enabled jetty modules found!
INFO : ${jetty.home} = /Users/zhangsan/git_repo/servlet-container/jetty.project
INFO : ${jetty.base} = /Users/zhangsan/git_repo/servlet-container/jetty.project
ERROR : Please create and/or configure a ${jetty.base} directory.
Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]
java -jar $JETTY_HOME/start.jar --help # for more information
I do not want to start with the start.jar file. What do I do
You can generate the full JVM command line used to start jetty with the dry-run command:
java -jar $JETTY_HOME/start.jar --dry-run
This will give you all the options and classpath that is required to run Jetty with your current configuration in your jetty-base directory.
With this you can enter the configuration into your intellij run configurations options for Main.java. But this is not recommended, if any configuration changes in the jetty-base then the JVM command line options required will change as well.
Perhaps you should look into running with remote JVM debug as described in https://github.com/eclipse/jetty.project/issues/8114, or even switching to using embedded Jetty.
I have a spring java project which is built on a CI system outside of google cloud. The final build command is gradle bootJar . I want to deploy the resulting jar to Google App Engine.
The suggested way to do so is just calling gcloud app deploy my.jar . Unfortunately, this approach doesn't work for me as the application needs more RAM than provided by the default instance type (F1 = 256MB). So I have to specify the instance type somehow.
My current approach is to create a custom app.yaml - and also a .gcloudignore to ensure that only the jar is uploaded. My app.yaml looks like this:
runtime: java11
instance_class: F2
entrypoint: java -noverify -jar my.jar
While the instance is working, the instance logs indicate that a build is tried in parallel (log excerpt):
Starting Step #5 - "builder"
Step #5 - "builder": Already have image (with digest): eu.gcr.io/gae-runtimes/buildpacks/java11/builder:java11_20200913_11_0_RC00
Step #5 - "builder": === Java - App Engine (google.java.appengine#0.9.0) ===
Step #5 - "builder": DEBUG: Using GOOGLE_RUNTIME: java11
Step #5 - "builder": DEBUG: Using config appengine.Config{Runtime:"java11", Entrypoint:appengine.Entrypoint{Type:"User", Command:"java -noverify -jar my.jar", WorkDir:""}, MainExecutable:""}
Step #5 - "builder": === Utils - Label Image (google.utils.label#0.0.1) ===
Finished Step #5 - "builder"
These build attempts do not happen when I specify the jar directly in gcloud app deploy, but as said this fails due to memory.
Ideally, I want to use my own app.yaml in order to specify other configuration options as well. But I don't want to have a build happening all the time.
So is there a way to either suppress these build attempts or, alternatively, pass additional configuration options which would usually be in an app.yaml to a gcloud app deploy my.jar call?
What you are trying to do is not possible, if you use a app.yaml to deploy your app a build will always be triggered and if you use gradle you will not be able to select the instance_class like the app.yaml allows you to do. So there is no optimal solution for your problem, However there is an alternative for this, which is to use App Engine Flex to deploy a container with your my.jar file.
You can check this link for how to create a docker file to run a .jar app. Also in this documentation you can see how you can deploy that docker containing your jar file to App Engine Flex, this configuration will also create an app.yaml file and in that app.yaml you can specify the infrastructure that you will need to run your app. As you can see in this second documentation, you could add the following block of configurations to the app.yaml to let App Engine Flex know how much infrastructure you need for your app's container:
resources:
cpu: 2
memory_gb: 2.3
disk_size_gb: 10
volumes:
- name: ramdisk1
volume_type: tmpfs
size_gb: 0.5
NOTE: Since you already have your app up and running in an instance of App Engine Standard I would say that the proposed alternative is not worth the effort if you can simply ignore the build logs.
Situation:
I have installed Jasper Reports Library (V6.5.1) on my local Linux server which generates PDF reports (Data is dumped in a temp Oracle DB table for the reporting engine).
It then serves this PDF back to the website from which I kick off the process.
Goal:
Install Jmeter to analyse performance / possible bottlenecks of "Jasper Reports Library" (aka Report Generation) on my local linux server (I cannot access this server via GUI, only shell).
I understand I have to connect my local Windows 10 machine (running same Jmeter 4.0) with this local server. On the server I have to start Jmeter 4.0 Server (via jmeter-server command) however I get an error and am stuck (have not found anything online or even people with the same goal unfortunately...)
Steps I have taken:
Download latest (4.0) bin from here
Extracted on local linux server in /opt/dlins/apache-jmeter-4.0bin
Trying to start server with /usr/lib/jvm/jdk1.8.0_102/bin/java jmeter-server (the default java version is 6 so through this I can run this app with java 8) - Instructions found here
-> Getting error: "Error: Could not find or load main class jmeter-server"
Any help regarding above or even any other tool you may use are appreciated (Maybe there is a preferable way to test performance for the above scenario)
There are 2 aspects related to your issue and screenshot:
1) Using java 8 instead of 6 - This can be done in several ways, depending on your needs and restrictions, such as the need to have Java 6 globally available for other applications and using 8 just to run JMeter, or just replacing 6 with 8 entirely. For the sake of brevity, I'll assume the first scenario, but there's documentation available for both and Dmitri T has partially explained it already.
Anyway, the same JMeter doc link you used, describes (just scroll down a few times) how to create a setenv.sh script in the bin directory and configure JAVA_HOME or JRE_HOME depending on your needs.
To set those variables permanently, you can place them in a file called setenv.sh in the bin directory. This file will be sourced when running JMeter by calling the jmeter script.
You seem to be wanting a JDK, so create the script and add inside JAVA_HOME=/usr/lib/jvm/jdk1.8.0_102, save and exit.
2) Running JMeter - To clarify a minor confusion, java MyCompiledClass instructs java to load and execute the "program" defined in MyCompiledClass, which is not what you want to do, because jmeter-server is a shell script. If you open it, you'll see that it calls the jmeter shell script which will do some configuration, end eventually call (in short) java -jar ApacheJMeter.jar with some arguments and options.
So, to run JMeter make sure your scripts are executable with chmod, and simply run from command line ./jmeter-server. From the same link:
Un*x script files; should work on most Linux/Unix systems:
jmeter - run JMeter (in GUI mode by default). Defines some JVM settings which may not work for all JVMs.
jmeter-server - start JMeter in server mode (calls jmeter script with appropriate parameters)
jmeter.sh - very basic JMeter script (You may need to adapt JVM options like memory settings).
mirror-server.sh - runs the JMeter Mirror Server in non-GUI mode
shutdown.sh - Run the Shutdown client to stop a non-GUI instance gracefully
stoptest.sh - Run the Shutdown client to stop a non-GUI instance abruptly
Amend your PATH environment variable so Java 8 bin would be before Java 6 bin like:
PATH=/usr/lib/jvm/jdk1.8.0_102/bin:$PATH && export PATH
Once done you should be able to just launch the jmeter-server script like
pushd /opt/dlins/apache-jmeter-4.0bin/bin && ./jmeter-server
More information:
Remote Testing
JMeter Distributed Testing Step-by-step
How to Get Started With JMeter: Part 1 - Installation & Test Plans
I am following this tutorial to setup hadoop on my windows 10. I successfully followed the tutorial till Page 5 and after putting everything I tried to check the hadoop version on the command line. But it returns the following error:
D:\hadoop-2.6.0\bin>hadoop version
Error: Could not find or load main class Azfar
Instead, if I use the following command it somehow works:
D:\hadoop-2.6.0\bin>hadoop
Usage: hadoop [--config confdir] COMMAND
where COMMAND is one of:
fs run a generic filesystem user client
version print the version
jar <jar> run a jar file
checknative [-a|-h] check native hadoop and compression libraries availability
distcp <srcurl> <desturl> copy file or directories recursively
archive -archiveName NAME -p <parent path> <src>* <dest> create a hadoop archive
classpath prints the class path needed to get the
Hadoop jar and the required libraries
credential interact with credential providers
key manage keys via the KeyProvider
daemonlog get/set the log level for each daemon
or
CLASSNAME run the class named CLASSNAME
Most commands print help when invoked w/o parameters.
I think it is doing this because my username "Azfar Faizan" contains a space, but I didn't use any path which includes my username folder during setting up. Can anybody guide me where exactly is the problem or I am doing it totally wrong ?
I want to measure the code coverage of integration tests using the JaCoCo and Sonar tools.
For that, I start my Tomcat 5.5 configured with the JaCoCo agent in order to get the dump file from JaCoCo.
Thus, I set the JAVA_OPTS for that:
set JAVA_OPTS=-Xrs -XX:MaxPermSize=256m -XX:PermSize=256m -XX:NewRatio=3 -Xms512m -Xmx1024m -XX:+UseParallelGC -javaagent:C:\dev\servers\jacoco-agent.jar=destfile=C:\dev\servers\jacoco.exec,append=true,includes=my.application.*
When I start Tomcat, the C:\dev\servers\jacoco.exec file is generated, but no data is filled.
Is there something I forgot in the configuration of my server?
Regards.
I realize this may not have been an option 2 years ago when this question was asked, but presently you have some other options available to fetch the JaCoCo execution data without shutting down Tomcat (or any JVM instrumented with the JaCoCo java agent).
First take a look at the current documentation for the JaCoCo Java Agent: http://www.eclemma.org/jacoco/trunk/doc/agent.html
You can use the output=tcpserver option on the JaCoCo agent to have the Java agent listen for commands. You can set address=* to have the tcpserver listen on all interfaces, and you can set the port=6300 argument to choose the port where the tcpserver should listen.
Through the tcpserver the JaCoCo java agent can be instructed to send you the data whenever you ask for it.
If your JVM is currently exposing JMX you have another option which you can utilize without opening additional ports. By setting the jmx=true option the JaCoCo java agent exposes an MBean which you can interact with.
If you are using maven you can take a look at the plugin I recently wrote in order to gather JaCoCo data from remote JVM's while running. The project for the plugin is located at:
https://github.com/mattcj/jacocotogo
As far as I remember - file would be populated during shutdown of Tomcat.
Besides the maven solution, you can also consider https://www.eclemma.org/jacoco/trunk/doc/cli.html
Basically, you start your service on the remote machine with the javaagent option like (you can change the port number and omit includes if you want to have coverage for all of the classes):
-javaagent:/tmp/jacocoagent.jar=port=36320,destfile=jacoco-it.exec,output=tcpserver,includes=a.b.c.d.*”
Then connect to the remote machine by providing remote host address or open a tunnel to the remote machine. The following example assumes I have set up a port forwarding between local host's 36320 and remote host's 36320
java -jar jacococli.jar dump --port 36320 --destfile /tmp/jacoco-it.exec
If you have multiple .exec files, you need to merge them:
java -jar jacococli.jar merge /tmp/jacoco-it-1.exec /tmp/jacoco-it-2.exec --destfile /tmp/merge
Then generate the html report (path1 can be a path to the jar file or the class files folder)
java -jar jacococli.jar report /tmp/jacoco-it.exec --classfiles path1 --sourcefiles path2 --html /tmp/report