Setting up Java + svn + Eclipse+ Tomcat , development environment with docker - java

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

Related

Adding Java to Boot2Docker Linux VM?

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).

Is it normal to run docker instance running tomcat and deploy to this tomcat applications?

I'm using Docker with DOCKERFILE to create basic environment for the applications. This involves installing os, java and tomcat.
I have a question regarding to this - if is it ok to run docker instance with tomcat installed and deploy applications, updated version of the applications to the running docker container?
It is ok as long as you remember that any change to the filesystem will be "lost" when the container exits.
If you want to start a container with the updated apps, it would be best to:
either docker commit the running container where the app updates tooks place
or (best practice), update the Dockerfile with the update steps (in order to be able to reproduce), docker build that new image, and start a new container with the right apps at the right versions.

Netbeans 8.0 and networks project are too slow

I have a VMware Virtual Machine running on my PC because I use it as a development environment. I'm running on the VM CentOS 6.5. I have a Samba shared folder on that VM and I connect through "host-only" connection from Windows 7 to CentOS without any problem.
Now I create a project using a shared folder as project sources and opening Netbeans and wait for the project to be opened takes sometimes 15 min or more.
I disable "background scanning" following instructions on this post but still to slow, any advice on this one? What is the best approach? Use remote project sources through SFTP connection?
The real fix would be a fix of your samba. There is very likely some locking due to some network timeout in it. Most likely it is some WINS/DNS configuration problem. Only you can debug it (tcpdump/strace the samba process).
However, the best approach is not the fix of your samba, but using a different version for deployment. Your question makes likely that you have your development environment on your Windows host machine, and you deploy your code to your CentOS.
Use a native filesystem on your host, typically bound it into a versioning system (most likely, git), and make the deployment a part of your build scripts. For example, you could install a cygwin, and then upload your compiled code (or even the source) to your VM by an rsync. This rsync can already be called from your build script (like maven-exec-plugin in a pom.xml, if you use maven).

Jconsole cannot connect to java processes running as Windows 7 Services

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.

Does anyone have a beginners guide to installing and using glassfish?

I am after a all round installation and introduction to Glassfish.
(ie Your boss has told you need to develop your web applications for glassfish instead of tomcat)
Installing
Installing Glassfish onto your own PC for testing.
Download the installer file off the glassfish website
Move the installer jar to the location you wish the files to be installed. Once
installed, the install folder can not be moved. If you are not sure where to place it on OS/X or Linux, drop the installer jar into /usr/local/, this will result in your appserver being installed as /usr/local/glassfish
Run the installer with extra memory java -Xmx256m -jar glassfish-installer-xxx.jar
Run the configuration script: cd glassfish; lib/ant/bin/ant -f setup.xml
Starting the app server
To start glassfish with the default configuration type bin/asadmin start-domain domain1. This will result in the following URL's becoming available:
Admin website http://localhost:4848/
Application site http://localhost:8080/
The default administrator username and password are:
Username: admin
Password: adminadmin
IDE support
Eclipse support
The easiest way to get Glassfish working under Eclipse 3.5 is to use this software Update url (https://ajax.dev.java.net/eclipse) inside Eclipse.
Caveats and warnings
For those used to storing application settings and configuration in a context.xml file, glassfish does not support this.
Moving on from here
The following links are also very useful:
Guide to JMS in glassfish
Guide to JMS in glassfish in Netbeans

Categories