Skip to content

recipesFound null in upgrade-asciidoc.ftl:46 breaks HTML report generation #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timtebeek opened this issue May 22, 2022 · 2 comments · Fixed by #125
Closed

recipesFound null in upgrade-asciidoc.ftl:46 breaks HTML report generation #124

timtebeek opened this issue May 22, 2022 · 2 comments · Fixed by #125

Comments

@timtebeek
Copy link
Contributor

Describe the bug
Template error generating HTML report.

freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> recipesFound  [in template "upgrade-asciidoc.ftl" at line 46, column 6]

To Reproduce
Steps to reproduce the behavior:

  1. checkout spring petclinic on spring boot 2.4
#!/bin/bash
set -e
source "$HOME/.sdkman/bin/sdkman-init.sh"

project='spring-petclinic-sbm'

wget --no-clobber https://github.com/spring-projects-experimental/spring-boot-migrator/releases/download/0.11.0/spring-boot-migrator.jar

git clone [email protected]:spring-projects/spring-petclinic.git $project
cd $project
#git reset --hard
#git clean -f
git checkout 09e07869ac8cea1d08bd62802d5e0dad97827b87 # commit on 2.4.x
cd -

sdk use java 11.0.15-tem
java -jar spring-boot-migrator.jar
  1. scan spring-petclinic-sbm
  2. apply boot-2.4-2.5-dependency-version-update
  3. apply boot-2.4-2.5-sql-init-properties
  4. apply boot-2.4-2.5-upgrade-report

Expected behavior
A HTML report, possibly with all steps resolved

Stacktrace

spring-petclinic-sbm:> apply boot-2.4-2.5-upgrade-report
Applying recipe 'boot-2.4-2.5-upgrade-report'
..   Create Upgrade Report for a Spring Boot 2.4 Application16:42:24.213 [main] ERROR freemarker.runtime - Error executing FreeMarker template
freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> recipesFound  [in template "upgrade-asciidoc.ftl" at line 46, column 6]
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
	- Failed at: #if recipesFound  [in template "upgrade-asciidoc.ftl" at line 46, column 1]
----
	at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)
	at freemarker.core.UnexpectedTypeException.newDescriptionBuilder(UnexpectedTypeException.java:85)
	at freemarker.core.UnexpectedTypeException.<init>(UnexpectedTypeException.java:48)
	at freemarker.core.NonBooleanException.<init>(NonBooleanException.java:47)
	at freemarker.core.Expression.modelToBoolean(Expression.java:195)
	at freemarker.core.Expression.evalToBoolean(Expression.java:178)
	at freemarker.core.Expression.evalToBoolean(Expression.java:163)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:48)
	at freemarker.core.Environment.visit(Environment.java:347)
	at freemarker.core.Environment.visit(Environment.java:353)
	at freemarker.core.Environment.process(Environment.java:326)
	at freemarker.template.Template.process(Template.java:383)
	at org.springframework.sbm.boot.upgrade_24_25.actions.Boot_24_25_UpgradeReportAction.renderMarkdown(Boot_24_25_UpgradeReportAction.java:80)
	at org.springframework.sbm.boot.upgrade_24_25.actions.Boot_24_25_UpgradeReportAction.apply(Boot_24_25_UpgradeReportAction.java:69)
	at org.springframework.sbm.engine.recipe.Action.applyWithStatusEvent(Action.java:37)
	at org.springframework.sbm.engine.recipe.Recipe.lambda$apply$2(Recipe.java:97)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at org.springframework.sbm.engine.recipe.Recipe.apply(Recipe.java:97)
	at org.springframework.sbm.engine.commands.ApplyCommand.execute(ApplyCommand.java:70)
	at org.springframework.sbm.shell.ApplyShellCommand.apply(ApplyShellCommand.java:54)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
	at org.springframework.shell.Shell.evaluate(Shell.java:180)
	at org.springframework.shell.Shell.run(Shell.java:142)
	at org.springframework.shell.jline.InteractiveShellApplicationRunner.run(InteractiveShellApplicationRunner.java:84)
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:803)
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:793)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:346)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1365)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
	at org.springframework.sbm.SpringShellApplication.main(SpringShellApplication.java:27)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Action [org.springframework.sbm.boot.upgrade_24_25.actions.Boot_24_25_UpgradeReportAction] with description 'Create Upgrade Report for a Spring Boot 2.4 Application' failed: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> recipesFound  [in template "upgrade-asciidoc.ftl" at line 46, column 6]
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
	- Failed at: #if recipesFound  [in template "upgrade-asciidoc.ftl" at line 46, column 1]
----
Details of the error have been omitted. You can use the stacktrace command to print the full stacktrace.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Version 11
@timtebeek
Copy link
Contributor Author

Looking at this answer it might be that this line needs to include two question marks.

-<#if recipesFound>
+<#if recipesFound??>

Although I've never worked with freemarker templates, so there might be a better/other way.

@fabapp2
Copy link
Contributor

fabapp2 commented May 22, 2022

Thanks a lot @timtebeek for reporting and solving it!

fabapp2 added a commit that referenced this issue May 22, 2022
@fabapp2 fabapp2 linked a pull request May 22, 2022 that will close this issue
fabapp2 added a commit that referenced this issue May 22, 2022
Thanks, @timtebeek for reporting and providing the fix!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants