XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
- Stylus Studio Technical Forum (14621)
-> + How to disable checking for up... (2)
-> + XML Publisher requires duplica... (4)
-> + Modifying Field Name in XML (4)
-> + Java Runtime Environmnet Libra... (2)
-> + Passing Parameters and Multipl... (4)
-> + Total Newbie Question... where... (3)
-> + XML Pipeline (2)
-> + Encoding problem in text previ... (5)
-> + New Installation on windows 20... (4)
-> - Exception while calling Java m... (1)
-> + Jars to be included for callin... (2)
-> + SXXP0003: Error reported by XM... (2)
-> + Validation error (5)
-> + Windows 10, latest Java, new t... (2)
-> + using help crashes stylus stud... (3)
-> + Web Service Call error (5)
-> + javax.xml.xquery.XQException: ... (2)
-> + Trang translator is not availa... (2)
-> + Replacement for flat2xml (2)
-> + CONV CSV Display Problem (3)
-- Previous [61-80] [81-100] [101-120] Next
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Posttop
sravya yarabatiSubject: Exception while calling Java methods.Java script from XSLT
Author: sravya yarabati
Date: 03 Dec 2015 08:51 AM
Originally Posted: 03 Dec 2015 08:50 AM
Hi,
I am getting below exceptions while executing the javascript/Java method from xslt using xalan.
I included bfs 2.4.jar,js 1.7.jar,xalan 2.7.jar in my class path. Please help in calling the javascript/java method from xslt and resolve these exceptions

Caused by: javax.xml.transform.TransformerException: Could not initialize BSF Manager
at org.apache.xalan.extensions.ExtensionHandlerGeneral.<init>(ExtensionHandlerGeneral.java:216)
... 21 more
---------
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.xalan.extensions.ExtensionNamespaceSupport.launch(ExtensionNamespaceSupport.java:95)
at org.apache.xalan.extensions.ExtensionsTable.<init>(ExtensionsTable.java:66)
at org.apache.xalan.transformer.TransformerImpl.setExtensionsTable(TransformerImpl.java:441)
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1312)
at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3447)
at org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:408)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:220)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:186)
at org.eclipse.wst.xsl.jaxp.debug.debugger.AbstractDebugger.run(AbstractDebugger.java:111)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.xml.transform.TransformerException: Could not initialize BSF Manager
at org.apache.xalan.extensions.ExtensionHandlerGeneral.<init>(ExtensionHandlerGeneral.java:216)
... 21 more
file:/C:/Users/syarabat/workspace/XSLExampleProject/files/JC_Test.xsl; Line #31; Column #42; java.lang.NullPointerException
------------------------------------------------------------------------

20:37:25,465 ERROR [main] JAXPSAXProcessorInvoker - The first argument to the non-static Java function 'getdate' is not a valid object reference.
20:37:25,470 ERROR [main] JAXPSAXProcessorInvoker - Could not compile stylesheet
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformerHandler(Unknown Source)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.addStylesheet(JAXPSAXProcessorInvoker.java:136)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.addStylesheet(JAXPSAXProcessorInvoker.java:127)
at org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition.addStyleSheet(PipelineDefinition.java:161)
at org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition.configure(PipelineDefinition.java:152)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.Main.main(Main.java:72)
20:37:25,477 FATAL [main] Main - Error with stylesheet: file:/C:/Users/syarabat/workspace/XSLExampleProject/files/JC_Test.xsl
org.eclipse.wst.xsl.jaxp.debug.invoker.internal.ConfigurationException: Error with stylesheet: file:/C:/Users/syarabat/workspace/XSLExampleProject/files/JC_Test.xsl
at org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition.addStyleSheet(PipelineDefinition.java:163)
at org.eclipse.wst.xsl.jaxp.debug.invoker.PipelineDefinition.configure(PipelineDefinition.java:152)
at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.Main.main(Main.java:72)

XSLT script:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:my-ext="ext1"
extension-element-prefixes="my-ext">
<xalan:component prefix="my-ext" elements="timelapse" functions="getdate">
<xalan:script lang="javascript">
var multiplier=1;
System.setProperty("org.apache.xalan.extensions.bsf.BSFManager","org.apache.bsf.BSFManager");
function timelapse(xslProcessorContext, elem)
{ multiplier=parseInt(elem.getAttribute("multiplier")); // The element return value is placed in the result tree. // If you do not want a return value, return null. return null; }
function getdate(numdays)
{ var d = new Date(); var totalDays = parseInt(numdays) * multiplier; d.setDate(d.getDate() + totalDays); return d.toLocaleString(); }
</xalan:script>
</xalan:component>
<xsl:template match="deadline">
<p><my-ext:timelapse multiplier="2"/>We have logged your enquiry and will
respond by <xsl:value-of select="my-ext:getdate(string(@numdays))"/>.</p>
</xsl:template>
</xsl:stylesheet>

XMl script

<?xml version="1.0" encoding="UTF-8"?>
<deadline>
<numdays>3</numdays>
</deadline>

Plese help in solving these

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.