Project

General

Profile

Bug #10919

the source/AST view is broken in the Analytics web UI

Added by Greg Shah 8 months ago. Updated 6 months ago.

Status:
Test
Priority:
Urgent
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
trunk/16362
reviewer:
production:
No
env_name:
topics:

analytics_language_statements_report.png (494 KB) Greg Shah, 11/21/2025 03:37 PM

broken_source_ast_view.png (1.21 MB) Greg Shah, 11/21/2025 03:37 PM


Related issues

Related to Conversion Tools - Bug #10784: FWD Analytics - Visualize Call Graph can't be used due to broken file paths Test

History

#1 Updated by Greg Shah 8 months ago

I suspect this is a bug from our recent #5586 changes.

Running reports in Hotel GUI completes properly. You can load up the report server, open specific reports like the Base Language -> Language Statements shown here:

The problem is when you click on any of the report details on the right side, you get an empty/broken source/AST view:

#2 Updated by Greg Shah 8 months ago

The .cache and .p.ast files do exist, but they are in ./cvt/ instead of ./abl/ which is probably the issue.

#3 Updated by Dănuț Filimon 8 months ago

  • Status changed from New to WIP

I am investigating.

#4 Updated by Dănuț Filimon 8 months ago

  • Related to Bug #10784: FWD Analytics - Visualize Call Graph can't be used due to broken file paths added

#5 Updated by Dănuț Filimon 8 months ago

The error is the same one mentioned in #10784-1. Octavian found a workaround for this, but I will see if I can fix it.

#6 Updated by Dănuț Filimon 8 months ago

  • % Done changed from 0 to 100
  • Status changed from WIP to Review
  • reviewer Greg Shah added

Committed a simple fix to 10919a/16292. The issue is with normalizeFilename(), the abnormal File is initialized without taking into account the home so we end up creating a File in the current working directory (where the report server is started).

The patch is:

=== modified file 'src/com/goldencode/p2j/cfg/Configuration.java'
--- old/src/com/goldencode/p2j/cfg/Configuration.java    2025-10-08 07:50:27 +0000
+++ new/src/com/goldencode/p2j/cfg/Configuration.java    2025-11-24 09:07:23 +0000
@@ -117,6 +117,7 @@
 **     DDF 20250911          Fix basepath replacement.
 **     DDF 20250916          Added getPathToConversionFolderPojoFromDmo().
 **     DDF 20251008          Removed nameMapPath and DEF_NAME_MAP_FILE.
+** 033 DDF 20251124          normalizeFilename() should use the home path when creating the file instance.
 */

 /*
@@ -1589,7 +1590,7 @@
     */
    public static String normalizeFilename(String home, String filename)
    {
-      File   abnormal = new File(filename); 
+      File   abnormal = new File(home, filename); 
       String absolute;

       try

Greg, please review.

#7 Updated by Dănuț Filimon 8 months ago

  • Status changed from Review to WIP
  • % Done changed from 100 to 0

The solution from #10919-6 is not correct, I tested it a little bit more and I ended up with /home/ddf/gcd/branches/hotel_gui/home/ddf/gcd/branches/hotel_gui/data/standard.df

#8 Updated by Dănuț Filimon 8 months ago

I've got ./abl/fwd-embedded-driver.p which is normalized to ./deploy/server/abl/fwd-embedded-driver.p. My initial idea was that the normalizeFilename home parameter should be the directory for the given filename, so I made this patch:

=== modified file 'src/com/goldencode/p2j/cfg/Configuration.java'
--- old/src/com/goldencode/p2j/cfg/Configuration.java    2025-10-08 07:50:27 +0000
+++ new/src/com/goldencode/p2j/cfg/Configuration.java    2025-11-25 08:25:45 +0000
@@ -1589,8 +1589,19 @@
     */
    public static String normalizeFilename(String home, String filename)
    {
-      File   abnormal = new File(filename); 
+      String prefix = "." + File.separator;
+      File abnormal;
       String absolute;
+      if (filename.startsWith(prefix))
+      {
+         // remove the dot
+         filename = filename.substring(1);
+         abnormal = new File(home + filename);
+      }
+      else
+      {
+         abnormal = new File(filename);
+      }

       try
       {

The idea is that we will create a file using home + filename (which we expect) without creating the File object for the filename which will result in adding ./deploy/server/.

#9 Updated by Greg Shah 8 months ago

Won't this be a problem when we reach the if (absolute.startsWith(home)) code later in that method? Why not have the ReportDriver configure a relative path that is a "fixup" which "gets you" to the project home directory. This could be calculated or configured in the ReportDriver and only if fixup is not null would be add it.

#10 Updated by Greg Shah 8 months ago

Also, assuming home is always the same value, can't home = new File(home).getCanonicalPath(); be calculated at startup and used as a constant? This is just a possible optimization.

#11 Updated by Dănuț Filimon 8 months ago

Greg Shah wrote:

Won't this be a problem when we reach the if (absolute.startsWith(home)) code later in that method? Why not have the ReportDriver configure a relative path that is a "fixup" which "gets you" to the project home directory. This could be calculated or configured in the ReportDriver and only if fixup is not null would be add it.

No, it will just remove home from the path. We already have home which is the relative path that we need, so I don't see a use for another path.

For #10919-10: It can be calculated once and stored.

#12 Updated by Greg Shah 8 months ago

No, it will just remove home from the path. We already have home which is the relative path that we need, so I don't see a use for another path.

What is home set to for the ReportDriver?

#13 Updated by Dănuț Filimon 8 months ago

Greg Shah wrote:

No, it will just remove home from the path. We already have home which is the relative path that we need, so I don't see a use for another path.

What is home set to for the ReportDriver?

When running the conversion or report server, it is /home/ddf/gcd/branches/hotel_gui (project root).

#14 Updated by Greg Shah 8 months ago

Above, I was saying ReportDriver but that was a mistake. I meant ReportWebServer.

If the files are being read by the ReportWebServer using a relative path AND the working directory for the ReportWebServer is in <project_home>/deploy/server/, then the files won't be found even if you fix the ./abl/ to ./cvt/.

#15 Updated by Dănuț Filimon 8 months ago

I fixed this in the report.sh script:

=== modified file 'deploy/server/report.sh'
--- old/deploy/server/report.sh    2024-11-06 15:12:06 +0000
+++ new/deploy/server/report.sh    2025-11-26 08:41:44 +0000
@@ -3,25 +3,29 @@
 port=$1
 logfile=$2

+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 
+cd ../..
+
 [ ."$port". == ".." ]    && port=9443
 [ ."$logfile". == ".." ] && logfile="report_server.log" 

 # Find FWD libraries
-fwd_lib=$([ -n "$FWD_LIB" ] && echo $FWD_LIB || echo "../../p2j")
+fwd_lib=$([ -n "$FWD_LIB" ] && echo $FWD_LIB || echo "./p2j")
 if [ ! -e "$fwd_lib" ]; then
    echo "ERROR: Either FWD_LIB must be set to a valid directory or ./p2j directory must exist so as to locate p2j.jar" 
    exit 1
 fi
 p2j_jar=$([ -e "${fwd_lib}/build/lib/p2j.jar" ] && echo ${fwd_lib}/build/lib/p2j.jar || echo ${fwd_lib}/lib/p2j.jar)
-p2j_jar=$([ -e "$p2j_jar" ] && echo $p2j_jar || echo ../../p2j/lib/p2j.jar)
+p2j_jar=$([ -e "$p2j_jar" ] && echo $p2j_jar || echo ./p2j/lib/p2j.jar)

 # defaults
 cpath="${p2j_jar}:.:" 
-dtxt="-Xnoagent -DP2J_HOME=../.. -Djava.compiler=NONE" 
+dtxt="-Xnoagent -DP2J_HOME=. -Djava.compiler=NONE" 
+debug="-Xdebug -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=2100,server=y,suspend=y" 

-java $dtxt -classpath $cpath com.goldencode.p2j.report.server.ReportWebServer \
+java $dtxt $debug -classpath $cpath com.goldencode.p2j.report.server.ReportWebServer \
                              -port $port \
-                             -ks ./embedded-private-key.store \
+                             -ks ${SCRIPT_DIR}/embedded-private-key.store \
                              -kspw 87ViGTQVp\<07zPw\(3i2A4%uCHYx3mIgSt\>Tk \
                              -kepw h8jNMO\>Vbn0\`cL\)b95dVn\$w03CePIB6eItL3 \
                              1> $logfile 2>&1
Ignore the $debug, it was used for testing. What do you think about this Greg?

#16 Updated by Greg Shah 8 months ago

I'm OK with the idea. Please add comments to make it clear that the ReportWebServer MUST be executed with the project home as the working directory.

This change would have to be migrated to every conversion project.

Roger: Please review.

#17 Updated by Dănuț Filimon 8 months ago

Roger, this is the final patch:

=== modified file 'deploy/server/report.sh'
--- old/deploy/server/report.sh    2024-11-06 15:12:06 +0000
+++ new/deploy/server/report.sh    2025-11-26 12:32:08 +0000
@@ -3,25 +3,31 @@
 port=$1
 logfile=$2

+# Save the current directory.
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 
+
+# Change the current working directory to the project home directory.
+cd ../..
+
 [ ."$port". == ".." ]    && port=9443
 [ ."$logfile". == ".." ] && logfile="report_server.log" 

 # Find FWD libraries
-fwd_lib=$([ -n "$FWD_LIB" ] && echo $FWD_LIB || echo "../../p2j")
+fwd_lib=$([ -n "$FWD_LIB" ] && echo $FWD_LIB || echo "./p2j")
 if [ ! -e "$fwd_lib" ]; then
    echo "ERROR: Either FWD_LIB must be set to a valid directory or ./p2j directory must exist so as to locate p2j.jar" 
    exit 1
 fi
 p2j_jar=$([ -e "${fwd_lib}/build/lib/p2j.jar" ] && echo ${fwd_lib}/build/lib/p2j.jar || echo ${fwd_lib}/lib/p2j.jar)
-p2j_jar=$([ -e "$p2j_jar" ] && echo $p2j_jar || echo ../../p2j/lib/p2j.jar)
+p2j_jar=$([ -e "$p2j_jar" ] && echo $p2j_jar || echo ./p2j/lib/p2j.jar)

 # defaults
 cpath="${p2j_jar}:.:" 
-dtxt="-Xnoagent -DP2J_HOME=../.. -Djava.compiler=NONE" 
+dtxt="-Xnoagent -DP2J_HOME=. -Djava.compiler=NONE" 

 java $dtxt -classpath $cpath com.goldencode.p2j.report.server.ReportWebServer \
                              -port $port \
-                             -ks ./embedded-private-key.store \
+                             -ks ${SCRIPT_DIR}/embedded-private-key.store \
                              -kspw 87ViGTQVp\<07zPw\(3i2A4%uCHYx3mIgSt\>Tk \
                              -kepw h8jNMO\>Vbn0\`cL\)b95dVn\$w03CePIB6eItL3 \
                              1> $logfile 2>&1
I removed $debug which I used for debugging the fix.

I also committed this comment to 10919a/16293.

=== modified file 'src/com/goldencode/p2j/report/server/ReportWebServer.java'
--- old/src/com/goldencode/p2j/report/server/ReportWebServer.java    2024-07-22 14:19:39 +0000
+++ new/src/com/goldencode/p2j/report/server/ReportWebServer.java    2025-11-26 12:33:43 +0000
@@ -154,6 +154,8 @@

    /**
     * Command line interface to launch web server.
+    * <p>
+    * The web server must be executed with the project home as the working directory.
     * 
     * @param   args
     *          Required arguments.

#18 Updated by Roger Borrello 8 months ago

So you start the web server as: ./deploy/server/report.sh?

#19 Updated by Dănuț Filimon 8 months ago

Roger Borrello wrote:

So you start the web server as: ./deploy/server/report.sh?

No, like this: ~/gcd/branches/hotel_gui/deploy/server$ ./report.sh

#20 Updated by Roger Borrello 8 months ago

Dănuț Filimon wrote:

Roger Borrello wrote:

So you start the web server as: ./deploy/server/report.sh?

No, like this: ~/gcd/branches/hotel_gui/deploy/server$ ./report.sh

OK. I had crossed the comment from the Java code with the comment from the changing of the directory in the script. This should be fine, especially because that's how Docker environment is running reports server already.

#21 Updated by Dănuț Filimon 8 months ago

  • Status changed from WIP to Internal Test

Thanks Roger, is there any testing I can do aside from running the report server for Hotel?

#22 Updated by Roger Borrello 8 months ago

Dănuț Filimon wrote:

Thanks Roger, is there any testing I can do aside from running the report server for Hotel?

Without actually having a 10919a FWD Docker image, not much. Getting one build would involve the container project, and:

./build_fwd.sh -b 10919a -l projects/10919a --latest --jdk_version=jdk17

Then building Hotel GUI Reports with that FWD Docker image and running it:

./docker/build_docker.sh --jdk_version=jdk17 -r . -t 10919a_latest -l --reports
./docker/run_docker.sh --reports

but that is going from memory.

#23 Updated by Greg Shah 8 months ago

Dănuț Filimon wrote:

Thanks Roger, is there any testing I can do aside from running the report server for Hotel?

This change isn't specific to Docker. You can test the report server from any Hotel GUI install. Make sure to use ant report_server as the target so that you have both reports and call graph. Then you should be able to open the source view from any details report. And you should be able to test a custom search, which is also dependent upon being able to access AST files.

#24 Updated by Dănuț Filimon 8 months ago

  • % Done changed from 0 to 100

I tested ant report_server, checked call graphs and reports. I found a single issue where the report log was in the project root so I updated the script:

=== modified file 'deploy/server/report.sh'
--- old/deploy/server/report.sh    2024-11-06 15:12:06 +0000
+++ new/deploy/server/report.sh    2025-12-02 09:02:19 +0000
@@ -3,25 +3,31 @@
 port=$1
 logfile=$2

+# Save the current directory.
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 
+
+# Change the current working directory to the project home directory.
+cd ../..
+
 [ ."$port". == ".." ]    && port=9443
-[ ."$logfile". == ".." ] && logfile="report_server.log" 
+[ ."$logfile". = ".." ]  && logfile="$SCRIPT_DIR/report_server.log" 

 # Find FWD libraries
-fwd_lib=$([ -n "$FWD_LIB" ] && echo $FWD_LIB || echo "../../p2j")
+fwd_lib=$([ -n "$FWD_LIB" ] && echo $FWD_LIB || echo "./p2j")
 if [ ! -e "$fwd_lib" ]; then
    echo "ERROR: Either FWD_LIB must be set to a valid directory or ./p2j directory must exist so as to locate p2j.jar" 
    exit 1
 fi
 p2j_jar=$([ -e "${fwd_lib}/build/lib/p2j.jar" ] && echo ${fwd_lib}/build/lib/p2j.jar || echo ${fwd_lib}/lib/p2j.jar)
-p2j_jar=$([ -e "$p2j_jar" ] && echo $p2j_jar || echo ../../p2j/lib/p2j.jar)
+p2j_jar=$([ -e "$p2j_jar" ] && echo $p2j_jar || echo ./p2j/lib/p2j.jar)

 # defaults
 cpath="${p2j_jar}:.:" 
-dtxt="-Xnoagent -DP2J_HOME=../.. -Djava.compiler=NONE" 
+dtxt="-Xnoagent -DP2J_HOME=. -Djava.compiler=NONE" 

 java $dtxt -classpath $cpath com.goldencode.p2j.report.server.ReportWebServer \
                              -port $port \
-                             -ks ./embedded-private-key.store \
+                             -ks ${SCRIPT_DIR}/embedded-private-key.store \
                              -kspw 87ViGTQVp\<07zPw\(3i2A4%uCHYx3mIgSt\>Tk \
                              -kepw h8jNMO\>Vbn0\`cL\)b95dVn\$w03CePIB6eItL3 \
                              1> $logfile 2>&1

#25 Updated by Greg Shah 8 months ago

  • Status changed from Internal Test to Merge Pending

Go ahead and commit this to our Hotel projects.

Assuming all other customer projects are using an unmodified version of the original script, please commit this new version to each of those repos.

#26 Updated by Dănuț Filimon 8 months ago

Committed hotel_gui/419, hotel/186. Fixed reports using the wrong location for AST resource.

ETF does not have a report.sh.

ChUI, testcases, customer 1, 2, and 3 need small adjustments. But I'd also need the customer to accept the change before I commit it to their repository branch.

#27 Updated by Dănuț Filimon 8 months ago

Committed xfer testcases/1817.

#28 Updated by Dănuț Filimon 7 months ago

I am merging 10919a now so that the trunk revision can be referenced.

#29 Updated by Dănuț Filimon 7 months ago

Branch 10919a was merged into trunk as rev. 16308 and archived.

Only a customer and ChUI scripts are left to be updated.

#30 Updated by Greg Shah 7 months ago

I've tested the fix, although it works, it is VERY SLOW. Even use in a small customer project (500KLOC) takes 10+ seconds to load the source/AST view. Even in Hotel GUI, it takes 3-5 seconds at its fastest and 30 seconds for some loads. This is not right.

Please look into this.

#31 Updated by Greg Shah 7 months ago

  • Status changed from Merge Pending to WIP
  • % Done changed from 100 to 90

#32 Updated by Dănuț Filimon 6 months ago

I tried to find the revision which introduced this performance issue using VisualVM. I am now switching to YourKit to investigate the root cause.

#33 Updated by Dănuț Filimon 6 months ago

Committed 10919b/16339. Noticed there were a lot of methods that only do read only operations and also call commit(). I made this change and managed to improve performance a bit.

#34 Updated by Dănuț Filimon 6 months ago

  • % Done changed from 90 to 100
  • Status changed from WIP to Review

Committed 10919b/16340. Missed 2 commit calls, committed to remove those for good.

Greg, can you let me know if it loads faster for you now?

#35 Updated by Greg Shah 6 months ago

It is much faster now.

#36 Updated by Dănuț Filimon 6 months ago

  • Status changed from Review to WIP
  • % Done changed from 100 to 90

Greg Shah wrote:

It is much faster now.

Thank you, I am experimenting with a few other changes.

#37 Updated by Dănuț Filimon 6 months ago

  • Status changed from WIP to Review
  • % Done changed from 90 to 100
I made a few additional changes and noticed an improvement, building the summary/detail report is slow the first time, but faster after that.
Committed 10919b/16341, this revision includes a few small changes:
  • Use a try with resources for a delete to avoid checking the statement later on
  • reordered two loops to avoid unnecessary checks
  • removed usage of wasNull() to reduce cursor calls

Greg, please review. We can wrap up with this commit, but if you have any other ideas let me know.

I checked if we could maybe limit the ArrayList(s) size to the fetch size of the ResultSet, but it was zero. I am wondering if we might benefit from adding a fetch size to the DatabaseService connections.

#38 Updated by Greg Shah 6 months ago

  • Status changed from Review to Internal Test

Code Review Task Branch 10919b Revisions 16339 through 16341

The changes look good.

#39 Updated by Dănuț Filimon 6 months ago

The changes only target the ReportApi, so I will take two customer applications and test them.

#40 Updated by Dănuț Filimon 6 months ago

There seems to be a bug in a customer report conversion:

     [java] ERROR!  Active Rule:
     [java] -----------------------
     [java]       RULE REPORT      
     [java] -----------------------
     [java] Rule Type :   POST
     [java] Source AST:  [ block ] BLOCK/ @0:0 {6472515715073}
     [java] Copy AST  :  [ block ] BLOCK/ @0:0 {6472515715073}
     [java] Condition :  rw.postprocessFile()
     [java] Loop      :  false
     [java] --- END RULE REPORT ---
     [java] 
     [java] 
     [java] 
     [java] com.goldencode.p2j.pattern.TreeWalkException: ERROR!  Active Rule:
     [java] -----------------------
     [java]       RULE REPORT      
     [java] -----------------------
     [java] Rule Type :   POST
     [java] Source AST:  [ block ] BLOCK/ @0:0 {6472515715073}
     [java] Copy AST  :  [ block ] BLOCK/ @0:0 {6472515715073}
     [java] Condition :  rw.postprocessFile()
     [java] Loop      :  false
     [java] --- END RULE REPORT ---
     [java] 
     [java] 
     [java] 
     [java]     at com.goldencode.p2j.pattern.PatternEngine.handleRunThrowable(PatternEngine.java:1938)
     [java]     at com.goldencode.p2j.pattern.PatternEngine.run(PatternEngine.java:1070)
     [java]     at com.goldencode.p2j.report.ReportDriver.patternEngine(ReportDriver.java:181)
     [java]     at com.goldencode.p2j.report.ReportDriver.oldSyntax(ReportDriver.java:578)
     [java]     at com.goldencode.p2j.report.ReportDriver.main(ReportDriver.java:320)
     [java] Caused by: java.lang.NullPointerException: Cannot invoke "com.goldencode.p2j.schema.NameNode.getType()" because "fromNode" is null
     [java]     at com.goldencode.p2j.schema.SchemaDictionary.addEntries(SchemaDictionary.java:5154)
     [java]     at com.goldencode.p2j.schema.SchemaDictionary.addFieldEntries(SchemaDictionary.java:2953)
     [java]     at com.goldencode.p2j.uast.ClassDefinition.<init>(ClassDefinition.java:689)
     [java]     at com.goldencode.p2j.uast.SymbolResolver.loadClassDefinition(SymbolResolver.java:2461)
     [java]     at com.goldencode.p2j.uast.SymbolResolver.loadClassDefinition(SymbolResolver.java:2411)
     [java]     at com.goldencode.p2j.uast.SymbolResolver.loadClassDefinition(SymbolResolver.java:2393)
     [java]     at com.goldencode.p2j.uast.SymbolResolver.loadConvertedClass(SymbolResolver.java:2374)
     [java]     at com.goldencode.p2j.uast.SymbolResolver.resolveClassDefinition(SymbolResolver.java:1347)
     [java]     at com.goldencode.p2j.schema.P2OAccessWorker.visitAst(P2OAccessWorker.java:264)
     [java]     at com.goldencode.p2j.pattern.PatternEngine.processAst(PatternEngine.java:1540)
     [java]     at com.goldencode.p2j.pattern.PatternEngine.processAst(PatternEngine.java:1507)
     [java]     at com.goldencode.p2j.pattern.PatternEngine.run(PatternEngine.java:1065)
     [java]     ... 3 more
     [java] 
Unrelated to the changes from 10919b.

#41 Updated by Dănuț Filimon 6 months ago

ChUI also failed the conversion with Cannot find class/interface ... in PROPATH.

#42 Updated by Dănuț Filimon 6 months ago

Regardless, the customer mentioned in #10919-40 allowed me to start the report server and test, the load time was pretty smooth and fast. I also noticed the script is missing the changes from #10919-24.

#43 Updated by Dănuț Filimon 6 months ago

  • Status changed from Internal Test to Merge Pending

Merging 10919b to trunk now.

#44 Updated by Dănuț Filimon 6 months ago

  • Status changed from Merge Pending to Test
  • version_reported changed from trunk 1627 to trunk/16362

Branch 10919b was merged into trunk as rev. 16362 and archived.

#45 Updated by Dănuț Filimon 6 months ago

  • version_reported deleted (trunk/16362)
  • version_resolved set to trunk/16362

Fixed the version reported/resolved.

Also available in: Atom PDF