Unable to make Rest call for SSL certificate(https) site - java

I built Springboot micro services application, here i am making rest call to other website which was SSL certificate protected, i imported certificate to my java keystore and i am able to make rest call and able to get response when i am debugging that application from eclipse IDE, but when i am trying to run the jar from command prompt using the command java -jar xxx.jar then application starts and run time unable to get response from the same site. I have configured JAVA_HOME environment variable in my system and using the same jre for Eclipse and command prompt , i have no clue what caused this issue. Any one help me identifying root cause.
Thanks

Related

Running Eclipse configuration from the console

I am trying to run the xtend Server (ServerLaucher.xtend) as a Java Application. It works if I execute it in eclipse. If I open the Run Configuration, click on Show Command Line, copy the code from it (which looks like this one)
/usr/lib/jvm/java-8-openjdk-amd64/bin/java
...
mydsl.web.ServerLauncher
and run it in a normal terminal, the server starts as normal and says that it is available under localhost:8080. The problem, however, is that, in contrast to running it in Eclipse, the website doesn't work and I got the error website:
HTTP ERROR 503
Problem accessing /. Reason:
Service Unavailable
Powered by Jetty://...

Installing Jenkins windows slave from https master

I am trying to install the slave on Windows from a linux master. When using the Java Web Start, I get an error that it can't load the resource http://jenkinsserver:8080/jenkins/jnlpJars/remoting.jar
This is because the jenkins server is using 8443. Is there a way to tell it to use the correct port?
When I try from command line:
java -jar slave.jar -jnlpUrl http://jenkinsserver:8443/jenkins/computer/Slave-it-jenkins-p2/slave-agent.jnlp -secret xxxx
I get a message that it is unable to access the jarfile slave.jar Is it possible to use Jenkins on https and install slaves?
Yes it is possible to execute the same over https , if you dont have the proper certificate then you can either download them from browser or you can also pass the argument --noCertifcateCheck to ignore the cert.
For the above issue via http can you please provide the detailed error stack that will help
First, you can configure your Jenkins port at Configure Jenkins menu http://your-jenkins-server/configure/. Check out the JENKINS URL at Jenkins Location
I had no problem configurating my Windows Slave using JNLP + service start. Just make sure that your JNLP port is set and open. You can set that port # Jenkins Global Security http://your-jenkins-server/configureSecurity/
I used the Jenkins documentation Installing Jenkins as Service in Windows Slaves as a guide.

NoClassDefFoundError: org/apache/catalina/startup/Bootstrap when running tomcat from exe/as service

I have been running a Tomcat 6.0.37 server for quite some time via the startup.bat.Now I want to run tomcat as a service that starts automatically when the machine starts up.
I created the service with the bat : service.bat install.This created the service succesfully.When trying to start it however I get the error in the title.I then tried running just the exe(tomcat6.exe).This gave me the exact same error.
I have checked that CATALINA_HOME,JAVA_HOME and JRE_HOME is set correctly.bootstrap.jar does exist in tomcat/bin.Path to the jvm is correct.jvm.dll does exist in jre6/bin/server.
I also found a thread with a different class missing where they said rt.jar was missing from the jre,I checked this and mine exists in jre6/lib/.I really don't have anymore ideas as to what can be wrong.
try to update the service by executing (adapt to your path):
C:\> tomcat6 //US//Tomcat6 --Description="Apache Tomcat Server - http://tomcat.apache.org/ " \
C:\> --Startup=auto --Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar
US means: update service.
This should fix the classpath.
All the necessary information are in the official website:
http://tomcat.apache.org/tomcat-6.0-doc/windows-service-howto.html
Recommend using one of the "Java as a Windows Service" frameworks as they handle adding JARs to the classpath, etc. This can be done manually however via the "java -cp {set your classpath here...}" options as well.

How do I run a Java .jar file as a Windows service on Windows Server 2008?

How do I run a Java .jar file as a Windows service on a Windows 2008 server? I have a jar file called SomeJavaFile.jar located under the C:\SomeDirectory directory on a Windows Server 2008 box. I usually just run this jar manually in the command line with: java –cp SomeJavaFile.jar com.ctg.SomeJavaFile and I let it run 24/7.
The problem with our Windows Server is if it restarts I need to run it as a service so it will automatically start as a service upon startup, because our processing for Vistakon runs 24/7. I have Googled around and tried to use a service wrapper and the sc.exe command to create the service.
I put the wrapper service.exe in the C:\SomeDirectory\. I use the following command to create it: sc.exe SomeJavaService binPath= “C:\SomeDirectory\service.exe \”java –jar C:\SomeDirectory\SomeJavaFile.jar\”” type= own start= auto error= ignore. This creates the SomeJavaService service correctly but when I try to start it I get an error that says the service on Local Computer started then stopped.
Some services stop automatically if they are not in use by other services or programs. Do I need to alter my sc.exe command to have the exact previous working command line maybe, by adding in the com.ctg.SomeJavaFile? So should I change This jar should just run in the background and constantly poll/ping the C:/poll directory then if there is data present it processes the data and sends an export file to another directory.
I have used this same .jar file for years successfully and it hasn't changed, but I cannot get it to run as a Windows service. This is the site I use to get the service wrapper http://code.google.com/p/simple-service-wrapper/. Any help would be greatly appreciated!
"winsw" is the standalone version of the Windows Service installer shipping with the Glassfish Java EE reference implementation.
Works well, but is not a fully polished product - I have used it for exactly this purpose for a couple of years. Requires .NET in some recent version on the Windows machine.
https://github.com/kohsuke/winsw
I think that the best bet would be wrap your java app with Procrun of Apache Commons Daemon .
Procrun is a set of applications that allow Windows users to wrap
(mostly) Java applications (e.g. Tomcat) as a Windows service.
The service can be set to automatically start when the machine boots
and will continue to run with no user logged onto the machine.
As per my analysis,
The Idle Solution will be writing a VC++ (.net) Windows Service creation program to launch the .bat (that triggers the jar file)/.exe as a System service with all the required call back methods to SCM.
Note : 1. Wrapping the process with sc.exe / srvany.exe would not work as it does not have any call back process to the SCM (Service Control Manager). 2. And java service Wrapper is a third party API (many are LGPL licensed).
If you start your Java code from commandline by using java -j some.jar does it run until you terminate the program, or does it stop by itself?
There needs to be a NON-Deamon Thread, that is running all the time. A JVM will terminate, if there is no thread running, that is not flagged as daemon.
If you have a little budget, buy an installer tool. I use instll4j. With that tool, you can create service launcher and install them during instllation.
The following solution is working fine for me having OpenFire Connection Manager (which is a jar file) running as service on Windows Server.
Download and install the Non-Sucking Service Manager
I didn't use the batch made by OpenFire team, because it didn't work for me (dependencies not found error...) So, make a batch file with the following code :
#ECHO OFF
cd /D "E:\connection_manager\lib"
java -jar startup.jar
and save it as cm_startup.bat in the bin folder of connection manager.
After that you can create the service with NSSM.
So, open a cmd.exe and run the following command :
nssm install ConnManager "E:\connection_manager\lib\cm_startup.bat"
.
Doc & examples
More documentation and examples for the Non-Sucking Service Manager here : https://nssm.cc/usage Actually NSSM as a lot of options available.
Here is a more complexe example :
nssm install solr "%JavaExe%" -Dsolr.solr.home="\"%CD%\solr"\"
-Djetty.home="\"%CD%"\" -Djetty.logs="\"%CD%\logs"\" -cp
"\"%CD%\lib\*.jar"\";"\"%CD%\start.jar"\" -jar "\"%CD%\start.jar"\"

Starting Jetty via launch script does not work

I have a problem with starting Jetty via the startup command /etc/init.d/jetty. When I execute the command the following output is generated:
/etc/init.d/jetty start
Starting Jetty servlet engine.:
Jetty Rotate logs
Jetty servlet engine started, reachable on http://jagadguru:80/.: jetty.
It does start successfully when I type java -jar start.jar in my Jetty directory.
Can anyone help me with this?
This is likely a file permission issue. Even if you are running the start script with sudo, the script defines a jetty user (default is jetty). I had an issue similar to this where my permissions on /tmp prevented jetty from creating a file there. I adjusted the permissions on /tmp and all is well! The jetty user also needs permissions on the jetty folder of course.
Also, for checking if Jetty is finding java correctly, run sudo service jetty check
It's probably an issue due to wrong permissions on some work or log folder. I assume the start script tries to change the user and therefore doesn't has the same permissions as the one you use when running Jetty via "java -jar".
Another possibility is that you don't have JAVA_HOME set and the start script doesn't find your java bin.
Please attach some kind of log file as it is really hard to say more without more detailed information.
As answered here, the default configuration for Jetty in /etc/default/jetty only allows connections from localhost, you need to set JETTY_HOST to 0.0.0.0 to allow Jetty to accept connections from any host.
Add the following line to /etc/default/jetty:
JETTY_HOST 0.0.0.0

Categories