In this lab, you will create a new Intellij IDEA project and save/commit/push it as a sub-folder in your course repo for this unit.
Follow the instructions in the Jetbrains/Intellij J2EE application tutorial, which bundles the Web and EJB
Run the Intellij IDEA J2EE tutorial: Developing a Java EE Application. Note the following as you go
through the tutorial sections, saving answers to the questions in a notes.txt
file in the root of your new project structure.
Before you start — The lab has all the tools required for the tutorial.
C:\Program Files\Java\jdk1.8.build#
C:\glassfish-4.1-web\glassfish4
Creating a Project — Name your project Lab11
and store it
in your class repo under cs342/11postrelational/Lab11/.
This allows you to commit/push the full application as part of your course repo
but also edit it individually using Intellij IDEA.
Exploring the project structure — How do the external libraries (in the project pane) relate to J2SE and J2EE?
Developing source code — Set the HTML title and body content to whatever you’d like. At what tier does this application run?
Running the application &
Modifying the code and observing the
changes — What server does this step use to serve up your application? For a
hint, look at what’s served up at the URL: /
. How does it compare
with a typical web server?
Exploring a run configuration &
Exploring an artifact
configuration — Skim through these sections, making sure that you can find
the application features they discuss. What is a WAR file?
Packaging the application into a WAR file &
Deploying an artifact
onto a running server — Here, we run the app on a GlassFish server running on
the local machine, called a “remote” server because it’s running
outside of Intellij IDEA. Start the server as follows.
C:\glassfish-4.1-web\glassfish4\glassfish\bin\asadmin.bat
and
run the server command start-domain
. You can stop it later using
stop-domain
.
http://localhost:4848/
and
make sure that you can find:
You should now have a GlassFish server running to which Intellij can (“remotely”) deploy your WAR. What’s the difference between “exploded” and non-exploded WAR files?
Packaging the application into an EAR: Using Java EE Application support
&
Looking at other features (tool windows and facets) — Skim
these sections but don’t implement them. Compare and contrast EAR and
WAR artifacts.
Save this new application to the your course repo by Git-adding the application source files
(i.e., the files in the root folder and those in the .idea/
, src/
and web/
, but not out/
, sub-directories) and git-commit/pushing
them.
You’ll update this app in the next exercise.
Now, add a RESTful service to the application you built in the previous exercise. This process is sufficiently similar to the J2EE tutorial used above that we can skip most of the steps in the Jetbrains tutorial.
Run the Intellij IDEA REST tutorial: Creating and Running Your First RESTful Web Service on
GlassFish Application Server. Note the following as you go through the tutorial
sections, saving the answers to the questions in your existing notes.txt
file.
Before you start
Configuring the GlassFish server in IntelliJ
IDEA
Configuring the JDK
Creating a project &
Exploring
the project structure — These steps are mostly done already, but you must do
the following to add JAX-RS/REST to your project.
Developing source code
Examining the generated artifact
configuration
Exploring and completing the run configuration
&
Running the application — Do these steps as written. The
application should run either locally or remotely. Modify it to support the URL /hello
(rather than /helloworld
). Note that you’ll need to stop the “remote” server
(using stop-domain
, see above) before deploying “locally” in
Intellij. What library does this application use for REST support?
Git-add the new source files and git-commit/push the updated application.
For the next exercise, you need to add support for the other REST operations and test that it works. For this, you’ll need the following references.
Implementing REST — You can find the details on writing PUT, POST and DELETE in the Creating a RESTful Root Resource Class tutorial.
Testing REST — You can test GET commands using a Web browser but data-driven web services typically support the other HTTP commands as well (i.e., PUT, POST & DELETE). Use Intellij’s Test RESTful Web Service tool to test them (see the Tools menu). For more details, see their Testing RESTful Web Services tutorial.
Add RESTful support for GET, PUT, POST and DELETE. Your implementations of these HTTP methods
should use the URL http://localhost:8080/Lab11_war/hello/api
and do the
following.
yourRootURL/x
should return “Deleting: x”, where
yourRootURL is the base URL for your app and x is URL
value).
Leave the original hello-world URL in place. Make sure that you can test your service using the Intellij RESTful test tool.
If there’s time, you can explore this application further.
You can also test your API using a command-line tool like curl.
/
.
Move the output to a more reasonably-named URL. You can do this by modifying the run
configuration’s
“Use custom context root” setting on the Deployment tab and setting path to
something like /
.
We will grade your work according to the following criteria: