how can i deploy the jar file in remote server - java

In my local machine, i just running the java application in eclipse and working perfectly.
But in my staging machine, i have a spring boot application and running in the centos server, which i am accessing by putty
when i tried running the command
> mvn clean package -DskipTests
after the above step, what the next step, i need to do
Actually i did was,
nohup java -jar target/cs.jar &
so that, jar was created in the target folder. Then when i tried to hit the endpoint from the postman its not working

As you said there might be some internet issue on the Staging Server. Maven may try to get dependencies from internet, but since it is not able to get to internet it is hanging.
Can you try to use following command on your linux server
$wget http://www.google.com
if it works correctly then you know that internet is there on that machine. Your maven should work then .
If not then, I would suggest build the whole thing on your local and transfer the build files to the server. In the server you can just execute
$ java -jar target/myproject-0.0.1-SNAPSHOT.jar
I am assuming that you can package the whole application in a jar file.
To move the jar file from windows machine to server machine you can use winscp tool.

Related

Can't load main class JUnitStarter when running tests on remote host via SSH on Intellij

I'm wanting to run tests on another more powerful machine to speed up testing time, so I've created a run configuration on Intellij which targets my Ubuntu machine rather than my local one.
If I don't use rsync to copy the files to the remote target, the tests all work fine, however when I enable rsync in IntelliJ, I get the following exception when the tests attempt to start:
Error: Could not find or load main class com.intellij.rt.junit.JUnitStarter
Caused by: java.lang.ClassNotFoundException: com.intellij.rt.junit.JUnitStarter
Process finished with exit code 1
Although I could run without rsync enabled, the copy process to the remote host takes longer than running the tests on my local machine.
For context, my local machine is running Windows 10, and my remote machine is running Ubuntu 20.04.
Thanks in advance!
EDIT:
After doing a bit more digging, I found that rsync is copying files in the maven repository and Intellij Ultimate folder using the MS-DOS file structure style. This means that as part of the copy, it's using backslashes instead of forward slashes resulting in linux thinking it's part of the name of the .jar file. In result, it means that the copied maven repository folder is in the wrong file structure:
Changing the file structure manually fixed the issue and tests run successfully however it's just a work around and doesn't directly fix the problem but at least points in the right direction.
This is a bug: https://youtrack.jetbrains.com/issue/IDEA-270106
Will be helpful if you can vote for it and attach idea logs there

Deploying scala and java springboot project on ubuntu server

My question is about deploying a project written in scala and java with springboot as backend. First I tried to build it with IDEA as .war file and put it under
my-tomcat-dir/webapps/
on my Ubuntu 18.04 server. When I run it with
sh my-tomcat-dir/bin/catalina.sh run
it just seems well, however it didn't respond to any request from my frontend application and there is no any errors log in my terminal screen. So I tried to build the project on my Ubuntu server. First I upload my project files to the server and run
sbt assembly
in the project directory, later I run
sbt package
and got a .war file. Again I put the file under
my-tomcat-dir/webapps/
and it just got the same result as before. How can I get this project built and run well under this situation? Any further information please inform me to provide, thanks!

Jenkins hosted on Windows OS to run shell scripts after build

I am trying to run a jenkins job which has a post deployment activity of running a few shell script commands. Jenkins is hosted on a windows OS. Can anyone tell me how Jenkins can connect to the Solaris environment on another machine and execute the shell script? Is this possible?
I am trying to build a Java WAR file on windows and then deploy it on tomcat on Solaris machine.
The WAR file is built. I need to write a shell script to copy that WAR file to Solaris machine.
Does anyone know how to integrate https://wiki.jenkins-
ci.org/display/JENKINS/XShell+Plugin
I suggest you use Artifact Deployer. It can copy files to a remote location and it does support Windows.
To answer your original question, yes, Jenkins can execute shell scripts on remote hosts. The most straightforward method that comes to mind is the Jenkins SSH Plugin, or the Jenkins Publish Over SSH Plugin. Either of those plugins will allow you to execute arbitrary commands over Secure Shell (SSH) to a host that supports SSH (like Solaris).
For your specific use case, however, it may be better to use a more specialized development plugin, such as the Deploy Plugin. Especially if you're using Maven to build your project in Jenkins, Apache publishes a Maven plugin that can automate deployment to Tomcat.

Making a java project, using MongoDB, run on remote server (ssh)

I'm trying to make a java project run on a remote server.
I've used Maven and the project uses a Mongo database. I've got access to a home directory on a remote web server. MongoDB, Tomcat and java are installed so the only thing I have to do is to transfer my Mongo Database and my project and making this all work and run.
However, I'm new to all this and I've got no clue in how to do this. I also can't find anything online on how to archieve this.
How would I go about doing this via SSH?
Additional info:
My project includes:
.js files
.java files
.html files
1 main java class which should run constantly
Actually if you are new for this kind of development, (actually it is more about deployment so popular tag DEVOPS anyway...) take it easy so use your application server and database in the same machine(which is not a suggested way for large systems).
Step 1 For ssh you need to create key read this document and create a key
Step 2 Make a ssh connection to your remote machine like
ssh username#yourIp
it will ask a password enter the password which is given by you when creating the SSH key.
Step 3 Install Mongo DB, Maven, Tomcat, Java to your remote machine.
Step 4 Copy your war to under remote machine webapps
Secure Copy war to remote machine
scp -vC ~/.m2/repository/com/foo/Example/foo.war username#yourIp:/home/Development/tomcat/webapps
echo "Copy to server"
Step 5 Run tomcat server Go to tomcat/bin directory run startup.sh
/tomcat/bin/startup.sh

Executable jar file won't run on centOS

I want to execute a little java program I wrote on my server running centOS and having the jdk1.7.0_10 running.
When logging onto the server with PuTTy, i navigate into the folder containing my eclipse generated runnable jar file jbtct.jar and try to launch it using the Command java -jar jbtct.jar.
But instead of launching, my putty session would just get stuck with nothing happening and The log files my Program should create won't come up as well.
I have a tomcat with applications running on the same server working quite well, so I guess it's some kind of config error. But what kind?
Alright, I solved the Problem! Eclipse may generated the runnable jar, but the Manifest files weren't set up properly as I was using maven to manage my dependencies.
The Solution was to add some code to the plugin management as described here (Posted by mike)

Categories