0

I am currently working on a Java based Maven project that has a REST backend module and using angular JS as a frontend that uses the backend for data. The 2 modules are named "rest" and "web" accordingly and are deployed as 2 separate war files to a glassfish instance during development. The glassfish is on a different machine.

My problem is that this is kind of slow, especially when developing the angular based frontend. Fix a minor spelling mistake, package, redeploy. Not that slow but every character change or fiddling with angular is another 20-30 seconds lost.

One thing I tried is to directly load the files from the source directory into the browser with file:// tag. This is OK as long as it tries to call the REST backend which fails due to CORS (I don't remember the exact error message, it just doesn't work). This happens a lot so it's a no-go.

I'm open to every kind of solution to develop angular in a way that I could see my changes instantly instead of deploying it every time? Much like the guy does in the egghead videos.

1 Answer 1

1

I would recommend breaking your Angular JS application into its own separate project, this would be a new HTML5 project on Netbeans. That way you can focus on pure backend and frontend development in their respective projects and you do not have to manually separate the war files. This link will help you to get CORS working if you are defining your RESTFUL services with Jersey Access-Control-Allow-Origin in ajax call to jersey rest web services. Or you can just mock the data out in the front end project.

Front End Run Configuration

Sign up to request clarification or add additional context in comments.

3 Comments

I definitely want to avoid mocking data. I added the CORS filter to my REST project and deployed it but if I want to use the angular project from my browser by directly(!) loading the files from the source folder via file:// then it still fails. Error in browser console: XMLHttpRequest cannot load file:///home/sloby/projects/project/java/web/src/main/webapp/template/profile_menu.html. Cross origin requests are only supported for HTTP. This is referring to a template file for my ui-router. Any suggestions?
You should not have to reference the files directly in the browser. If you put the front end in its own project you can use your glassfish container or if you are using Netbeans the embedded lightweight server. That way the code is actually deployed and can do http requests but you do not have to keep restarting the server if you make simple html or javascript changes. Once everything is working correctly localhost:port/home/sloby/projects/project/java/web/src/main/webapp/template/profile_me‌​nu.html will work and your HTTP requests should fire. I edited my answer to show my configuration.
Although I'm using IntelliJ Idea and it took a while to do it, you pointed me to the right direction, so thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.