Run dropwizard jar file on https after creating package with debian - java

I'm able to run Dropwizard application on https on my local machine trough this commands.
mvn package
java -jar target/dropwizard-example-1.2.0-SNAPSHOT.jar db migrate example.yml
java -jar target/dropwizard-example-1.2.0-SNAPSHOT.jar server example.yml
Here is the example I am following dropwizard-example on github
Once we create package of Dropwizard application with Debian. it converts into single jar file.
Q1:
How can I run the command ends with server example.yml? because this file is not going to found?
Q2:
How can I run jar file of dropwizard application packaged through debian on windows machine?
Q3:
On local machine it runs sucessfully on https port. How can it will be achieve after packaged through debian?

You need to ship .yml file because it is a setting file JAR always looks for this file.

Once we create package of Dropwizard application with Debian. it converts into single jar file.
All Dropwizard applications are a single jar file. That is what you are making on your local machine (when you do mvn package) and running on your local machine (when you do java -jar...), so you will run that single jar on whichever other machine you deploy your app to.
How can I run the command ends with server example.yml? because this
file is not going to found?
The github project you cloned included the file example.yml. This needs to be on the machine you are going to run the application on. You can call it whatever you like, but you must pass its name to the jar as an arguemnt.
How can I run jar file of dropwizard application packaged through
debian on windows machine?
The same as on debian, java -jar target/dropwizard-example-1.2.0-SNAPSHOT.jar server example.yml
On local machine it runs sucessfully on https port. How can it will be
achieve after packaged through debian?
If you look in the example.yml you can see where this is configured:
applicationConnectors:
- type: http
port: 8080
- type: https
port: 8443
keyStorePath: example.keystore
keyStorePassword: example

Related

Unable to deploy EAR file to Azure App Service using JBOSS EAP 7

I am unable to deploy EAR file into Azure App Service with JBOSS EAP 7.3.6.
I tried following steps as described in the documentation found at this link.
Out of given 4 options, allowed to use either Azure CLI or Kudu API since EAR is not supported by Azure Powershell and Kudu UI not supporting any.
Using Azure CLI, tried executing following command.,
az webapp deploy --resource-group test-rg --name dmap --src-path C:\Users\HP\Desktop\DMAP.ear
Getting error as
CommandNotFoundError: 'deploy' is misspelled or not recognized by the system.
Did you mean 'deployment' ?
Still stuck? Run 'az webapp --help' to view all commands or go to
'https://learn.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest' to learn
more
Using Kudu API, tried executing following command.,
curl -X POST -u dmap --data-binary #"C:\Users\HP\Desktop\DMAP.ear" https://dmap.scm.azurewebsites.net/api/publish&type=ear
Getting response as
The system cannot find the file specified.
Searching for this response, I found this link where it comes for successful deployment too. Assuming it I tried to access my application using link https://dmap.azurewebsites.net/DMAPWeb. But it shows nothing found.
To verify the deployment, I checked folder /site/wwwroot using FTP but I don't see any files deployed.
Could you please guide me here and clarify where I am wrong.
We have tested this in our local environment it is working fine. Below statements are based on our analysis.
Using the Below Azure CLI cmdlet , we have tried deploying the .ear file from local machine to web app (deployed in azure ) operation got succeeded without any issues.
Here is the cmdlet we have used :
az webapp deploy --resource-group <rgName> --name <webAppName> --src-path c:\Users\Downloads\<fileName>.ear ##Path of .ear file
Here is the Sample output for reference:
Note:
If you are deploying from local machine run the az.cmd(AzureCLI) in admin mode. By default az.cmd will be under the path c:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin in your local machine.

process manager for JAVA Jar Files for hosting

I want to deploy my java spring backend to AWS .
I figured the way to deploy jar file on aws. But the problem is as soon as I terminate the terminal deployment stops. I created a jar file on build and hosted on aws EC2 linux Instance by copying jar file there and running below command .
java -jar jarfile
I want this deployment to be persistent. Is there any tool similar to pm2 for nodeJs in JAVA so that I can run this jar file permanently. ?
Thanks for help.
You should use nohup to deploy jar file. It will run even though you close terminal
E.g:- nohup java -jar javaservice.jar > nohup.log &

Sprin Boot apps no log dir created by running it throgh a remote ssh command

I try to deploy the sprin boot jar file into a remote Linux server and run it throw java -jar command.
The command was much like below:
ssh root#xxx.com:/myjdk_path/bin/java -jar /tmp/target.jar
The problem is that there was no any log dir been created while i running the command.
The sprin boot app was created by the spring.io site,it's a normal app then i put one single line "logging.file=./log/my.log" into application.properties.
But it works(the log dir can be created) when i just logged into the target server and type the command in the ssh console.
The sprin boot version is 2.05 and i've test version 1.5.16 still the same.
And i aslo test it in both Ubuntu and Centos servers,nothing haapens too.
Really appreciate if you can give a clue on this!
Thanks all you guys , it turns out my fault, the reason is that I am using a relative log path ,and I run that java -jar command out side the shell directory.
old command:ssh root#xxx.com:/myjdk_path/bin/java -jar /tmp/target.jar
new command:ssh root#xxx.com:cd /tmp; /myjdk_path/bin/java -jar target.jar
the log dir was been created for the old command ,but it in the user home path(for this command is the ROOT user),but not in the /tmp path.
so my stupid check steps missing that point,and thought there is no log dir been created!

How to set environment variable to localhost?

I have a very basic question regarding environment variables. The Tika python library that I'm trying to work with mentioned the following:
TIKA_SERVER_ENDPOINT: set to the host (local or remote) for the running Tika server jar
I downloaded the server jar from here and ran it with java -jar jarname.jar I'm trying to set the environment variable to the localhost, but I'm not sure how exactly to do this. I tried the following:
TIKA_SERVER_ENDPOINT=http://localhost:9998
But this simply resulted in a 404, with Network Error (dns_unresolved_hostname), Your host cannot be resolved by the DNS,
I also ran ps aux | grep java to check if the jar file was running and saw that it was running on the port 9998..... i.e:
java -cp /tmp/tika-server.jar org.apache.tika.server.TikaServerCLi -- port 9998 --host localhost
What exactly am I doing wrong here with my environment variable? I'm just very new to messing with jar files and environment variables, so any help would be greatly appreciated, thanks!
I had a similar issue and was able to resolve it by simply downloading the latest server jar from the Apache downloads page and then starting the server on my local machine from bash with:
java -jar tika-server -x.x.jar --port xxxx
Which started the tika server. I was then able to access tika in python through:
from tika import parser
parser.from_file('path_to_file')
Maybe java is installed incorrectly. You can check java installation here
Installation (with pip)
pip install tika
Installation (without pip)
python setup.py build
python setup.py install
Environment Variables
These are read once, when tika/tika.py is initially loaded and used throughout after that.
TIKA_VERSION - set to the version string, e.g., 1.12 or default to current Tika version.
TIKA_SERVER_JAR - set to the full URL to the remote Tika server jar to download and cache.
TIKA_SERVER_ENDPOINT - set to the host (local or remote) for the running Tika server jar.
TIKA_CLIENT_ONLY - if set to True, then TIKA_SERVER_JAR is ignored, and relies on the value for TIKA_SERVER_ENDPOINT and treats Tika like a REST client.
TIKA_TRANSLATOR - set to the fully qualified class name (defaults to Lingo24) for the Tika translator implementation.
TIKA_SERVER_CLASSPATH - set to a string (delimited by ':' for each additional path) to prepend to the Tika server jar path.
TIKA_LOG_PATH - set to a directory with write permissions and the tika.log and tika-server.log files will be placed in this directory.
More information you can get here.

Running Java application on server

I have access to a server using SSH. I need to run a stand-alone Java application on it to access a MySQL server installed there. How do I go about in doing this?
Assuming you have the requirement to copy the JAR file on the *nix box and then run it(and not connect a Java process to it remotely)
Create a standalone JAR which contains all the dependencies required to run the application
Make sure you have Java installed on that machine
Assuming it's a *nix box, set the $PATH environment variable to point to $JAVA_HOME/bin
Log on to that box using a SSH client. Any decent SSH client also comes with a FTP plugin which allows you to transfer files between your local box and the server
Copy the JAR to the appropriate directory and run it using the java -jar your.jar command
Assuming it is a linux machine, you have to connect to by using SSH it and use scp command to upload the files and deploy it...
than you have to run the JAR you deployed:
java -jar /path/to/file.jar
Or, provide more details please

Categories