Jump to content
We've recently updated our Privacy Statement, available here ×

Load image from byte[] error


Joe Taras
Go to solution Solved by Joe Taras,

Recommended Posts

I'm using JasperSoft Studio 6.8.0 and I've a struggling error:

I've a `logo` property of my Java class `EnvParameter`.

this property is a `byte[]`

I pass my Java class to Jasper Studio, so I try to load the image inside logo property as follow:

    net.sf.jasperreports.engine.util.JRImageLoader.loadAwtImageFromBytes($P{EnvParameter}.logo)

But I have this error:

> net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error
> evaluating expression for source text:
> net.sf.jasperreports.engine.util.JRImageLoader.loadAwtImageFromBytes($P{EnvParameter}.logo)
>     at
> net.sf.jasperreports.engine.fill.JREvaluator.handleEvaluationException(JREvaluator.java:284)
>     at
> net.sf.jasperreports.compilers.GroovyEvaluator.handleEvaluationException(GroovyEvaluator.java:98)
>     at
> net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:316)
>     at
> net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:672)
>     at
> net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:640)
>     at
> net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1169)
>     at
> net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:466)
>     at
> net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:440)
>     at
> net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:383)
>     at
> net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:548)
>     at
> net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:323)
>     at
> net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:150)
>     at
> net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:615)
>     at
> net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414)
>     at
> net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:814)
>     at
> net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:61)
>     at
> net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:221)
>     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>     at java.lang.Thread.run(Thread.java:745) Caused by:
> groovy.lang.MissingMethodException: No signature of method: static
> net.sf.jasperreports.engine.util.JRImageLoader.loadAwtImageFromBytes()
> is applicable for argument types: ([b) values: [[-119, 80, 78, 71, 13,
> 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, ...]] Possible solutions:
> loadAwtImageFromBytes([b)     at
> groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1518)
>     at
> groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504)
>     at
> org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52)
>     at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
>     at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
>     at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
>     at
> rptVTitolo_1558437271760_434544.evaluate(calculator_rptVTitolo_1558437271760_434544:203)
>     at
> net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:302)
>     ... 17 common frames omitted mag 21, 2019 1:17:36 PM
> org.apache.catalina.core.StandardWrapperValve invoke

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

is the parameter really passed for the fill process and also not null?

perhaps it's better to use a (commonpublic getter instead direct access to that field "logo" in your parameter-class "Env-Parameter"? 

So that you could use $P{EnvParameter}.getLogo()  as ImageExpression?

Otherwise you could also change the report-language from Groovy to Java... just to see, if the compile process already has problems with your expression.

hth + regards

C-Box

 

 

Link to comment
Share on other sites

Dear, I've tried to change my language from groovy to Java but I have a lot of errors as follow:

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. Only a type can be imported. it.uncertainty.dmn.EnvParameter resolves to a package
import it.uncertainty.dmn.EnvParameter;

all for all occurencies of EnvParameter I used in my report

 

My head bursts!

Link to comment
Share on other sites

How is the package-Structure of our class " EnvParameter"?  Is it

a) it.uncertainty.dmn.EnvParameter   (so that the full resolved class name incl. package would be: it.uncertainty.dmn.EnvParameter.EnvParameter)

or just

b) it.uncertainty.dmn  (so that the full resolved class name incl. package would be: it.uncertainty.dmn.EnvParameter )

??? The compile error message would tell me, that your  given import resolved is directing to a package and not to the concrete class... !??!

regards

C-Box

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...