name.package.class.Scriptlet resolves to package when report with Scriptlet on Jasper server

Hi

 

I'm trying to run a report that uses a scriptlet. I created a java file in src/com/av/jasper, then I Compiled it to a .class file and I then created a jar file out of the class file.

I included the jar for the scriptlet in the build path for the Project folder.

You can see that it's in the scr folder and Referenced Libraries.

This is the Scriptlet config:

I've imported them in report jrxml like this:

 

<import value="com.av.jasper.*"/>
<import value="cp,.av.jasper.GetExpressionFromStringScriptlet"/>
<scriptlet name="GET_EXPRESSION_FROM_STRING" class="com.av.jasper.GetExpressionFromStringScriptlet"/>

I've copied the file to apache-tomcat-9.0.54/webapps/jasperserver-pro/WEB-INF/lib/GetExpressionFromStringScriptlet.jar

Then I restarted the server, but it still fails with:

ERROR SecureExceptionHandlerImpl,pool-18-thread-1:125 - There was an error on the server. Try again or contact site administrators. (Error UID: b77e9879-0351-4a3d-a1a7-a380f1d4233
b). Errors were encountered when compiling report expressions class file:
1. Only a type can be imported. com.av.jasper.GetExpressionFromStringScriptlet resolves to a package
import com.av.jasper.GetExpressionFromStringScriptlet;
       <-------------------------------------------->
2. com.av.jasper.GetExpressionFromStringScriptlet cannot be resolved to a type
                value = ((com.av.jasper.GetExpressionFromStringScriptlet)parameter_GET_EXPRESSION_FROM_STRING_SCRIPTLET.getValue()).FormatString(); //$JR_EXPR_ID=26$
                          <-------------------------------------------->
3. com.av.jasper.GetExpressionFromStringScriptlet cannot be resolved to a type
                value = ((com.av.jasper.GetExpressionFromStringScriptlet)parameter_GET_EXPRESSION_FROM_STRING_SCRIPTLET.getValue()).FormatString(); //$JR_EXPR_ID=26$
                          <-------------------------------------------->
4. com.av.jasper.GetExpressionFromStringScriptlet cannot be resolved to a type
                value = ((com.av.jasper.GetExpressionFromStringScriptlet)parameter_GET_EXPRESSION_FROM_STRING_SCRIPTLET.getValue()).FormatString(); //$JR_EXPR_ID=26$
                          <-------------------------------------------->


I've also tried to upload the jar file as a resource for the report but it does nothing.

kry_1's picture
13
Joined: Sep 20 2022 - 2:21am
Last seen: 5 months 2 weeks ago

Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times.

mrajkuma - 5 months 4 weeks ago

1 Answer:

Hello,

while importing the package n jrxml report, we could see it was mentioned as wrong like cp, kindly correct and republish report.
<import value="cp,.av.jasper.GetExpressionFromStringScriptlet"/>


Also, you can try editing WEB-INF/applicationContext-adhoc.xml and add the following property somewhere inside the adhocEngineService bean:
<property name="reportUnitClassLoadingEnabled" value="true"/>
Reference : https://community.tibco.com/s/article/jasperserver-unable-load-scriplet-...

Hope this will find you useful.

jphadtar's picture
1532
Joined: Mar 20 2022 - 10:51pm
Last seen: 13 min 5 sec ago
Feedback