Project

General

Profile

Defect #1247

renderTemplate() returns NULL

Added by Robert Ivens over 2 years ago. Updated about 1 year ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
08/21/2017
Due date:
% Done:

0%

Estimated time:
Browser (if web client):
Safari

Description

I try to use the renderTemplate function in Developer which works correctly in SmartClient and NGClient but not in Webclient.

When I run the following command in the Command Console;

plugins.VelocityReport.renderTemplate("<html>test</html>",{})
I get a NULL back.
In the Servoy log I see the following exception:
java.lang.NullPointerException 
        at org.apache.wicket.Session.getClientInfo(Session.java:568) 
        at com.servoy.j2db.server.headlessclient.WebClient.getServerURL(WebClient.java:125) 
        at com.servoy.j2db.plugins.ClientPluginAccessProvider.getServerURL(ClientPluginAccessProvider.java:335) 
        at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.getApplicationURL(VelocityHelper.java:390) 
        at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.getContextURL(VelocityHelper.java:458) 
        at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.getBaseURLFromScriptable(VelocityHelper.java:436) 
        at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.getBaseHrefFromScriptable(VelocityHelper.java:405) 
        at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.evaluateWithContext(VelocityHelper.java:287) 
        at net.stuff.servoy.plugin.velocityreport.VelocityReportProvider.js_renderTemplate(VelocityReportProvider.java:1585) 
        at net.stuff.servoy.plugin.velocityreport.VelocityReportProvider.js_renderTemplate(VelocityReportProvider.java:1566) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
        at java.lang.reflect.Method.invoke(Method.java:498) 
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:158) 
        at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:312) 
        at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:70) 
        at org.mozilla.javascript.gen.internal_anon_12._c_script_0(internal_anon:1) 
        at org.mozilla.javascript.gen.internal_anon_12.call(internal_anon) 
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:406) 
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3204) 
        at org.mozilla.javascript.gen.internal_anon_12.call(internal_anon) 
        at org.mozilla.javascript.gen.internal_anon_12.exec(internal_anon) 
        at org.mozilla.javascript.Context.evaluateString(Context.java:1121) 
        at com.servoy.eclipse.debug.scriptingconsole.CommandHandler$1.run(CommandHandler.java:67) 
        at com.servoy.j2db.server.headlessclient.WebClient.invokeAndWait(WebClient.java:565) 
        at com.servoy.eclipse.debug.scriptingconsole.CommandHandler.handleCommand(CommandHandler.java:58) 
        at com.servoy.eclipse.debug.scriptingconsole.ScriptConsoleViewer$ConsoleDocumentListener$1.run(ScriptConsoleViewer.java:175)

Velocity v3.5.52
Servoy version 8.1.4 -releaseNumber 3035
JVM Information
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.version=1.8.0_141
java.vm.info=mixed mode
java.vm.vendor=Oracle Corporation

Associated revisions

Revision 1419 (diff)
Added by Patrick Talbot over 2 years ago

Fix for issue #1247 and issue #1252

History

#1

Updated by Patrick Talbot over 2 years ago

  • Status changed from New to Feedback
  • Assignee set to Robert Ivens

That's a weird one. Not that it is not working in Web client, but that it would work at all in Smart and NG. :D

renderTemplate is usually expecting a template path, not the actual template content!
You could add a "fromString: true" property in the context object you're passing and this should work (telling Velocity that the String is actually the template content and not a path).
Or use evaluateWithContext() instead which is made for that...

#2

Updated by Robert Ivens over 2 years ago

  • Assignee changed from Robert Ivens to Patrick Talbot

It all actually works in 7.4.x :) Just not in 8.1.x

Anyway, I tried the following commands and they all return NULL and in the servoy log shows the same exception:

plugins.VelocityReport.renderTemplate("<html>test</html>",{})
plugins.VelocityReport.renderTemplate("<html>test</html>",{fromString: true})

plugins.VelocityReport.evaluateWithContext("<html>test</html>",{})
plugins.VelocityReport.evaluateWithContext("<html>test</html>",{fromString: true})
#3

Updated by Patrick Talbot over 2 years ago

  • Assignee changed from Patrick Talbot to Robert Ivens

Hum... I would gather that the call to getServerURL() is really to try and set a base ref URL to the xml... wonder why Session.getClientInfo() would suddenly throw a NullPointerException though.

Is that in developer or on a server? And what version of Servoy is it exactly? I'll have a deeper look asap.

#4

Updated by Robert Ivens over 2 years ago

This is in Developer.

Version(s):
Velocity v3.5.52
Servoy version 8.1.4 -releaseNumber 3035
JVM Information
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.version=1.8.0_141
java.vm.info=mixed mode
java.vm.vendor=Oracle Corporation
On macOS 10.12.6 (Sierra)

#5

Updated by Robert Ivens over 2 years ago

  • Assignee changed from Robert Ivens to Patrick Talbot
#6

Updated by Patrick Talbot over 2 years ago

OK, I'll have a look asap. Thanks for the info!

#7

Updated by Patrick Talbot over 2 years ago

  • Status changed from Feedback to Resolved

Fixed in v3.5.53

#8

Updated by Koen Cloostermans over 2 years ago

Hi Patrick,

In web client i do get this similar error
See below.

Thanks a bunch
Koen

===

Velocity 3.5.53
Server Information
Servoy version 8.2.1 -releaseNumber 3105

JVM Information
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.version=1.8.0_151
java.vm.info=mixed mode
java.vm.vendor=Oracle Corporation

Operating System Information
os.name=Mac OS X
os.version=10.13.1
os.arch=x86_64

=== in developer
plugins.VelocityReport.evaluateWithContext("hello world",{})

ERROR com.servoy.j2db.util.Debug - Throwable
at internal_anon:1 === in server log
2017-11-23 12:13 Command Line Handler ERROR com.servoy.j2db.util.Debug Throwable at internal_anon:1 71A556CF-705D-48AD-81C7-BE2145C48204 servOS
java.lang.NullPointerException
at org.apache.wicket.Session.getClientInfo(Session.java:568)
at com.servoy.j2db.server.headlessclient.WebClient.getServerURL(WebClient.java:125)
at com.servoy.j2db.plugins.ClientPluginAccessProvider.getServerURL(ClientPluginAccessProvider.java:335)
at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.getApplicationURL(VelocityHelper.java:394)
at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.getContextURL(VelocityHelper.java:468)
at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.getBaseURLFromScriptable(VelocityHelper.java:446)
at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.getBaseHrefFromScriptable(VelocityHelper.java:415)
at net.stuff.servoy.plugin.velocityreport.util.VelocityHelper.evaluateWithContext(VelocityHelper.java:287)
at net.stuff.servoy.plugin.velocityreport.VelocityReportProvider.js_evaluateWithContext(VelocityReportProvider.java:937)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:158)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:312)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:70)
at org.mozilla.javascript.gen.internal_anon_1._c_script_0(internal_anon:1)
at org.mozilla.javascript.gen.internal_anon_1.call(internal_anon)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:406)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3204)
at org.mozilla.javascript.gen.internal_anon_1.call(internal_anon)
at org.mozilla.javascript.gen.internal_anon_1.exec(internal_anon)
at org.mozilla.javascript.Context.evaluateString(Context.java:1121)
at com.servoy.eclipse.debug.scriptingconsole.CommandHandler$1.run(CommandHandler.java:67)
at com.servoy.j2db.server.headlessclient.WebClient.invokeAndWait(WebClient.java:565)
at com.servoy.eclipse.debug.scriptingconsole.CommandHandler.handleCommand(CommandHandler.java:58)
at com.servoy.eclipse.debug.scriptingconsole.ScriptConsoleViewer$ConsoleDocumentListener$1.run(ScriptConsoleViewer.java:175)

#9

Updated by Robert Ivens over 2 years ago

  • Status changed from Resolved to Reopened

I see the same thing at Koen's environment, however I can't reproduce it on my system. Very weird.

Edit: Actually I see it too in my Servoy 8.2.1 environment. Webclient gives that error, Smart client and NG Client works fine.

#10

Updated by Patrick Talbot over 2 years ago

  • Assignee changed from Patrick Talbot to Robert Ivens
  • Status changed from Reopened to Feedback

I thought I had fixed this. Is there any other exception with Velocity before that one?

#11

Updated by Robert Ivens over 2 years ago

I just did it again, ran the web client. Checked first the servoy log in servoy-admin page (running developer).
Then in the command console I typed the following command:

plugins.VelocityReport.evaluateWithContext("hello world",{})

Which returned nothing, but I did get the following output in the Console view:
ERROR com.servoy.j2db.util.Debug - Throwable
    at internal_anon:1

And in the servoy log I get the stack trace that Koen posted.

#12

Updated by Patrick Talbot about 1 year ago

  • Status changed from Feedback to Resolved

Also available in: Atom PDF