Deploy a Ninjaframework application on openshift - maven

Apologies for the vagueness of this question.
Is it possible or, how can a ninjaframework application be deployed on Openshift.
Basically, I have a Ninjaframework application running locally in superdev mode. I can even build a war file. However, when I push it to an Openshift git repository it simply doesn't work. Specifically, I get a vague "Oops. That's an internal server error and all we know." page when I try to access the site.
TBH, I'm not surprised. I need to somehow specify to Openshift how to build the application. I'm hoping this can be done by some Maven configurations etc. but I haven't the faintest idea how?
Any help or pointers very much appreciated.

Yep, cool, thanks guys. I'm afraid i was so clueless on how to do this that logs would only tell me what I already knew; that simply git committing a NinjaFramework application configured to build as a fat jar (by default per the archetype) was never going to work in a Tomcat application server. Apologies if that didn't come across in the question.
I expected some elaborate Maven stuff would be required but luckily I was wrong. It turns out that a simple Maven change was all that was required to have the application deployable in OpenShift (Tomcat 7).
I've outlined the steps here in tutorial form: http://outbottle.com/deploying-a-ninjaframework-application-on-openshift/

Related

Maven toolchain and heroku/cloud deployment

This is going to be a broad topic so please bear with me. So I build a microservices app started as a hobby and now in the few months I put into it I made something useful. So, far I used STS (spring tool) with maven and Eureka client.
I have an independent microservices talking to each other and a UI microservice that present the results to you. It's a single page app I will lay down the structure (GitHub repo also same) :
--my-app
--my-microservice-discovery
--my-microservice-domain (jdk12)
--my-microservice-searcher
--my-microservice-orchestrator
--my-microservice-ui
--my-transferobjects (common jar not microservice)
--pom.xml (my main module pom)
So, this is what I am dealing with in GitHub I made a single repository of my-app containing all these spring boot projects, in IDE everything works, now comes the deployment part on some cloud provider. I choose Heroku as I had some experience with it in the past but also because I cannot make this work with Google (although they have an attractive starter scheme going on right now). Connecting to a private GitHub repo from Google Cloud build is pain, but Heroku does this with style.
I decided to go command line because that's how I have to deal on the cloud and that's where all hell broke loose, I got lots of dependencies issues between the version of JDKs managed well by IDE but not defined correctly for maven yet.
I am still managed to make my local build success (command line) but I had to do some hard-code configuration to fix jdk12 for a my-microservice-domain pom like below and similar fix for my-transfer objects but because of the Lombok issue no idea why I have to provide jdk8 specifically for this project.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>12</source>
<target>12</target>
<executable>/home/Downloads/jdk-12</executable>
</configuration>
</plugin>
</plugins>
</build>
My questions are as follows :
Do we have a toolchain example to handle this different JDK compilation issue plus do we always have to provide the JDK local installation path?
How to deploy this on Heroku, how it will know where is my jdk12 is, or just defining the source/target version in pom will do the trick on the cloud, also Heroku supports jdk12 or google cloud?
Is it a good idea to have multi-repo or single repo deployment I can still change but I like it this way.
I get it that I need to create docker images for each of my microservices, but someone has a tutorial to do so locally first, or some GitHub repo so that I can look some examples.
Once I add all those docer files in each microservice is this sufficient to deploy its production level? I read a lot about APIGateway, load balancer .. where they fit into my architecture.
I also use localhost everywhere for EurekaServer and Eureka/Feign client properties will it also work the same way on the cloud and Eureka server will be able to find all my services as it does locally with no config changes needed on cloud?
What is better Google cloud or Heroku, google cloud seems a bit of a hassle for now.
These are my worries please advise.
Ok I am going to answer my own question I did bit of reading and what #cool suggested above and I ended up going multiple repository way and I achieved what was needed.
I also chosen Heroku simply because the ease of things there felt like my local environment and such a simple app like mine on latest binaries has no problem whatsoever.
I followed few links for setting up my Eureka server and client and Procfile and some environment variable direcrlt from your Apps settting page from dashboard.
Needless to say I also maintained multiple profiles (dev,prod,test) and for ui I use vaadin hence some additional step needed in your UI app pom.xml for production.
I am bit of concerned with the way my services were terminated of no activity on heroku plus right now the issue with services discovery among each other. So my eureka server reports > all instances but they cannot contact each other.
Right now I am busy with other things [viz. fixing bugs] as launch is a month later. I will soon post a question about this ;).

url after spring maven deployment

I have a basic question about deployment but I can't seem to find an answer on google...
I am working on a jakarta project and it's the first time I do the deployment.
Since I am using Spring-boot maven, I know there is an embedded tomcat that will launch with the jar.
My issue is, I don't know what url to use to check my project is working...
Before, I used the address http://localhost:9091/contextPath/endpoint, but now, I only get a whiteScreen...
So my question is, what url should I use ? Also, is there something else to do after packaging ?
Thank you for your answers.
EDIT:
Alright, so I tried actuator but that didn't help me...
With /actuator/mappings, I could see that my endpoints are correctly configured but when I use the executable jar, http://localhost:9091/contextPath/endpoint odes not work while it does if I compile with my IDE...
I don't know what url to connect to just to see the index... I'm using a very basic spring framework (boot and mvc) and my IDE is intellij community if this helps anyone
EDIT 2:
I tried to deploy the app on a local Tomcat9 to see if something would change but the connexion is reinitialized everytime I try to deploy a war using the manager, and there was no trace of error in the logs.
I tried using ./mvnw and it did work, endpoint and all, but it implies working with IDE environment
I tried using java (openjdk 13) and it compiled, but i couldn"t acces my own endpoint. I could still access the actuator endpoints so i don't know what to make of it.
Should the url be different depending on whether we are using IDE environment or just the jar?
EDIT 3:
Ok, I think have a lead but I have no idea how to resolve this:
when I began the web part of the application, I created a WEB-INF folder where I put all my jsp. My js and css files were in the resources/static folder. I tried once to put the jsp in the resources folder but it didn't work so I didn't push too hard.
Now, when I unzip the jar, i find my css and js files, but not my jsp.
When I unzip my war file, I have everything, but when I try to deploy it on a separate tomcat server, the connexion resets and I don't know why because nothing is written in the logs.
The issue then becomes:
Right now, I have
└──src
└──main
├──java
├──resources
| ├──static
| | ├──css
| | └──js
| └──template
└──webapp
└──WEB-INF
└──classes
└──jsp
What is the standard tree in intellij with jsp ?
By default Spring Boot apps are on port 8080.
Can you try http://localhost:8080?
Port can be changed in application.properties (or application.yml, application-profile.properties etc.) via server.port property (e.g. server.port=8888).
Ok, I managed to make it work.
I'm going to describe here everything of note that I encountered.
First, when I called my app to the usual url, there was no response (whiteLabel).
I added test logs and i found that I indeed called m controller.
I unzipped the jar and war i produced and came to the conclusion that the issue was architectural. I couldn't use jar, I had to use the war file.
I tried to deploy on a local tomcat server using the manager, but it always resetted the connection, so I took the manual approach - copy pasting the war file in the webapp directory.
Finally, the web pages were accessible in the browser.
Thank you for all the tips given during my research!
`http://endpoint:{PORT}/actuator/health` or `http://endpoint:{PORT}/actuator/status`
it should help but it must require spring-boot-actuator as a dependency in your pom/gradle file.

Can't get Netbeans Project to acknowledge existing Tomcat or Glassfish Server

I haven't been able to figure out what I'm missing here.
I've installed Tomcat and can spin it up fine. (Glassfish too, in my efforts, but I had removed it when I took the screenshot.)
So now I want to hook my project up to the Tomcat instance so I can have Netbeans deploy it for me automatically.
I right-click on my project, go down to Properties. In Project Properties I select 'Run' and go to the drop down to select my server. Only, there's no servers.
Why is it not showing up here? Am I going about this all wrong?
Thanks in advance for any help!
Other potentially useful notes:
* Using Gradle (for my first time)
* Using Spring Boot (for my first time)
* On Windows 10 (don't hate me, I don't love it either)
I was chasing the wrong problem. Spring-boot provides an embedded server so I had no need to install and provide my own.
My real problem was that I had dependencies declared for jpa, postgresql, etc. that I hadn't configured in application.properties. When I tried to run, I'd get an error saying "a problem occurred starting process /path/to/my/jdk/java.exe". I couldn't figure what was going on and, looking around, I saw the issue mentioned in my question about the server.
The solution was to simply comment out the dependencies in my build.gradle until I was ready for them. After I got my PostgreSQL DB set up and added the configureation to application.properties, I was able to un-comment them and it's working great.

Simple working Spring MVC / Maven configuration

I’ve been trying to set up a Spring MVC application from scratch, using Maven, in IntelliJ Idea. I know there are probably some nice Archetypes that can do this for you, but I really want to understand what’s going on. Here’s what I want to do:
Create a simple web application that shows displays “Hello World” under https://localhost:8080/, using an embedded Tomcat (with the Maven plugin). So, one controller, one request mapping, and one template. I’ve been able to get the spring application to boot (the Spring logo appears in the console) and Tomcat seems to run as well (the site responds). The problem is, I haven’t been able to get the request to map to my RequestMap method in my Controller. I’m quite sure that the controller isn’t the problem, but that it’s some configuration/setup issue.
Here’s the thing: I’ve been looking at tutorials, StackOverflow, Spring documentation, etc. for hours now, but I haven’t found a source that really explains how to configure a Spring MVC Maven project. Everyone seems to have a different opinion on what XML files you need, what they should be named, and where they should be located. The consensus seems to be that you need a web.xml file in a folder named WEB-INF, but even there, everyone has a different opinion on where that folder should go. I appreciate that there are multiple different ways to do this, and that there’s no “right” way, but in my experience, there are definitely many “wrong” ways =).
My question right now isn’t necessarily how to get my current project running (I don’t mind starting over), but what kinds of config files are out there (web, spring, app-config, servlet, …), what they do, which ones you need, where they need to go, what they should be named, how they connect, etc. Some people also use the Maven Compiler plugin, and others don’t, and nobody says why :D. Essentially: How do I let Spring know where to find controllers, templates, etc., and how to run and deploy all of this on the embedded Tomcat. I would like to find a source that explains the entire core-ecosystem of Spring MVC in a unified way. I have found many sources that provide “how-to” tutorials, but with little to no explanation (like “add the following servlet.xml file to your WEB-INF folder”). So, if your setup slightly differs from the tutorial (e.g. because you are using IntelliJ instead of Eclipse, Tomcat instead of Jetty, embedded Tomcat, a slightly different folder structure) nothing works, and, most importantly, you have no clue why.
Has anyone learned these setup-basics with anything better than copy/pasting or trial & error? :D
Easiest way to start is by using Spring Boot. Go to following link:
Spring initializr
Choose "Web" for "Selected Dependencise" and click "Generate Project". Download of maven project should start after that. Then import that project in IntelliJ IDEA as a Maven project. And that is a good starting point. You'll get main class that you can run and embeded Tomcat will start at 8080 port. Than you can add some controller, template etc...
Also good guides

Tapestry class loader with Tomcat and maven

Is it possible to integrate tapestry for class loading only under tomcat7 and eclipce, if so, how?
I am interesting in that for making java development alot faster.
My project is consists of:
Spring MVC+JSP
Maven
String Security
Mysql
Hibernate
log4j
Tomcat7
Eclipse
helios
ExtJs
I am looking for a stuation where I can save the java file and refresh the browser for seeing results/changes. (Like Jrebel).
Thanks
someone on the mailing list says it's possible, however i haven't gotten it to work 100%. You need to figure out how to point tomcat to various locations to find resources and not copy resources and libraries into the webroot folder. try asking on the mailing list for more instructions.
You need to use Jetty + tapestry for it. And use tomcat7 only to production and tests.
Absolutely it's possible and it works well. We (at tynamo.org) have a whole guide available for using Maven, Eclipse, Tomcat7 and Tapestry together, just follow the steps. Tomcat7 is easily as fast, perhaps faster starting up than Jetty.

Resources