How can I reload Nginx in tomcat web application - java

I want to reload nginx when I send a http request to the web application. So In the web application's servlet, I execute the nginx reload command. The Java code is :
"Runtime.getRuntime().exec("/etc/init.d/nginx reload").waitFor();". I have tried it but it has no use. But if I login the server as user root, then execute the Java code above, it works!
So I guess the reason is that the tomcat user has no authority to reload nginx. The tomcat process is running as user tomcat6. The nginx master process is running as user root and the nginx worker processes are running as user www-data. How could I solve this problem? Thanks.
My environment :
OS:Ubuntu 10.04
tomcat: 6.0.24
nginx: 1.2.2.
Tomcat and nginx are both installed via the Ubuntu's way "apt-get".

You can use sudo command. Also you can grant corresponding authorities to tomcat user. Also you can perform su to change user to some that have corresponding authorities and then perform nginx reload. Actually there are a lot of different ways to solve this issue.
I think that it will be better to write and test some script which can reload nginx from tomcat user session and use it for reloading instead of /etc/init.d/nginx reload command.

Related

cannot use both TOMCAT server and my internet connection

I cannot have my tomcat server started and at the same time use internet.
either I can start Tomcat (in Eclipse) and internet is not available.
or I can access the internet but tomcat cannot be started.
Here the original probleme I had when I first wanted to use Tomcat and display my html page on localhost.
GRAVE: StandardServer.await: create[localhost:8005]: I find a way to start the Tomcat Server: in the terminal:
sudo lsof -i : 8005 # checks port 80
sudo route -n flush
sudo route add default 192.168.1.1
then I can use tomcat and localhost:8080 but my internet connexion is dead
if I want my internet connexion then I stop the tomcat server by clicking on the red square in eclipse and then in the terminal I do:
sudo route -n flush
sudo route add default 192.168.0.1
THen I can use internet but tomcat cannot be restarted. I have to undergo the first process.
this of course is a very boring process and I would like to know what 's wrong and how I could fix it.
I use tomcat 9 / Mac OS sierra / Eclipse Neon3
When you say "my internet connexion is dead", do you mean that your network connection drops or that your DNS lookups fail? (What do you think this command is doing and why are you performing it: sudo route add default 192.168.1.1?)
If your program is modifying your system's connectivity settings, I would strongly recommend against preventing it from doing that. There's no reason for it to do so at that level, a more appropriate place to set settings would be at some deploy stage.
Alternatively, you could run your app in a Docker container which I strongly suspect will solve your problem. Visit www.docker.com to learn more.

Connect JVisualVM to a Remote Wildfly Instance?

I'm trying to connect JVisualVM, running on my local machine, to a remote machine which is running a WildFly server (version 8.1.0, to be specific.)
I didn't configure the WildFly server myself, and I don't know who did, but I do know that I can log in as an administrative user from my local machine by pointing my browser at:
https://[ip address of the remote machine]:9443/console
Note that it's https, not ordinary http, and that the port for that has been set to 9443 (I think the default is 8080 or 9990 or something... IDK, I saw a lot of port numbers online. I have been explicitly told that http was disabled for this WildFly server).
I can SSH into the remote machine. I can navigate to the bin directory for WildFly and run jboss-client.sh. I have to connect on port 9999 (I think the default is 9990 for that?)
I copied the jboss-client.jar (under bin/client) to my local machine and ran JVisualVM from the command line like this:
.\jvisualvm.exe -cp:a C:\[path to]\jboss-client.jar
It launches fine. File > Add Remote Host: Then I entered the IP. OK. I right clicked on it under Remote in the tree and picked Add JMX Connection. I entered
service:jmx:http-remoting-jmx://[ip]:9999
I checked off that I wanted to use the security credentials and entered the username and password. Checked off to save the security credentials. Left "Do not require SSL Connection" unchecked. Hit OK. It immediately spat out the message
Cannot connect to admin#service:jmx:http-remoting-jmx://[ip]:9999 using service:jmx:http-remoting-jmx://[ip]:9999
I also tried the port 9443, 9990, and 8080 instead. None of those worked. I tried https instead of http in the protocol name. That also didn't work.
What am I missing? How is it that I can access the console, and connect with jboss-client.sh, but I can't use JVisualVM? Is there some log I can use somewhere to see what's wrong? Maybe someone can point out a configuration I've missed somewhere?
Not sure if it's important or not, but my local machine is running Windows 10 with JDK8 installed. The WildFly server is using Java 6 on CentOS 6.3.
You need to add the jboss-client.jar (or jboss-cli-client.jar) to the class path for JVisualVM. The library can be found in the bin/client directory of the WildFly install.
I used the following command to add the library to the class path.
jvisualvm --cp:a ~/servers/wildfly-10.0.0.Final/bin/client/jboss-client.jar
Then I used service:jmx:remote+http://[ip]:[port] and was able to connect.
I don't know if someone else is also (still) having the same issue (Wildfly10 on a remote machine where management console is available at 9443 with HTTPS). The following worked for me.
For ssh connections:
Starting jvisualvm with jboss-client.jar
jvisualvm --cp:a #JBOSS_HOME/bin/client/jboss-client.jar
Using the following connection string:
service:jmx:remote+https://remote-server:9443
NOTE: I used here remote+https
Provide username and password
Hope this helps.
you missed run jstatd command in remote host ,
this little program is RMI server that possible connection from client to remote host though you using jmx connection it used jmxrmi protocol for that connection .
so first in remote host create file name as security.policy with this contain :
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
off course you must in file section for linux put explicit path and then of creation this file put it in bin directory of jdk.home
then you should run this command on remote host
$JAVA_HOME/bin/jstatd -J-Djava.security.policy=path of /security.policy -J-Djava.rmi.server.hostname=remote ip address -J-Djava.net.preferIPv4Stack=true
then you could connect to server off course with correct settings.
Include jboss-cli-client.jar and jboss-client.jar under \lib\visualvm\platform\lib and restart jvisualvm to pickup new jars.

Weblogic 10.3 can not be accessed after enableing Administrator port

I was was following this blog to set up some SSL connection. One-Way SSL with JAX-WS using JDeveloper 11gR1 and WLS 10.3.1
One of the steps mentioned is to enable the Administration port from weblogic console. I did that and change the Admin port. But, after saving everything get missed up the conclose closed and the I could not run the application form Jdeveloper .
The Error message is:
User 'principals=[weblogic, Administrators]' has administration role. All tasks by adminstrators must go through an Administration Port.
**** Authentication error while connecting to application server IntegratedWebLogicServer. Please check settings.
**** Failed to complete start-up of application server IntegratedWebLogicServer.
[Server Instance IntegratedWebLogicServer is shutting down. All applications currently running will be terminated and undeployed.]
[Forcing termination of IntegratedWebLogicServer]
taskkill /F /PID 7480
Process exited.
This blog: SOA OIM integration and WebLogic administration port
discuss this issue BUT under the assumption that I can access the weblogic console. But it is not happening for me.
I am using Jdeveloper 11.1.1.7 and the weblogic 10.3
The problem solved by deleting the system files for jdeveloper. This action will re insinuate the weblogic server. This file is located in my case in the following path: C:\Users\[UserName goes here]\AppData\Roaming\JDeveloper.
Check this thread form Oracle community for more information : Authentication error while connecting to application server IntegratedWebL

Remote admin of glassfish does not work

I have a server on remote where i am logged by ssh. I have unzip it the glassfish v 3.1.2 and follow the steps http://bbissett.blogspot.com.es/2012/01/asadmin-with-remote-glassfish.html until the part where enters in the link of admin(port 4848) There I am redirect by the browser to the web where the login loader (ip-glassfish-installed:4848) starts spinning and nothing happens.
The log I got in the server is "User [] from host localhost does not have administration access|#]" But I have changed the admin password and login with it. So I dont understand in first instance why I got the user empty. Also, although I think is not related, says that the certificate has expired.
You need to enable remote adminstration. Here are couple of other useful links that provide help in that direction:
http://www.adam-bien.com/roller/abien/entry/enabling_remote_administration_for_glassfish
https://blogs.oracle.com/quinn/entry/securing_adminstration_in_glassfish_server1
The problem is that the user I logged in the remote machine by ssh did not have the right permission to execute the domain, even after doing "sudo su". If I enter in the remote machine with the root user everything works fine, or using "sudo su -" after login with the normal user.

Authenticating a server using kerberos

I thought it could be a good idea to use kerberos on Windows 2003 to authenticate a Java server application against active directory. That way, we will not have to put a password in a file. But this does not work.
[2012-09-20 17:42:19,301] ERROR Cannot authenticate server via JAAS
javax.security.auth.login.LoginException: No LoginModules configured for KerberosLogin
at javax.security.auth.login.LoginContext.init(LoginContext.java:273)
at javax.security.auth.login.LoginContext.<init>(LoginContext.java:349)
If I run the exact same code and configuration on Windows XP, then authentication works. In both cases I am using Java 7 u07.
It turned out my TGT that I had aquired via JDK's kinit command had expired.

Categories

Resources