Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find or load main class net.virtualvoid.perf.AttachOnce #17

Closed
stepancheg opened this issue Aug 21, 2015 · 22 comments
Closed

Comments

@stepancheg
Copy link

# ./bin/perf-java-top 19835
Error: Could not find or load main class net.virtualvoid.perf.AttachOnce

scripts expects attach-main.jar to be found in out dir, while it is in the project root dir.

@jrudolph
Copy link
Member

@stepancheg I recently changed the directory structure. Can you try to git clean the project and then run cmake . && make again? This should put build artifacts into out.

@stepancheg
Copy link
Author

I did build in clean checkout, it didn't help.

Problem must be in cmake. Seems like CMake 2.8 which I use doesn't understand OUTPUT_DIR option. I bet you have newer version?

@jrudolph
Copy link
Member

Not sure about that:

> cmake --version
cmake version 2.8.12.2

@jrudolph
Copy link
Member

I'm on Ubuntu 14.04.3 btw.

@jerrinot
Copy link

jerrinot commented Sep 1, 2015

I'm having the same problem with cmake version 2.8.11 on CentOS 7.0.1406

@jrudolph
Copy link
Member

jrudolph commented Sep 1, 2015

Is "the same problem", that attach-main.jar gets copied to the root directory of the project?

@jerrinot
Copy link

jerrinot commented Sep 1, 2015

indeed

@jrudolph
Copy link
Member

jrudolph commented Sep 1, 2015

Can you try if adding this line to CMakeLists.txt helps:

set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${OUTDIR})

@jerrinot
Copy link

jerrinot commented Sep 1, 2015

Yep, it seems it did the trick! Thanks!

[simulator@localhost perf-map-agent]$ git diff CMakeLists.txt 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8bcebbf..98e5832 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,7 @@ project (perf-map-agent)
 # Binaries (agent libperfmap.so and attach-main.jar) will end up in ./out
 set(OUTDIR ${PROJECT_BINARY_DIR}/out)
 set(LIBRARY_OUTPUT_PATH ${OUTDIR})
+set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${OUTDIR})

 find_package(JNI)
 if (JNI_FOUND)

@jrudolph
Copy link
Member

jrudolph commented Sep 1, 2015

Cool, thanks for verifying.

@jerrinot
Copy link

jerrinot commented Sep 1, 2015

no problem. Thanks for your work on this!

@donsi
Copy link

donsi commented May 31, 2017

FYI I got the same error
Error: Could not find or load main class net.virtualvoid.perf.AttachOnce

In my case it was due to the fact that the user that was being su'ed to (ie the user that owned the java process being attached to) did not have access to the directory where the software was installed.

@sattishv
Copy link

Hi Team,

Even i got the same error "Error: Could not find or load main class net.virtualvoid.perf.AttachOnce"
I could see the files attach-main.jar and libperfmap.so in out directory. but still it fails.
I am running the attach command
as user who owns the java process inside the docker container
java -cp attach-main.jar:$JAVA_HOME/lib/tools.jar net.virtualvoid.perf.AttachOnce 5063

Any help greatly appreciated.

Thanks
Sattish

@tekumara
Copy link

@sattishv see issue #50 for tips on running inside Docker.

@Liron24
Copy link

Liron24 commented Dec 12, 2018

@donsi I think I have the same issue. I have tomcat running my Java app and I get the error. How did you resolve your issue?

@donsi
Copy link

donsi commented Dec 13, 2018

@Liron24 my issue was that the user that the java process (eg tomcat) was running under did not have access to the directory where perf-map-agent was installed. Ensuring that the user had access fixed the problem for me.

@Liron24
Copy link

Liron24 commented Dec 20, 2018

@donsi thank you. Now I'm getting the following: Exception in thread "main" java.lang.UnsupportedClassVersionError: net/virtualvoid/perf/AttachOnce : Unsupported major.minor version 52.0
Did you come across such error?

@donsi
Copy link

donsi commented Dec 21, 2018

Sorry @Liron24 I don't recall getting that error.

@alex-dukhno
Copy link

Hi @Liron24,
Seems like you build perf-map-agent with Java 8 and run your tomcat application on Java prior this version. I suggest you check your java versions and align them. However, I don't remember required Java version for map-agent though. Hope it helps.

@Liron24
Copy link

Liron24 commented Dec 26, 2018

@alex-dukhno thank you for the response, do you know how can change the Java version for the perf-map-agent?

@alex-dukhno
Copy link

@Liron24 I haven't built perf-map-agent in a while, but I assume that you can change Java with JAVA_HOME as pointed in Readme file build section.
You need to install your's tomcat JDK version on your machine and change JAVA_HOME.
Or, if it is possible, check out git repo onto your's tomcat machine and build agent their.

@Liron24
Copy link

Liron24 commented Jan 1, 2019

@alex-dukhno Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants