Blaze advisor error: this function should be called while holding treeLock

By , last updated December 20, 2019

Problem

As a Blaze Advisor rules programmer, I often get errors like this. They are almost always Java related. Last time I struggled with “JVM not found” while installing the Blaze Advisor IDE.

This time I was getting error message “This function should be called while holding a treeLock. Details logged in …\advisor.log” each time I was trying to change my Object Model or look at a Cross Reference browser.
blaze advisor function should be called while holding treeLock

This error comes as I’m using a newer version of Java om my Java-side of the program, while Blaze Advisor version 6.9 still needs Java6. Apparently, there’s a new feature in Java7 that is designed to force you to write better and safer code by calling some functions in synchronized mode. As we can’t rewrite Blaze Advisor, we are going to solve the problem on our side.

How to fix

Update Blaze Advisor

I’m using version 6.9 and hearing that newer versions can be used with Eclipse and support java7 and up. Give it a try if you can.

Set special Java version

If you can’t get a newer version than you need to set a special Java version for running Blaze Advisor IDE. This can be done in different ways based on how you start the application:

  • setenv.bat

If you are using “builder.bat” or some other .bat file to start the IDE that you can add a property to setenv.bat file that you can find in a “bin” folder of your Blaze Advisor installation. Add/change JAVA_HOME property like that:

:setjavahome
set JAVA_HOME=C:\Java\jdk1.6.0_33
  • maven
  • I’m using maven and maven-blaze plugin at some projects and start Blaze with a maven command:

    mvn blaze:builder
    

    Here is how my pom.xml looks like with maven-blaze setup:

     <plugin>
          <groupId>myconfig</groupId>
          <artifactId>maven-blaze-plugin</artifactId>
          <executions>
               <execution>
                    <goals>
                        <goal>copyServerFiles</goal>
                        <goal>compile</goal>
                        <goal>generate-brunit</goal>
                        <goal>test</goal>
                        <goal>validate-locale</goal>
                    </goals>
               </execution>
          </executions>
    </plugin>      
    

    So, if you are using maven you will need to set your JAVA_HOME before running the command. Run the following two commands in your command line just before mvn blaze:builder:

    set JAVA_HOME=C:\Java\jdk1.6.0_33
    set path=%JAVA_HOME%\bin;&PATH%
    

Always suspect Java when you get errors in Blaze!
Hope this helps!