How to Stop Hybris server from command prompt or Admin console - java

I want to add a new extension and for that I need to stop hybris server first, but I am unable to figure out how exactly I should STOP the server: through command line or by admin Console?
I cannot type any command as my server is running.
I also started the server by using hybrisserver.bat

just push ctrl + c in the command line window and the server is shut down properly

As a small side note, if you'd like to stop a hybris server through the admin console, you could always go to Console > Scripting Languages > Edit Statement and execute System.exit(0);
hybris has got all the necessary runtime shutdown hooks to do a graceful (as if you did CTRL + C).
In theory it's also possible to restart the hybris system internally by executing:
import de.hybris.platform.core.Registry;
Registry.destroyAndForceStartup();
By default, there's a restriction to forbid doing so using groovy scripts, though.

Sometimes it happen that the hybrisserver is runned on another console and even after hybrisserrver.sh stop some processes are still running. And you will receive message like:
INFO: Illegal access: this web application instance has been stopped already
My solution is (for linux based systems):
lsof | grep hybris
To get the processes runned from "hybris" directory(change on you need) and then kill the listed processes with:
kill -15 <PROCESS_ID>
PS. (This solution require the root privileges)

Use this command /bin/platform/hybrisserver.sh stop
That will stop the server.

Related

Rabbitmq exception com.rabbitmq.client.PossibleAuthenticationFailureException: Possibly caused by authentication failure [duplicate]

I've installed the latest RabbitMQ server (rabbitmq-server-3.3.0-1.noarch.rpm) on a fresh Centos 5.10 VM according to the instructions on the official site.
I've done this many times before during development and never had any issues. However, this time I cannot log into the management web interface using the default guest/guest user.
In the logs, I see the following:
=ERROR REPORT==== 4-Apr-2014::00:55:15 ===
webmachine error: path="api/whoami"
"Unauthorized"
What could be causing this?
It's new features since the version 3.3.0
http://www.rabbitmq.com/release-notes/README-3.3.0.txt
server
------
...
25603 prevent access using the default guest/guest credentials except via
localhost.
If you want enable the guest user read this or this RabbitMQ 3.3.1 can not login with guest/guest
# remove guest from loopback_users in rabbitmq.config like this
[{rabbit, [{loopback_users, []}]}].
# It is danger for default user and default password for remote access
# better to change password
rabbitmqctl change_password guest NEWPASSWORD
If you want create a new user with admin grants:
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
Now you can access using test test.
If you still can't access the management console after a fresh install, check if the management console was enabled. To enable it:
Go to the RabbitMQ command prompt.
Type:
rabbitmq-plugins enable rabbitmq_management
Something that just happened to me and caused me some headaches:
I have set up a new Linux RabbitMQ server and used a shell script to set up my own custom users (not guest!).
The script had several of those "code" blocks:
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
Very similar to the one in Gabriele's answer, so I take his code and don't need to redact passwords.
Still I was not able to log in in the management console. Then I noticed that I had created the setup script in Windows (CR+LF line ending) and converted the file to Linux (LF only), then reran the setup script on my Linux server.
... and was still not able to log in, because it took another 15 minutes until I realized that calling add_user over and over again would not fix the broken passwords (which probably ended with a CR character). I had to call change_password for every user to fix my earlier mistake:
rabbitmqctl change_password test test
(Another solution would have been to delete all users and then call the script again)
If on Windows and installed using chocolatey make sure firewall is allowing the default ports for it:
netsh advfirewall firewall add rule name="RabbitMQ Management" dir=in action=allow protocol=TCP localport=15672
netsh advfirewall firewall add rule name="RabbitMQ" dir=in action=allow protocol=TCP localport=5672
for the remote access.
I also couldn't log in to Rabbit's web interface. in my case, cookies were disabled in the browser for this web interface. I allowed cookies to be saved and rebooted chrome. and I was able to log in again.
If you are in Mac OS, you need to open the /usr/local/etc/rabbitmq/rabbitmq-env.conf and
set NODE_IP_ADDRESS=, it used to be 127.0.0.1. Then add another user as the accepted answer suggested.
After that, restart rabbitMQ, brew services restart rabbitmq

Error while running webapplication with google appengine

I created a small web application.if i deployed its work but if try to run application it show
the port 8888 appears to be in use(perhaps by another lanch),do you still to contine with this lanch? i clicked yes
but show the error
Could not open the requested socket: Address already in use: bind
Try overriding --address and/or --port.
The problem is what it is stating.
You are facing this issue because of the following:
Either the port 8888 is in use by some other application and not previous launch. This is less likely.
This condition is more likely and it is because you have already launched the application once i.e. via the Run as Web Application. And it is still running. In your Eclipse, visit the Window-> Show View -> Console. And in the Console window, you will find one or more previous instances running. Please stop that.
There are some instances where the solution suggested by Romin will not work because the option to stop the process does not present itself in the console.
In these cases, you can probably find out which process ID is using the port and then kill that process.
For example, on a mac, this worked for me:
😈 >lsof -i tcp:8888
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 25866 alexryan 60u IPv6 0x96e9c26778f105e1 0t0 TCP localhost:ddi-tcp-1 (LISTEN)
😈 >kill 25866
😈 >lsof -i tcp:8888
😈 >
The port number 8888 is in use means that port already been activated. do one thing go to servicees option of control panel set the server start option from automatic to manual. Then your apps will get run. else you can stop the server from your eclipse env stop option.

Windows service installed with Procrun works in //TS mode, but doesn't start as a Windows service saying it "started and then stopped"

I installed a standard executable jar file as a Windows service by running the following command:
> prunsrv.exe //IS//"My Service" --Install="C:\path-to-prunsrv.exe" --Jvm=auto \
--Startup=auto --StartMode=jvm --Classpath="C:\path-to-MyService.jar" \
--StartClass=com.mydomain.MyService
I can now run my program fine in console mode by running the following command (I'm using Java 1.6):
> prunsrv.exe //TS//"My Service"
When I try to start the service through the standard Windows services interface, I get the following error message:
The MyService service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.
There is no output in my application's log file when I attempt to start the service this way. There is also no output in the Window's event log (Windows 7 64-bit). What can I do to try and figure out why this service will not run?
Don't use any white-space in the service name!
After many hours of testing and pulling apart Tomcat and duplicating it's bootstrap process, the fix for my problem ended up being that Apache Commons Daemon (Procrun) does not work properly when there is white-space in the name of the Windows service.
It seemingly correctly installs and registers a service with Windows when there are spaces in the service name. The Windows registry entries even look correct. The service even runs in debug (aka TS or console) mode just fine. When run, however, as an actual service launched by Windows it fails if the service was installed with a white-space in the service name.
I sure wish Procrun had some type of log output when it fails! Good logging can make debugging issues like this a snap.
I did need to have multiple words in my service name, so I named my service with one word and changed the name with the "DisplayName" parameter:
> prunsrv.exe //IS//MyService --Install="C:\path-to-prunsrv.exe" --Jvm=auto \
--Startup=auto --StartMode=jvm --Classpath="C:\path-to-MyService.jar" \
--StartClass=com.mydomain.MyService --DisplayName="My Service"
I wanted to give some additional information about what '11101101b' said above. (This is my first post, so please be gentle!)
I was able to get the service to install correctly with spaces in the service name by changing the //IS//MyService part of his command to instead be the following, which I suspect is what he also did. (I apologize if I'm assuming incorrectly.) Notice that the opening double quote is at the beginning of the string rather than at the beginning of the service name.
"//IS//My Service"
As was the case for him, the service installed correctly and looked correct, but it wouldn't start. I was able to get around that by changing the service's ImagePath value data setting in the registry to have the same change for the //RS//My Service part of the command. Therefore, the registry value instead had the following in its data setting:
"//RS//My Service"
Everything seems to be working without any problems.
This server starts and stops because of reason the task is completed by the service so it would stop automatically. if you have a logic of running long inside it would not stop.
I got same problem ... under my local machine everthing working fine on server the same issue => problem was that Working Path was not set.
May its heps someone ... be the force with you

Binding a port < 1024 for non root user in Java

I have a Java application which is running as non root mode.
My App will create a TFTP server (using apache commons tftp). TFTP server is bind to port 69(Default TFTP port). When running the app from IDE everything works fine since the IDE running as root. But if the app is run from other user i get the error
java.net.BindException: Permission denied
It is clear that for non root user i can not open the port. Is there a workaround for this issue?
For binding on Linux of ports less that 1024 you need to application to run a root. There is no way around this. If you need to do this you have you run as root. sudo might be the command to look into.
BTW - Running your IDE as root is not a very good idea.
To resolve this issue. You can use setuid() and setfid() system calls. So that you can temporarily elevate the permissions and then drop the permission back to user permissions.
In my Case, this problem happened in Solaris 11 OS. I added privileges to user to use the ports under 1024.
https://technicalsanctuary.wordpress.com/2014/06/03/allowing-a-user-to-use-ports-under-1024-on-solaris-11/

How to kill firefox child process/tab from Java/C++

I have my application in Java which invokes a browser [IE or Firefox etc ] ..
Requirement is when my Java Application exits i have to kill all the web pages [Child processes ] i have opened from my Application in IE/Firefox etc..
I use the following code .
Note : cmd contains "System Browser exe path and URL"
static ArrayList<Process> pro = new ArrayList<Process>();
String cmd=" ";
Process p = Runtime.getRuntime().exec(cmd);
pro.add(p);
I maintain a static arraylist to add all the process objects .
To kill the process i invoked i use the below code
Iterator<Process> iter = pro.iterator();
while(iter.hasNext()){
Process p = iter.next();
System.out.println("Now Killing "+p.toString());
p.destroy();
}
This code[p.destroy();] is working fine for Internet Explorer , But its not working for Firefox/Chrome...
Since Firefox runs as a Main process and the process what i invoke goes as its child :(...
I have to use generic fix for Windows and Linux..
I can even go for C++ file fix which does this with some search criteria ..so that i can execute that executable from my code using
Runtime.getRuntime().exec("executable cmd");
In windows, you can run :
wmic process get description, executablepath, processid | findstr firefox
which will give you the PID of the firefox process. Then you can use tskill PID to kill
the process.
Good question.
There are several solution.
The first is the following. Run browser not directly but using script (shell for unix, bat file for windows) that will report you the process ID of the browser that it runs. Then use kill -9 PID on linux and taskkill on windows.
This solution will require you writing scripts for different platform (at list for 2).
But I have other suggestion. If the URL that you are opening in browser is yours (I mean you can add some javascript there) you can do the following. The URL that you are opening will create AJAX call to server. When you close your application you should say to server to send command to the browser to close it. At this moment javascript that is running into the browser will close its window. This is the most cross-platform solution.
BTW I think that the server that is used by mentioned AJAX component may be your own application. And the signal that you send to the AJAX component is just connection error. Really, if your application is the server and you are closing it, the AJAX call will fail. This 100% means that the browser should be closed too.
try using pkill (killing by process name) command.
Runtime.getRuntime().exec("pkill firefox");
or in c++
system("pkill firefox");
But it's not platform independent. It will run on Unix-like operating system, and not in windows.

Categories

Resources