How to host Spring Boot Application on Web Hosting Server - java

I know this question might sound stupid but for me it's new. I have developed a simple Spring Boot Application, provide some backend APIs, running on localhost. I have also bought an webhosting server with my own domain, let's say: www.my-domain.com. Right now in the my-domain.com I just have some simple html code. And what I want to do is having the spring boot application running also under this domain.
Is it possible then? If yes can anyone point me to some references please?. If no, what do I need to run an Java Application under my own domain?
Thank you very much!

You need to run the Spring boot application on the server, then you need to configure your web server (nginx/apache), configure Spring API path and port on the web server, and the traffic will go into your application.

Related

Spring boot security (embedded vs external)

I know by default Spring boot produces a fat Jar file which incorporates an embedded server but when it comes down to security is there any flaws using an embedded server compare to launching your spring application to an existing server like tomcat. Is the jar or war more secure ?
Tried looking it up but I’ve seen a post explaining some pros and cons to using an embedded server vs an existing application server but I lost that post I need more insight please help. I know using embedded is quick and less work on configuration but is it more secure to deploying to an existing tomcat server or jboss instead of using spring default embedded server please help me so I don’t make mistakes when making a large app

Connecting to windows server from PCF

I came across a very different requirement today where the Application running in PCF has to connect to Windows-Server and execute some business logics.
Currently the teams are achieving it using VB-Script. The command looks something like this
Dim computerToConnect As New System.DirectoryServices.DirectoryEntry("WinNT://" + Server + ",computer")
The same functionality the teams are trying to achieve through a spring-boot app running in PCF Linux stack.
Is there a way to achieve this in Java ?
Answering your question:
Yes, it is possible to connect into Windows Server from Spring Boot.
You can start from:
Investigate better what you really need to do inside the Windows Server, to understand how you can translate it in Java/Spring code;
Investigate what kind of authentication your company use in the Windows Server;
For example, if your company use LDAP/OpenLDAP, you need to learn how to connect from Spring Boot app into Windows Server using this kind of authentication;
Configure your Spring Boot app with the credentials to handle the authentication;
After authenticate, consume the resources you want, similar to VB-Script.

Configuring Java Client for Hazelcast

I am trying to configure a JAVA client for Hazelcast. I have a web application deployed on tomcat servers. The example that I am following is this
Basic Clients Hazelcast. I have copied the code into my local machine and when I simply run it without running anything else and without the addAddress() step I get a java.net.ConnectionException. My doubts are:
1) What is the client in this case (I am assuming it is the web application that probably means I have to get the Hazelcast server up and running then what is to be done)?
2) How do I establish a link between the web app, the tomcat server and hazelcast cluster? The web app uses MongoDB as the backend. I was able to do a only MongoDB with Hazelcast integration but not the web app on tomcat server integration. What role does tomcat play here in this setup?
3) In the example what are the start.sh and stop.sh supposed to do? Where should I run them? If I simply open the git bash and run it. It doesn't seem to work.
I have looked at the documentation provided in the Hazelcast manual but I wasn't able to understand it as my current level of knowledge is woefully inadequate. If somebody could explain it to me or paste the links to some of the obvious stuff that I should know it would be great.
The answers are inline:
What is the client in this case(I am assuming it is the web
application that probably means I have to get the Hazelcast server up
and running then what is to be done)
The web application can be a Hazelcast client if you would like to use Hazelcast in client-server topology.
How do I establish a link between the web app, the tomcat server and
hazelcast cluster. The web app uses MongoDB as the backend. I was able
to do a only MongoDB with Hazelcast integration but not the web app on
tomcat server integration. What role does tomcat play here in this
setup.
Your web app runs in Tomcat server (web container) and the Hazelcast client you use in your web app can directly connect to the Hazelcast cluster members (server). You will just need to configure your client properly such as adding cluster member address by using clientConfig.getNetworkConfig().addAddress() API. Please see for more details about configuring client in this link: http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#configuring-java-client
In the example what are the start.sh and stop.sh supposed to do.
Where should I run them. If I simply open the git bash and run it. It
doesnt seem to work.
Those are sample start scripts for the sample client and member application. You don't need to use them in your application.
Please see the following guides for using Hazelcast in client-server topology:
https://hazelcast.org/getting-started-with-hazelcast/
http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#getting-started-with-java-client

Developing app with web and Android client with Java

I'm going to start developing a new simple "X management" kind app, like contact management or events management. What I want to know is which tools would be the best to achieve it in the way I want.
My app needs to be a web app running on a server that has a mysql database to save and retrieve some simple information. This app must have a web client but I want it to be able to be extended to work with an Android app client.
Things I've thought:
I've worked on Java with facelets and JPA travels management app running on a GlassFish server on localhost with a JSF web view, so maybe my web client and the full app could be done with this.
I've worked with web services such as SOAP and REST with Jaxb and xml schemes to retrieve information parsing some webs into xml or json to show on a client .net app. So I've thought I can add to my app, like last topic we talked about, a REST web service layer to easily work as I want, or at least I think it would be easy. If I do this the Android app could share the same app core code but using the REST service.
My question is what could be the best way to do an app with 2 client side in different platforms that could share some code to be easy to extend it moreover to a desktop app. I've talked about these 2 options because I'm a students of computers at university and those are the tools I know, but I can easy learn more. I've also think about just a REST service and create a web and an Android client to work on same service or something like that.
This post is getting long, so here is the summary: What technologies and tools do you think are the best choice to create an java web app that needs to have web and Android client? Also what server, like tomcat, GlassFish or another, should I use? And what about persistence layer? JPA with mysql is the best I know to work with.
Thanks a lot.
P.D: I work with eclipse
From my point of view:
You can use java jersey and java spring both ( java spring as Dependency injection) for creating RESTful Web service. So, In server side you will create endpoint and you can access data from any platform through those endpoint.
Server can be anyone. It's up to you. I always try to use tomcat but tomcat is not a full JavaEE container it's only a servlet container. So if you want to use full JavaEE version then you should use Glassfish.
And yes JPA .It can be easily used in any environment supporting JPA including Java SE applications, Java EE application servers, Enterprise OSGi containers etc.
On the other hand, still choice is yours.

Deploy Java restful web service to live server

I have just learned to create java rest API using jersey and Oracle database.
I'm developing in eclipse and using weblogic server to run and test web service on localhost.
My question is what are the options of live servers to deploy this service so that I can access this API in my android application or any web application???
You can do that. But you have to make sure that all the dependent jars are packaged with the your WAR project(eg; Oracle db related things).
Some blog entries which give you an idea about what are all these servers and which one to pick for open development and common standards - http://blogs.forrester.com/mike_gualtieri/11-07-15-stop_wasting_money_on_weblogic_websphere_and_jboss_application_servers,
and this one http://zeroturnaround.com/rebellabs/the-great-java-application-server-debate-with-tomcat-jboss-glassfish-jetty-and-liberty-profile/
This will give pretty good idea about what is all these servers :)

Categories

Resources