I just installed Glassfish 3. My browser shows me the Glassfish 3 Control Panel at 127.0.0.0:4848.
Since my computer is also running the Apache2 server for my PHP development, and I don't want to use too much memory, I want to be able to turn Glassfish on or off at will. e.g. if I want to turn the Apache2 server off on my Ubuntu machine I use the command
sudo /etc/init.d/apache stop
So what is the procedure to turn the Glassfish server off on Ubuntu?
Change to the glassfish/bin directory
Run the following as needed:
asadmin start-domain domain1
asadmin stop-domain domain1
Visit Chapter 3 Administering Domains for more asadmin commands.
In addition to the valid "asadmin start-domain" & stop-domain option already given, you can utilize operating system services to start/stop GlassFish, much like you do with your PHP environment.
Look into "asadmin create-service" command:
$ asadmin create-service --help
You can also check out the documentation on docs.oracle.com on how to create a service with create-service.
cd [GlassFishHome]/bin
asadmin stop-domain domain1
Related
I am trying to install Glassfish 4.0 on a Linux Red Hat Entreprise Linux release 5.11 (Tikanga) Server.
Therefore, I successfully installed Java jdk1.7.0_79 and NetBeans 4.0 on this server following this website instructions: https://blog.idrsolutions.com/2014/02/tutorial-setting-up-glassfish-on-a-linux-server/
When I run the server using the linux command ./asadmin start-domain, the console tells me that everything is ok:
If I run the sudo netstat -lntp command, I obtain the following output for port 4848:
which seems to be all right.
Finally, if I open the domain.xml file in glassfish/domains/domain1/config repertory, I will have:
and
and
which is quite strange because port 4848 is not appearing and everything is set to localhost.
I really do not know what is going on. In the tutorial everything looked so straightforward. Could you help me please ?
I finally found out the problem.
The firewall of my Linux Red Hat Entreprise Linux release 5.11 was blocking the 4848 port. Therefore, using the following commands I successfully made everything working properly:
Go to the following folder:
/etc/sysconfig
Open the file containing the firewall table:
vi iptables
Add the following line to the table:
-A RH-Firewall-1-INPUT -m state –-state NEW -m tcp -p tcp -–dport 4848 -j ACCEPT
Save and exit
Restart the network service by typing :
service iptables restart
I recently downloaded Glassfish 4.0 and I want to use it in NetBeans for making some Web Applications, but when I want to start the domain1 (asadmin> start-domain domain1) I keep getting this error:"There is a process already using the admin port 4848 -- it probably is another instance of a GlassFish server". Any clue what could be the problem?
Glassfish could not resolve the host name. Diagnose the problem (on Linux) as follows:
Open a Terminal.
Type hostname.
Type: ping $(hostname)
If the ping command fails (could not find the host), then add the host name to /etc/hosts. This can be accomplished as follows:
Switch to root: sudo su -
Type: echo "127.0.0.1 $(hostname)" >> /etc/hosts
Kill GlassFish
Restart GlassFish
your system using port 4848 that is why.
when glassfish starts its need three port numbers one for administrations, one for http applications other for https.
so in you system 4848 is already reserved by some program or server.
Or you can change default port number as per your need like below.
type in command prompt.
To change the HTTP port to 10080:
asadmin set server.http-service.http-listener.http-listener-1.port=10080
To change the HTTPS port to 10443:
asadmin set server.http-service.http-listener.http-listener-2.port=10443
To change the administration server port to 14848:
asadmin set server.http-service.http-listener.admin-listener.port=14848
Try lsof -i:4848 on the terminal.
Kill the java processes listed using the command kill -9 <PID>.
If you have a GUI task manager, say like Activity Monitor on OSX, then you can just kill the java processes listed there.
Hope this works for anyone facing this problem.
1- Go to the config folder inside your domain.
(In my case: C:\Glassfish\glassfish\domains\mydomain\config\ )
2-Open the file domain
3-Update the port number on these three lines:
4-Restart your domain:
--Note
For restarting the domain:
1-Open cmd console
2-Navigate yo your domain
3-Execute: asadmin restart-domain mydomain
--I hope it helps :-)
Solution can be this:
in console type:
echo $HOSTNAME
then make sure the output follows 127.0.0.1 string in
/etc/hosts
For example:
127.0.0.1 dev.myserv.pl
Do a
netstat -aon
from command line and check which process is using your port.
If it's not important, kill it as a quick'n'dirty solution.
For some monitoring purposes I need to start Glassfish domain with custom java agent attached.
If I start domain directly with command:
java -cp /path/to/glassfish3/glassfish/modules/glassfish.jar com.sun.enterprise.glassfish.bootstrap.ASMain bla-bla-bla -javaagent:/path/to/agent.jar
it works as expected.
But how to do the same with domain, which starts with asadmin?
I've tried asadmin create-jvm-options and asadmin create-system-properties - it didn't help me. Any ideas?
Try restarting the domain.
If you set anything JVM-related, that will not be effective until you restart the domain. The GF Admin Console also warns about it it you do it on the web UI.
The asadmin docs also warns about it.
I am running Tomcat 6 on a Linux server in Amazon's cloud. I am trying to connect to it with VisualVM from my Mac at my office. I have allowed opened up all TCP ports between my desktop and the server, but I am unable to get VisualVM to do anything.
On the linux box, I have started Tomcat with:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9191
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
On my Mac, I launch VisualVM and choose File -> New JMX Connection...
I enter amazonhostname.com:9191 in the box. It says "Adding amazonhostname.com:9191..." and sits there for several minutes before timing out.
From my Mac, I can "telnet amazonhostname.com 9191" just fine, and I tried some other random ports, and they all worked. I'm pretty convinced it's not a firewall issue, unless I need to open UDP or ICMP or something like that. (Really??)
There is nothing in catalina.log on the server, or the system console on my Mac, related to jmx. netstat on the server shows 9191 and some other ports open on all interfaces.
There is no jstatd on the remote server. Is that a pre-requisite for JMX? (I am totally new to Java and I'm not even sure what those things mean, but I saw it on a blog post somewhere. I'm grasping at straws now.)
Set the hostname property before the VM starts:
java -Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=9191 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Djava.rmi.server.hostname=the.public.ip \
-jar program.jar
Add the relevant rules to your security group.
What worked well for me in RHEL7 environment is to implement the JmxRemoteLifecycleListener on Tomcat using the example provided in the documentation. I have also opened up ports 10001 and 10002 on the firewall.
JMX Remote Lifecycle Listener
I am running tomcat 6.0.18 as a windows service. In the service applet the jvm is configured default, i.e. it is using jvm.dll of the JRE.
I am trying to monitor this application with JConsole but cannot connect to it locally. I added the parameter -Dcom.sun.management.jmxremote (which works when starting tomcat with the start.bat script). But the jvm does not seem to pick up the parameter.
There's a nice GUI to edit the options, no need to muck around in the registry.
Open up the C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\tomcat6.exe (or just double-click on the monitor icon in the task bar). Go to the Java pane, add the following to the list of arguments, and restart Tomcat.
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Then you can connect with JConsole or the newer VisualVM.
Here's the prescribed way for changing jvmoptions & interacting with the service:
http://tomcat.apache.org/tomcat-5.5-doc/windows-service-howto.html
I would try going into your registry at HKLM/Software/Apache Software Foundation/Procrun 2.0//Parameters/Java and editing the "Options" multi-string value directly.
If Tomcat is running as a Windows service, and you want to attach to the JVM locally, you need to run VisualVM or JConsole as the System account. You can use Sysinternals PsExec.exe to accomplish this.
psexec.exe -i -s c:\visualvm\bin\visualvm.exe
I'm posting it mainly to record this information to myself, I haven't validated it - but this is supposed to work as well:
http://mysqlandsqlserver.blogspot.com/2010/02/jconsolejmap-and-tomcat-as-windows.html
There is still a rather simple way to connect JConsole to Java process started as Windows Service using the local mode which I discovered here.
Basically it says that in order to connect to Java process launched as a Windows Service you need to launch JConsole as a Windows Service (you can do it using windows native api or using any wrapper like yajsw.)
By the way, this will free you from restarting the Java Process which was critical for me.
Add the following near the top of your catalina.bat
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote ^
-Dcom.sun.management.jmxremote.port=8086 ^
-Dcom.sun.management.jmxremote.ssl=false ^
-Dcom.sun.management.jmxremote.authenticate=false
Stop and restart tomcat (obviously)
Run jconsole.exe. If your tomcat is running as service, then run jconsole.exe as administrator.
Select Remote Process and enter localhost:8086