How to activate the built-in HTTP Server in a Java Web-App Module?


I have a project that uses server side CDI beans, Servlets and a JAX-RS interface, in combination with an AngularJS SPA front-end, all deployed in a single WAR file. 

I have mocked all the REST services with Angular's $httpBackend, so I can work on the client side stuff without the Server running, and I can also auto-deploy to JBoss as an exploded WAR and work on the server with the real back-end.   So far so good.

My issue is in this:  
- If I select "Static Web" when creating the new Module, I get the built-in HTTP Server in IDEA, which allows me to run all my Angular and static web stuff.  Using "Open in Browser" on my SPA index.html opens a browser with a URL that starts with "http://localhost:63342/...", which means the mocked client-side application works - it's all being served by the same embedded web server.  But then I don't get the Java Facets on the module, which I need.
- On the other hand, if I select Java|Web Application etc when creating the module, I don't get the built-in HTTP Server.  "Open in Browser" starts a browser with a URL that starts with "file:///C:/...", and my client-side Angular application fails with "Cross origin requests are only supported for HTTP".  The embedded server doesn't seem to be running.  

So my question is how do I activate the built-in HTTP Server in a Java/WebApp module?  Any hints?

Thanks very much,

Adam Crowther

Please sign in to leave a comment.