I was able to create a JAVA Rest API Web Service using SpringBoot. How do I deploy it so not only my localhost can access it but other computers in the private LAN as well.
I dont want to officialy publish it outside. Is Glassfish the tool for this?
I want to have an endpoint like
https://privatewebservice.net/api/
in the private network that other people can use.
Thanks.
Deploy the rest on your tomcat server on port 80 and in other PCs in the private LANs update host file for privatewebservice.net to point to your PC's IP in the LAN
It needs to run an a servlet container(aka web server). There are many; Jetty, Tomcat, Glassfish etc. That servlet container will start and host your application and make it available via it's port(s).
You can run this process on any physical or virtual machine that is visible on your LAN. You could even use your own machine for this if it's visible to your LAN (barring firewall/network rules blocking the traffic).
To make it available to your LAN from your machine, find your machines internal LAN IP address (run ifconfig on Linux or ipconfig on Windows) and try accessing the app via that IP from your browser. If other machines on your LAN can see your machine, they should be able to access it too via that IP address (likely you will also have an internal DNS name for your machine which would be cleaner to use in case your IP address changes).
Obviously that's only good for development and testing. Generally for internal hosted applications for your company you would have a machine running somewhere that you could deploy the app to to make it accessible by others on your LAN.
It's worth noting that Spring Boot by default comes with an embedded server/servlet container. By default this is Tomcat, but can be changed to say Jetty, via configuration and changing default dependencies in your maven POM file or Gradle build file. The default will be fine unless you have some specific reason to change it.
To use this embedded server, use one of either Maven or Gradle Spring Boot plugins which will provide a set of tasks that can be used to build an executable Java jar file for the application that will run the application on the embedded server, and the application within it. This can then be run with something like java -jar myapp.jar
Technically speaking this would probably be the easiest way to deploy the application. With the only major requirement on the machine you are deploying to being a compatible version of Java. Although I'd recommend wrapping that app in a Docker image that already has Java on it and use Docker to run the docker image as a container. This means your applications' dependencies(including Java and it's specific version) are housed within the docker image/container and also means the machine that will run the app could host many different applications resource efficiently(RAM, CPU etc), with each managing their own dependencies. The machine hosting the app would then just need Docker installed on it, and doesn't get polluted with any other applications dependencies.
follow this step :
1- generate a war file of your Spring-boot project API - see here how to do
2- deploy it on tomcat server see here how to do
3- replace your localhost with your #adress ip (where the server is on and where the project is deployed)
Related
I have made a small .NET Core REST API which I would like to be able to easily put on a Linux server running a Java app on Tomcat. Can one use Docker to ease the deployment of the .NET tool, and if so, how is it done? I was told by someone that Docker would (more or less) allow me to bundle the API as a single app/file without having to bother too much about deployment policies at the place I am working (which by default only allows for Java apps to Bd deployed).
You can use a docker image like e.g. microsoft/dotnet to run your app in a docker container. Please read the documentation on the linked page on how to run your app inside the container.
If you then map an exposed port (443, 80, 8080... depends on you app) using the -p option on container startup you can then access the REST endpoints from any software you like because it is basically behaving like an other REST server running on that host. Since you want to run tomcat in parallel you should avoid to map the port from the container to 8080 on you host, thought! Other than that this setup is totally independent from the application server running on the host itself.
I have created a java application in intellij ide. The application is working well. Now that my application is ready I want to transfer my java application from my machine to server and make it live. I have one server, domain and all the basic rights in the server. Can any one help me figuring out?
I am very new in this part. I dont know anything about hosting my own website and application.
The answer depends on what technology you use. If you use application that needs to be deploy into servlet container you can deploy it onto e.g. Tomcat.
Whatever technology you use you definiately should build your application - it also depends on what building system you use.
E.g.fFor gradle, you can use gradlew build.
For maven: mvn compile.
Tell us more details about technology you use to allow us to help you.
You have a java application (Dropwizard) and first need a server to run it on, which means that it must be a server with java installed or where you can install it yourself.
Then you need to transfer the application "fat" jar (typically you find this in the target directory, depending on how you built it) to this server and start it with java -jar my-application.jar.
Then you need to make sure that the port that the application runs on is available externally. This usually means that you need to have a web server installed (commonly nginx or httpd) which redirects from port 80 or 443 to the port of your application.
Only then is you app "live".
In the past when a new webapp or set of services was to be deployed, it was common practice to be given a new vm with tomcat installed on to deploy to. With my current position the client is only giving me one linux instance to deploy several webapps to. (Small internal usage, 0 scaling. Deploying to a single AWS EC2 linux machine)
The applications are required to be given unique domains. ie app1 and app2 could be mapped to smallapp1.com:8080/app1/login and smallerapp2.com:8080/app2/login (ports are for example only and not a requirement)
I currently have two installations of tomcat8 running on the instance and each application is deployed to a unique tomcat install and running on different ports. (one is 8080 and the other 8081).
If I were to want to deploy a handful of other small applications would I be better off using individual tomcat installations or should I be using Virtual Hosting?
I am new to deployment. In the past I was handed a deployment destination and procedure. In the new position I was simply given credentials to a single instance. I am not sure what is better practice or in which situation which is better than another. If it matters, each application is only ever going to be used by a maximum of 20 users at the same time.
TL;DR Using multiple installations of tomcat on the same instance or using the same tomcat installation to host multiple applications.
Virtualhosts is a better option because you are not bloating the server with several installations that could conflict with each other, and you are to take 1 port for each instance of tomcat.
Keep in mind that tomcat is a better solution for Java web applications, if you are not running servlets or JSPs you are better off using Apache Http server.
I am trying to deploy a JSP/servlet onto a server. Not tomcat but on a real web domain. This is my first time doing so and so far I exported it into a war file and placed the file onto the server. Nothing happened which is why I am here. All the google searches seem to concentrate on Tomcat which I have already ran the project on. Advice?
Ok, let's get really basic. You want to see the compiled JSP in a browser, through some public URL, right?
First, find a place to host your application. You can try Digital Ocean (starts at $5/mo), EATJ (free version available), Amazon AWS (free trial available), OpenShift (free gears available), your own computer with dynamic DNS, or many other options available through Google.
Next, you packed your compiled code to a war file. That war file needs to be unpacked (deployed) using some software.
There are numerous ways to handle this (Tomcat, Jetty, Glassfish, etc.). They all have their pros and cons. Pick one and learn the very basics. Tomcat doesn't require a separate web server but you can set one up with it if you like. At this stage, I would keep it simple and not do that yet.
Lastly, set up GoDaddy (or whomever you used to get your URL) to point to the IP address of that server. If your server is running and enough time has passed for the changes to propagate, you should see your page.
There are plenty other J2EE server for example, JBoss and Glassfish. Each one has it's own way to deploy your war files. For example, Glassfish is throught a web administration console (https://docs.oracle.com/cd/E19798-01/821-1757/6nmni99aj/index.html) and in JBoss you need to deploy the war file in a specific directory (http://docs.jboss.org/jbossweb/3.0.x/deployer-howto.html).
It depends on which J2EE server you are using.
Now if you want to get your own server and configure it:
Get the server or VPS
Install JAVA
Install Apache
Install a J2EE server (I prefer glassfish)
Configure glassfish with apache (http://www.codefactorycr.com/glassfish-behind-apache.html) to use apache in front of glassfish
You may want to block the ports 4848 and 8080 used by glassfish
Deploy your webapp
Have fun!!!
PS: I'm assuming you have root access to the server
Easy Apache Tomcat 7 install after,
Run Code via SSH:
/usr/local/cpanel/scripts/addservlets2 --domain=domain.com
For Linux.
I have created a web service using Netbeans in Fedora which is working fine in local host. But I want to deploy client on different computer and server on different computer.
I could also connect two Fedora systems using a LAN cable(SSH), but could not access the web service.
What is the procedure to deploy it? Does a webDav-http service connection be established? If so how to do that?
To deploy your project in a different machine, compile it, and the copy the war file to the application server you desire. I use Tomcat, just need to copy the war to the webapp folder, you should have something like in glassfish.
About the clients:
What are you using to generate the client? I assume metro, since is the default in netbeans.
Create a new java project;
Add new, Web Service Client;
Create it from the url: something like http://example.com.someService?wsdl.
Changing the ip you change the machine that this client will communicate to.