How to make requests to Payara Micro using API? - payara

I am trying to complete a test case that deploys a war and makes some REST requests.
I want to use Payara Micro JAVA API and I've had a good start with setting up a boostrap
bootStrap = PayaraMicro.getInstance().setHttpPort(6060).bootStrap();
... and deploying my war
bootStrap.deploy(new File("{path}"));
My war deploys correctly.
Where do I go from here? Where do I point my requests to?

The context path is the same as the name of the WAR you've deployed. (See example cURL in this README)
So if you are deploying my-war.war with your settings above, then you would go to:
http://127.0.0.1:6060/my-war

OK so I was able to setup up a standard javax.ws.rs.client.WebTarget and Client and make regular requests after all.
It's nice to be able to design system test in JUnit. Payara rocks ;)

Related

Redeploying OpenAPI spec into App Engine standard environment

When I do some changes in OpenAPI spec, which don't involve any changes in the code, do I need to redeploy the code along with the new specification?
When I deploy OpenAPI spec with gcloud service-management deploy command I get back in it's output new service configuration version, which I should set to the ENDPOINTS_SERVICE_VERSION parameter in the app.yaml file.
I'm not sure but it looks like I have to redeploy the app every time I deploy a new version of my OpenAPI spec, even when the application code doesn't change I still need to point it to the right service configuration version with the new ENDPOINTS_SERVICE_VERSION value, is that right?
If so, then it's different from what is described in the How API Deployment Works document for AE flex environment under the "Redeployment" section, where it says the following:
You can use the gcloud service-management deploy command to update
just the API specification without redeploying your backend API server
code or the Extensible Service Proxy. This is useful if you are
changing a configuration-only detail.
When you change the API specification, the Service Control API backing
your running service instances will pick up the change because as it
depends on the same service configuration.
Maybe someone could help to clarify how exactly it works in case of AE standard environment?
Are you using the Endpoints Frameworks? If so, then you will have to deploy the app when you make a new service config version, because, as you mentioned, the app.yaml specifies which service config to use.

Embedding jetty for Apache camel

I have a file transfer routing developed in Apache camel. I want to embed Jetty server into this project so that i can keep the service running without deploying it to another server. It will be really helpful if someone can put some code.
Thank You.
You should use Camel's Jetty component and declare a consumer, which will automatically bring up an embedded Jetty:
from("jetty:http://localhost:{{port}}/myapp/myservice")
.process(new MyProcessor());
You have 2 options, they are quite popular:
Use maven camel:run plugin, you have to just enable this in your pom file and run the command. (I am not too sure whether they use Jetty internally, but it works)
Spring boot, Its quite easy to create a project nowadays, using the web portal.
There is one more maven plugin as well for Jetty , which is mvn jetty:run

What is the actual advantage of running an AngularJS web app over Node.js instead of a server like Xampp?

As stated in the title,
I don't really understand how Node.js works and above all why it's actually used to run an AngularJS application (e.g. in WebStorm IDE this is the default option when you create an AngJS project).
I've got this doubt since I could run a simple AngularJS app on an Apache web server (within Xampp) without any involvement of NodeJS.
Thank you in advance
Node.js is an application platform. It's good for running your applications on.
Apache HTTPD is a web server. It's good at serving web pages.
They're two very different things, not directly related, and not mutually exclusive.
You are correct that many apps can run anywhere, but some benefits we've seen are:
Simplicity, especially for web developer also developing the server-side code/config/deploy.
Real-time web - easier to add in things like WebSockets and Server Sent Events if you need them.

Hosting Angular fullstack project

I started a new Yeoman angular-fullstack project (client-angular.js, server-node.js)
(generator: https://github.com/DaftMonk/generator-angular-fullstack)
I have 2 seperated directories for client and server,
I want to launch the app but the deployment don't show any index.html file,
The question is, Should I make 2 different hosts for the server and the client?
if no, how can I host and use the united projects?
No, it is not needed to create 2 different hosts for the server.
The server needs to point to app.js, usually located at server/app.js, as this is the entry point (instead of index.html) of your app. How this is done depends solely on the server you intend on using.
If you consider using IIS you can take a look at: Installing and Running node.js applications within IIS on Windows
As for the other deployment options, as laggingreflex said, "Heroku is the popular choice to host node.js projects". The angular-fullstack git site has more information on deploying to Heroku or Openshift.
As a side note:
Deploying to IIS requires a bit more attention than the information in the link specified. You need to set file access, create a web.config file as well as a few other stuff. At least, I had to...
You'll need a host that supports MongoDB assuming you kept the Database the same after generating your application. Heroku is a great option as it allows you to setup up plugins like mongolab or mongohq fairly easily. I would also recommend looking into Digital Ocean as they allow you to set up a droplet/server that has what you need for the application to run.
If you go with Digital Ocean and are a student check out https://education.github.com/pack. You'll actually receive $100 credit towards a new Digital Ocean account which will let you test things out.
Good luck!

How can I turn an Eclipse GWT/GAE app into an Eclipse Tomcat/mySQL app?

Sorry in advance for the long post but the problem I am facing here is quite crucial for me, so here we go...
I have a Eclipse GWT (2.0) Web Application using the the GAE and making transactions with its datastore.
On the other hand I would like to make sure that I can also deploy this web application on another infrastructure than the Google App Engine. Therefore I wanted to debug my web app using another servlet container (Tomcat 6) and another datastore (mySQL or MSSQL or any other, it doesn't really matter for now.)
In order to be able to debug an Eclipse web app with Tomcat it has to carry the Dynamic Web Project facet. If it doesn't then the new server that I add to Eclipse within Servers refuses to pick my GWT module in its list of supported apps. And not only GWT Web Apps don't carry it, but they don't even allow to alter the project's facets at all!
However, I found that adding the few relevant tags to the .project file can make it eligible within Eclipse to allow new project facets additions. Here are the tags I used:
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.google.appengine.eclipse.core.gaeNature</nature>
So I did that, I could "turn" the project into an Eclipse's Dynamic Web Project and by doing so made it compliant to be added to the list of modules handled by - let's say - Tomcat 6 within Servers.
So that is exactly what I wanted, I can now switch between two debug configurations at will in Eclipse in order to debug my GWT web app either on the App Engine or on Tomcat.
The problem is that adding the Dynamic Web Project facet disturbs the DataNucleus enhancer. For some reason, once the project has become a Dynamic Web Project, it seems that the enhancer is never called anymore and I get this error message saying that some classes haven't been enhanced. Playing with the Google... App Engine... ORM classes or checking/unchecking the Enhancer in Builders wouldn't change anything. Please note that the enhancer issue affects both debug configurations: Tomcat as well as the App Engine.
So I was thinking of two solutions.
(1) Disable the Google plugin's DataNucleus enhancer and perform the enhancements myself. So I installed the DataNucleus plugin to configure project specific enhancements by following their guide about the Eclipse plugin.
They say that by right-clicking on the project one can activate DataNucleus support for the given project's files. Unfortunately, after installing the latest version of their plugin for Eclipse, no such right-click menu appears! I have therefore no way to tell their plugin that I want to activate the enhancements on a given project! How frustrating is that?? (I uninstalled/reinstalled the plugin, let perform plenty of pending Eclipse updates... but still no right-click menu.)
Does anyone know of another way to activate DataNucleus enhancement? For now I would be happy even with a pretty manual trick as it is very critical for me to be able to perform this cross-servlet container debugging within Eclipse.
(2) Use this tip from the official GWT website http://code.google.com/webtoolkit/doc/latest/FAQ_DebuggingAndCompiling.html#How_do_I_use_my_own_server_in_hosted_mode_instead_of_GWT%27s
Ok that works, and for now let's say that it saves my life BUT... it requires hosted mode and therefore doesn't allow the use of GWT 2.0.
So regarding this workaround I would like to know if there is a way to do something similar under GWT 2.0?
Turning the GWT Web App into a Eclipse Dynamic Web Project would be the ideal solution for pursuing the development of my application. As I said above, that way, it is very convenient to switch from the App Engine to Tomcat and vice versa. So I favour workaround (1) over workaround (2). But anyway, some help or piece of advice regarding any of the two points will be very very welcome.
Thank you for reading this very long post!
I always use Google Plugin (GPE) for GWT development even when I deploy to Tomcat, where I simply disable GAE option.
Perhaps, I don't understand the question - but I have had no problems debugging my app running on jetty and then transferring the app to Tomcat. Are there any issues that I need to learn?
In fact, even when my app is plain jsp or servlets, without any GWT, I still used GPE. But GPE would refuse to run jetty without either GWT or GAE enabled. So I simply create a dummy GWT app. In all my years, I had never had to worry about differences between jetty and tomcat. And if I had to write an app where I had to exploit the differences in tomcat over jetty, I would consider myself a lousy programmer.
The only reason I see to push JEE server into an external server, is for profiling the app as it runs on tomcat.
JEE is JEE, whether Tomcat or Jetty. I have heard that some people have a bias against using Jetty, like preferring starbucks over neighbourhood cafe. Coffee is coffee.
I don't understand. May be you could write another thesis to explain why you cannot debug on jetty and then deploy on tomcat.
I ran into the exact same problem, I could edit the properties of my project and see the datanucleus menu in the context so the plugin was definitely working. My issue was I was using the "Java EE" perspective in eclipse. (Juno btw). I switched to the "Java" context and my datanucleus menu was back and I was able to enable support and enable automatic enhancement.
Window -> Show perspective -> Other -> Java

Resources