I have images which are based on Alpine Linux with only JRE, and I'd like to be able to debug some through the host machine on Boot2Docker's Tiny Core Linux VM. Is this possible, or is there a better way, besides adding JDK right into the container? I'm having trouble finding out how to get Java working in this
There's no need to install Java in the boot2docker VM. You can attach a remote debugger running on your host directly to the JVM running in your docker container. You'll need to bind the container port to the boot2docker VM (for example: docker run -p 4000:4000 myimage:latest), then connect your debugger to the exposed port on the VM (e.g. 192.168.99.100:4000).
Related
I'm running Tomcat 9 (as user tomcat) with OpenJDK 11 on an Ubuntu 18.04 server. I'd like to be able to attach JProfiler 11 to the Tomcat process.
In the past, I've simply used the option to connect to a remote JVM via ssh, and JProfiler locates the process. On this machine, JProfiler never finds the Tomcat process.
I've tried using both the su and sudo options to switch to the tomcat user. I've even enabled login directly as tomcat. No matter what, JProfiler cannot locate the JVM process.
I think this is because the /tmp/hsperfdata_tomcat folder is empty. I've set -XX:+UsePerfData even though it should be enabled by default (trying both JAVA_OPTS and CATALINA_OPTS) but that didn't solve anything. I've checked the tomcat command line, there is nothing there to disable UsePerfData. I've also monitored the folder to see if somehow the hsperfdata gets populated but then deleted - the file is never created.
How do I enable profiling with Tomcat 9 on Ubuntu 18.04 with OpenJDK 11?
UPDATE:
Using jps -l -m running as tomcat returns no output. However running it as root does list the tomcat java process, despite no entry in /tmp/hsperfdata_tomcat.
I just ran into this exact issue. I was unable to see the JVM started under tomcat user: in jprofiler (11), switching to the tomcat user via sudo showed no JVMs.
It was a permission problem on the uploaded by jprofiler. jpenable is uploaded under my remote home directory to which tomcat has no access to.
Solution was to:
ssh to remove node (with same user as what jprofiler will use)
chmod 555 ${HOME}
chmod 555 -R ${HOME}/.jprofiler11. Tomcat user needs to access ${HOME}/.jprofiler11/agent/11082_11.0.2/jprofiler11/bin/jpenable and jar file in the same dir.
Test: sudo -u tomcat ${HOME}/.jprofiler11/agent/11082_11.0.2/jprofiler11/bin/jpenable
Then you'll be able to connect your laptop jprofiler to that tomcat user via remote ssh + sudo tomcat.
Background:
I am currently working in a Linux Virtual Machine on some Java plugins that I install into Eclipse by placing them into the /opt/eclipse/dropins folder. My plugins need to support both CentOS 6 and CentOS 7 VMs (shouldn't be a big deal since they are written in Java and both flavors of CentOS have Java 1.8.0 installed). My plugins build and install just fine on both OSs. I see them in Eclipse and can interact with them as expected.
The VMs I need to support can either be local to my machine (opened with VMWare Player/Workstation) or hosted on a cloud server. We use Windows Remote Desktop to get into the cloud VMs through xrdp on the Linux server.
Problem:
One of my plugins needs nddsjava.so from /opt/rti_connext_dds-5.2.3/lib/x64Linux3gcc4.8.2.
On both local VMs (CentOS 6 and 7), I can just set the LD_LIBRARY_PATH in an /etc/profile.d script so that any user that logs in can get the path to the required C++ library.
On CentOS 7 cloud VMs, however, when this plugin is invoked, I get java.lang.UnsatisfiedLinkError: no nddsjava in java.library.path. This happens only when opening Eclipse via the Linux menus. If I open a terminal and start Eclipse from there, the plugin can find the C++ library (because my LD_LIBRARY_PATH is set in my /bin/bash terminal). I did a little digging and found out that running chmod g-s /usr/bin/ssh-agent fixes the issue when opening Eclipse from the Linux menus (yes I understand that the chmod opens a security vulnerability. I am willing to look past this).
On CentOS 6 cloud VMs, I have never gotten the plugin to find the C++ library. LD_LIBRARY_PATH seems to get wiped when signing in through xrdp and for whatever reason, CentOS 6 appears to be explicitly not sourcing any of the profile scripts in the main top-level gnome-session process, which means other processes spawned from the GUI will not have LD_LIBRARY_PATH either.
I have also tried adding -Djava.library.path to my eclipse.ini file with no luck. It will fail on the next C++ library needed even though it lives in the same directory: java.lang.UnsatisfiedLinkError: /opt/rti_connext_dds-5.2.3/lib/x64Linux3gcc4.8.2/libnddsjava.so: libnddsc.so: cannot open shared object file: No such file or directory
Question:
Is there a single place that I can set my LD_LIBRARY_PATH for all flavors of Linux I am attempting to support (local CentOS 6, xrdp CentOS 6, local CentOS 7, and xrdp CentOS 7)?
Note: When I say cloud VM below, I mean server hosted VM in which I Windows-Remote-Desktopped into via xrdp.
This answer from server fault worked for me in the CentOS 6 cloud VM. The CentOS 7 cloud VM did not have the startwm.sh script in /etc/xrdp. Instead, it lived in /usr/libexec/xrdp and did not contain the xinitrc lines (referenced in the server fault link) causing the issue in the CentOS 6 cloud VM. Something else must be wiping the LD_LIBRARY_PATH variable in the CentOS 7 cloud VM, so I still needed to perform chmod g-s /usr/bin/ssh-agent to allow my /etc/profile.d script to be invoked on startup.
I just started to tryout docker to see if it helps setting up our development environment , which consists of
Jdk 1.6
Eclipse
RabbitVCS
Tomcat
MySQL server
Our Development desktops are mostly Ubuntu 16.04 . I would have eclipse, RabbitVCS installed on host and the rest in container .
If every thing goes well , developers should be able to download a Docker image . Running that image should give them JDK , Tomcat and MySQL server . Developers can then start using RabbitVCS to check out projects .
Is this feasible with Docker ?
tl;dr
It is not feasible to run eclipse in host OS and use JDK/JRE runs in a container because eclipse has a dependency on JRE. Similarly you cannot have tomcat in one container and JRE/JDK in another container because tomcat needs JRE to run.
Explanation
I would have eclipse, RabbitVCS installed on host and the rest in container....... Running that image should give them JDK , Tomcat and MySQL server
Are you trying to use JDK running on a docker container (and Eclipse IDE running on host os) for active development? If that is the case, it not not feasible (arguable, you can do remote debugging; but remember, debugging is very different than active development) . And it is not the intend of docker. While developing, your developers may need to have JDK installed in their host machine itself. In your case, only sensible thing to run from container is mysql as you don't have any active development there.
Edit: To build a portable development environment
In docker-land, one possible solution is, have eclipse+jdk+tomcat in the same docker image and mount the X11 socket into the container so that you can expose eclipse GUI running in the container to your host OS
More read here: https://blog.jessfraz.com/post/docker-containers-on-the-desktop/
Or just ditch Docker and go to full-blown VM like virtualbox, you might be able to find pre-built images with eclipse in it (not sure), or you can build one after installing all the required packages on a base image and share it amongst your developers.
Yes it's feasible.
I would recommend to use different containers for each service (Mysql/Tomcat/JDK). You could use docker-compose to connect the containers together and automate a lot of tasks. There are plenty of images already on dockerhub that you can use.
Here's an simple example of how you can setup your own docker-compose.yml file:
services:
tomcat_service:
#contains tomcat & jdk
image: tomcat
volumes:
- /local/path:/path/in/docker
links:
- mysql_service
depends_on:
- mysql_service
ports:
- "80:80"
# - other ports for debugging
mysql_service:
image: mysql
volumes:
#you should keep mysql data on the host, not in container
- /local/path/data:/var/lib/mysql
Each image used above will be downloaded automatically from dockerhub:
tomcat, java, mysql
EDIT: jdk and tomcat would be better together in the same container
I'm trying to set up JVisualVm to monitor a Tomcat 6 instance (running on Ubuntu Server 10.04 LTS). I've seen other questions, but none of them directly answer my problem. I try to connect to Tomcat with JVisualvm and it comes back with a "Cannot connect" error - but there are TCP connections being made to the server; the server drops the connection after a short burst of traffic.
I have already added this to /etc/default/tomcat6 and restarted tomcat6
# This enables JMX in order to permit VisualVM to profile the JVM.
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
I started rmiregistry using default settings:
rmiregistry &
I haven't started jstatd; installing it on the server requires the full JDK which requires X libraries. I'm not about to install X just to get one single binary.
I wonder if not running jstatd would have something to do with it; I was of the impression that I needed neither RMI nor jstatd, as long as I could use JMX directly via the JMX port.
There is no firewall in between the server and the JVisualvm client, and the iptables host firewall is open. Using jconsole results in the same error.
Running JVisualVM against the local Ubuntu 10.04 machine (by using its IP address and JMX port) and adding a JMX instance works fine - and I'm running neither rmiregistry nor jstatd - though the monitor shows RMI threads running.
Question: What must I do (either on the server or the client) in order to be able to monitor Tomcat (and other Java programs) via JMX with JVisualVM?
Thanks in advance.
If there is no firewall, try to set java.rmi.server.hostname system property for your Tomcat. Add this to your Tomcat's JAVA_OPTS:
-Djava.rmi.server.hostname=<IP address of Ubuntu Server>
You don't need to start rmiregistry and you don't need to run jstatd to be able to monitor your Tomcat remotely.
For the record: jstatd does not require X libraries, it only depends on them via some other recommended package. You can make aptitude or apt-get skip installation of recommended packages and have jstatd installed without any X11 libraries.
For aptitude, go into options ➞ preferences ➞ Install recommended packages automatically. For apt-get, see this question on askubuntu.
We have a Java process which we run as a Windows service (using srvany). It runs with Java 1.6 (1.6.0.23 at the moment).
In the past (Windows XP), I could connect JConsole to the processes, on Windows 7 I cannot do this anymore.
If I run jconsole <pid> I get “Invalid process id:4488”. The services are running as SYSTEM user.
If I make the service run as my desktop user (using “Log On as This Account”) the services process ID appear in JConsole, but they are grayed out and I cannot connect.
Is it impossible to dynamically connect to Java processes when they are running as a Windows 7 service?
Perhaps it is a 64bit/32bit problem, I have several applications compiled with 32bit JDK, which could not be opened with JConsole from 64bit JDK on Windows 7 64bit, after I downloaded the 32bit JDK it worked.
Others have been able to run jstack on 2008r2 which may provide some insight on how to get jconsole to connect on Windows 7. As you noted in your comment, the permissions are important. If the service and jconsole can't access the temp directory to write to the appropriate hsperf subdirectory, it won't work. What is also important is the location of the temp directory, the user the service is running, and the user that is running jconsole.
Running SysInternals psexec -s -i <jdk_home>\bin\jconsole <PID> can be used to run jconsole as Local System, the same user that I believe you are using to run your service.
My experience running jconsole from JDK 1.5 in Server 2008 as a system user was unsuccessful. With permissions that I thought should have been sufficient, I got a Could Not Open PerfMemory error. Java 1.6 may be a different story.
In light of all the challenges with running jconsole locally, you would probably have better luck setting it up to accept remote connections. You could set it up for local-only access with your firewall blocking that port from external access.
Add the following to JAVA_OPTION
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Then,
Use JConsole to connecet remote session:
localhost:8086
I am currently facing the same problem but on Windows 2003 R2 (SP2). There is on open bug in Oracle Bug database (bug id 6399729)
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399729
Also there is a work-around posted towards the end. It talks about installing java in "install" mode :-), but didn't work for me on Windows 2003 though. But your mileage may vary!!
Change Environment Variable TEMP and Tmp to a different folder that you created.
Like c:\theTemp
It might be a problem with the folder %TMP%/hsperfdata_{USER_NAME}.
In my case, it worked after I :
close all applications running over the JVM
delete the folder %TMP%/hsperfdata_{USER_NAME} (exemple: C:/Temp/hsperfdata_MyUser)
reopen JConsole (it recreates the folder)
Hope it helps. You can also take a look at this thread in Oracle community.