2

I'm curious as to how the IntelliJ debugger uses the domain.xml of my glassfish server and reports a webpage when requested.

Specifically, I have an IntelliJ project called blobGame that uses a Glassfish server that opens a webpage called blobGame when the artifacts .war and .ear are deployed.

Firstly, how are these artifacts deployed? When I deploy them, I MUST have the URL of the localhost be http://localhost:60836/blobGame_war_exploded, and localhost:60836/blobGame DOES NOT WORK, even if I change it in the debug configuration - here is my debugger info

Why is this? Why does the url have to be /blobGame_war_exploded? It cannot even be /blobGame_ear_exploded, as I see that also in the domain.xml.

Here is the snippet of domain.xml for my domain called "domain2":

  <applications>
    <application object-type="user" name="blobGame_ear_exploded" directory-deployed="true" location="file:/C:/Users/Kevin/EECS/blobGame/out/artifacts/blobGame_ear_exploded/">
      <property name="archiveType" value="ear"></property>
      <property name="isComposite" value="true"></property>
      <property name="appLocation" value="file:/C:/Users/Kevin/EECS/blobGame/out/artifacts/blobGame_ear_exploded/"></property>
      <property name="org.glassfish.ejb.container.application_unique_id" value="98074431158681600"></property>
      <property name="defaultAppName" value="blobGame_ear_exploded"></property>
      <module name="web.war">
        <engine sniffer="ejb"></engine>
        <engine sniffer="security"></engine>
        <engine sniffer="weld"></engine>
        <engine sniffer="web"></engine>
      </module>
      <engine sniffer="ear"></engine>
    </application>
    <application context-root="/blobGame_war_exploded" object-type="user" name="blobGame_war_exploded" directory-deployed="true" location="file:/C:/Users/Kevin/EECS/blobGame/out/artifacts/blobGame_war_exploded/">
      <property name="archiveType" value="war"></property>
      <property name="appLocation" value="file:/C:/Users/Kevin/EECS/blobGame/out/artifacts/blobGame_war_exploded/"></property>
      <property name="org.glassfish.ejb.container.application_unique_id" value="98074431158812672"></property>
      <property name="defaultAppName" value="blobGame_war_exploded"></property>
      <module name="blobGame_war_exploded">
        <engine sniffer="ejb"></engine>
        <engine sniffer="security"></engine>
        <engine sniffer="weld"></engine>
        <engine sniffer="web"></engine>
      </module>
    </application>
  </applications>

SECOND of all, why does the deployment still use previous artifacts (as I assume they are) when I redeploy or restart the server?

Specifically, when I press restart, I get the exact same HTML and javascript files I was left with before, and even if I edited the html or JS files during the time before my second debug. (I add alert("test") in the new debug, but it does not show up in the new debug. When I access the index.html page independently the alert does show up).

Here is the index.html

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>keyBoardDemo</title>
    </head>
    <body>
        <canvas id="canvas" width="800" height="600" style="border:1px solid #000000;"></canvas>
        <p id="main"></p>
        <script type="text/javascript" src=resources.js></script>
        <script type="text/javascript" src=canvas.js></script>
        <script type="text/javascript" src=keyboard.js></script>
        <script type="text/javascript" src=packethandler.js></script>
        <script type="text/javascript" src=player.js></script>
        <script type="text/javascript" src=websocket.js></script>
    </body>
</html>

and here is the canvas.js that it calls:

alert("test 123"); //this is not called on the second redeployment!


var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
Kevin Hu
  • 41
  • 9

1 Answers1

1

Firstly, how are these artifacts deployed? When I deploy them, I MUST have the URL ...

By default, IDEA computes context root from the artifact name, by replacing unsupported characters with underscores. Thus, the 'blobGame:war exploded' artifact, by default gets 'blobGame_war_exploded' context root.

To change the context root for the artifact, you may want to open the 'Deployment' tab of the run configuration, check 'Use custom context root' and enter the desired value into the field

'Open browser' field on the 'Server' tab does not affect the server settings, it just allows you to open whatever URL you like after the server start. The field value defaults to the URL computed from the first artifact, but once user have changed it IDEA assumes that user knows better.

Specifically, when I press restart, I get the exact same HTML and javascript files I was left with before, ...

The expected sequence is as follows:

  1. make a change to a resource
  2. update the application on the server with the mentioned 'Update <> application' action: 'Update resource' choice should be enough for an exploded application, redeploy/restart may be needed for archive artifact
  3. reload (refresh) the page, that uses the resource in browser

I suspect you're missing the last (3) step. Please note, step (2) only updates the resource on the server, and to see a change in browser (on client) you should reload the corresponding resources from server by refreshing the page manually.

Hope that helps, I am going to redirect your second post to this answer

Michael Golubev
  • 271
  • 1
  • 3
  • Nope, I always do refresh my chrome browser (the webpage I use) whenever I restart the server or redeploy or update classes, etc.... it does not work. Like I said, even after restarting IntelliJ, it still retains my unchanged deployment even though the files have been modified – Kevin Hu Jun 07 '17 at 23:32
  • Please submit new youtrack, and attach (privately) your .idea folder. Please see https://intellij-support.jetbrains.com/hc/en-us/articles/207241135 if you are not familiar with YouTrack. – Michael Golubev Jun 08 '17 at 14:47
  • It does not for EAR deployment: https://stackoverflow.com/questions/51525485/use-custom-context-root-does-not-work-for-deployment-ear-application-to-glassf – RoutesMaps.com Jul 25 '18 at 18:30