ClassCastException from Velocity

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

ClassCastException from Velocity

Postby roddy » Mon May 24, 2021 8:23 am

I am getting the following error on calling: plugins.VelocityReport.previewReport()
whether calling with a String or a Template File name.

Code: Select all
JavaException: java.lang.ClassCastException: com.servoy.j2db.server.ngclient.NGClientPluginAccessProvider incompatible with com.servoy.j2db.server.headlessclient.IWebClientPluginAccess


I have no idea how to begin working out what to do about this error; any indicators would be much appreciated.
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am

Re: ClassCastException from Velocity

Postby ptalbot » Mon May 24, 2021 9:24 pm

The previewReport() is used to show a window that contains the preview of the filled template.
It works with Smart Client and Web Client but not in NG.

However, you can easily use the getPDFReport() which will return the bytes of the PDF report, which you can then either store on the server, or push to the client to be displayed in the PDF viewer (using a form variable as dataProvider for example)
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: ClassCastException from Velocity

Postby roddy » Tue May 25, 2021 12:41 am

Thanks for the response; it looks like the getPDFReport() is what uses the Eastwood dependency? Is this the engine that translates the HTML to PDF? With the Eastwood dependency, there is a the dependency on the reports folder, which seems to have examples and samples in it. Can we remove the files not part of the dependency as am not keen, if possible, to transfer samples and examples with the core of the app for migration.
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am

Re: ClassCastException from Velocity

Postby roddy » Tue May 25, 2021 1:01 am

Apologies if I am missing something; I am getting an exception after calling getPDFReport (am unable to catch it) with:
Code: Select all
ERROR com.servoy.j2db.util.Debug - IO problem for http://localhost:8080/eastwood/reports/styles.css
   at /Users/roddy/git/servoy/mod_ui/printing.js:213 (printEstimate_velocity)
java.net.ConnectException: Connection refused

followed by:
Code: Select all
ERROR com.servoy.j2db.util.Debug - InputStream is null for URI http://localhost:8080/eastwood/reports/styles.css
   at /Users/roddy/git/servoy/mod_ui/printing.js:213 (printEstimate_velocity)


The Eastwood WAR is placed in the webapps folder. Have also placed the velocity_listener.jar in the lib folder and the unzipped report file in the configured velocityreport.reportfolder directory (where it is picking up the file for the renderTemplate() function call). The velocityreport.serverURL has been setup to http://localhost:8080/.

I also removed the pdf_output files just in case because of the iText jar conflict mentioned in your documentation and have restarted the Servoy Developer quite a few times to ensure the configuration is picked up.

There are no charts in this template (is very simple), so am not sure why it is trying to stream something to Eastwood?
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am

Re: ClassCastException from Velocity

Postby roddy » Tue May 25, 2021 4:01 am

I've found the issue causing the exception; it is the
Code: Select all
   <link rel="stylesheet" type="text/css" media="all" href="styles.css"/>


Taken from the example templates. Does this entail that there needs to be a styles file somewhere? The $baseHREF has been set in the file; from reading the docs, this would indicate it is taking it from the reports files I unzipped into the required directory?
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am

Re: ClassCastException from Velocity

Postby ptalbot » Wed May 26, 2021 12:39 am

$baseHREF is tricky, it's trying to find the URL of the reports folder. I might deprecate it altogether.
Because it's hard to find it when it's deployed on a server inside a context for example, in Developer it's trying to read the servoy.properties for the velocityreport.reportFolder property, but on a server, it will not reliably find it.

Easiest is to make sure your href is either using a full url (http://domain[:port]//path/to/css/) or using a relative url, which should be relative to the location of the template itself.

So if your template is in /reports/templates/ and you have a css file in /reports/templates/css/styles.css you should be able to use href="css/styles.css"
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: ClassCastException from Velocity

Postby ptalbot » Wed May 26, 2021 12:42 am

You could also take advantage of the #include() directive and include the content of your css file inline, so add something like the following in your html header:

Code: Select all
<style>
   #include("css/styles.css")
</style>


where the css file is located in a "css" subfolder, relative to your template.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: ClassCastException from Velocity

Postby roddy » Thu May 27, 2021 1:00 am

Thanks, that is really good to know :-)
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 18 guests