XPath can't find an engine - java

I inherited some code that is using XPath for which I am a novice. I have it now so that it loads the document, but when the document.selectPath(queryPath) it always fails with the following error:
java.lang.RuntimeException: Trying XBeans path engine... Trying XQRL... Trying delegated path engine... FAILED on //
at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:173)
at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:130)
at org.apache.xmlbeans.impl.store.Cursor._selectPath(Cursor.java:902)
at org.apache.xmlbeans.impl.store.Cursor.selectPath(Cursor.java:2634)
at org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:462)
at org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:446)

Thank you jor for the post. I was confused as earlier commands to xml beans were successful.
Without saxon, this still works:
MapDocument doc;
...
String cityQuery = "$this//City";
XmlObject[] cities = doc.selectPath(cityQuery);
However saxon is required for explicit selection of fields within tags:
String aveQuery= "$this//Street[Kind='Avenue']";
XmlObject[] avenues = doc.selectPath(aveQuery); // RuntimeException without saxon on path
java.lang.RuntimeException:
Trying XBeans path engine... Trying XQRL... Trying delegated path engine... FAILED on $this//Street[Kind='Avenue']
I hope this might be of use to others that encounter a similar issue.

You need an XPath engine in your classpath, which one bepends on the XMLBeans version, see
http://wiki.apache.org/xmlbeans/XmlBeansFaq#whatJars

The movement if you have [] in your xpath, it is searching for the external xpath enginer.. you have to download saxonb9-0-0-4j & xmlbeans-xpath-2.4.0.jar and add to the classpath

worked for me:
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>10.6</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
</dependency>

Related

Dynamic Reports - ".toPdf(<<filepath>>)" function is not working in Java

I am using Java 8 and Dynamic reports version is 6.0.0.
In pom.xml, I have added this dependency :
<dependency>
<groupId>net.sourceforge.dynamicreports</groupId>
<artifactId>dynamicreports-core</artifactId>
<version>6.0.0</version>
</dependency>
This code is to generate the report parameters:
JasperReportBuilder report = new JasperReportBuilder();
report.setPageMargin(DynamicReports.margin().setLeft(30).setRight(30).setTop(10).setBottom(10));
report.setPageFormat(PageType.A4, PageOrientation.PORTRAIT);
report.title(cmp.subreport(subReport1));
Here, the variable subreport1 contains all the report data. They are verified to be correct.
After generating all the report data, this is the code I execute to write the report details into a file:
FileOutputStream st = new FileOutputStream("<<DUMMY_FILE_PATH>>");
report.toPdf(st);
At this line where .toPdf is present, the following exception is being thrown:
Exception in thread "main" java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.<init>(SimpleFontExtensionHelper.java:149)
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.getInstance(SimpleFontExtensionHelper.java:131)
at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.ensureFontExtensions(FontExtensionsRegistry.java:80)
at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:57)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:130)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:277)
at net.sf.jasperreports.engine.fonts.FontUtil.getFontInfo(FontUtil.java:191)
at net.sf.jasperreports.engine.fonts.FontUtil.getFontInfo(FontUtil.java:291)
at net.sf.jasperreports.engine.fonts.FontUtil.getAwtFontFromBundles(FontUtil.java:476)
at net.sf.jasperreports.engine.fonts.FontUtil.getAwtFontFromBundles(FontUtil.java:466)
at net.sf.dynamicreports.design.transformation.StyleResolver.getFont(StyleResolver.java:122)
at net.sf.dynamicreports.design.transformation.StyleResolver.getFont(StyleResolver.java:100)
at net.sf.dynamicreports.design.transformation.StyleResolver.getFontHeight(StyleResolver.java:69)
at net.sf.dynamicreports.design.transformation.TemplateTransform.getTextFieldHeight(TemplateTransform.java:1391)
at net.sf.dynamicreports.design.transformation.ComponentTransform.textField(ComponentTransform.java:395)
at net.sf.dynamicreports.design.transformation.ComponentTransform.component(ComponentTransform.java:155)
at net.sf.dynamicreports.design.transformation.ComponentTransform.list(ComponentTransform.java:303)
at net.sf.dynamicreports.design.transformation.BandTransform.band(BandTransform.java:231)
at net.sf.dynamicreports.design.transformation.BandTransform.transform(BandTransform.java:86)
at net.sf.dynamicreports.design.base.DRDesignReport.transform(DRDesignReport.java:155)
at net.sf.dynamicreports.design.base.DRDesignReport.<init>(DRDesignReport.java:127)
at net.sf.dynamicreports.design.base.DRDesignReport.<init>(DRDesignReport.java:111)
at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperReportDesign(JasperReportBuilder.java:299)
at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.getJasperParameters(JasperReportBuilder.java:346)
at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperPrint(JasperReportBuilder.java:363)
at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.export(JasperReportBuilder.java:896)
at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toPdf(JasperReportBuilder.java:735)
at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toPdf(JasperReportBuilder.java:724)
Please let me know the solution for this error.
I found the actual solution. There was a version mismatch between xerces jar and dynamic reports jar. It was resolved by adding the following dependency :
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>

Can't load Phoenix JDBC driver for Storm's JdbcInsertBolt

During initialization of Apache's Storm JdbcInsertBolt I get an error
java.lang.ClassCastException:
Cannot cast org.apache.phoenix.jdbc.PhoenixDriver to javax.sql.DataSource
at com.zaxxer.hikari.util.UtilityElf.createInstance(UtilityElf.java:90)
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:292)
at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:84)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:102)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:71)
at org.apache.storm.jdbc.common.HikariCPConnectionProvider.prepare(HikariCPConnectionProvider.java:53)
at org.apache.storm.jdbc.mapper.SimpleJdbcMapper.<init>(SimpleJdbcMapper.java:43)
from the underlying HikariCPConnectionProvider. Whats wrong?
I am following http://storm.apache.org/releases/1.1.2/storm-jdbc.html, here is what I am doing based on that:
I like to write data from a Apache Storm topology to a HBase table via Phoenix. For that I downloaded the driver-file (phoenix-4.7.0.2.6.5.3003-25-client.jar) from my cluster-Server and added it to my local maven repository:
mvn install:install-file
-Dfile=lib\phoenix-4.7.0.2.6.5.3003-25-client.jar
-DgroupId=org.apache.phoenix
-DartifactId=phoenix-jdbc -Dversion=4.7.0 -Dpackaging=jar
After that I updated my .pom:
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-jdbc</artifactId>
<version>4.7.0</version>
</dependency>
Now add Storm's JDBC-Bolt:
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-jdbc</artifactId>
<version>1.2.2</version>
<scope>provided</scope>
</dependency>
and I am set-up to use the bolt. First: Setup Connection-Provider:
Map hikariConfigMap = new HashMap();
hikariConfigMap.put("dataSourceClassName", "org.apache.phoenix.jdbc.PhoenixDriver");
hikariConfigMap.put("dataSource.url", "<zookeeperQuorumURI>:2181:/hbase-unsecure");
this.connectionProvider = new HikariCPConnectionProvider(hikariConfigMap);
Now initialize the tuple-values-to-db-columns-mapper
this.simpleJdbcMapper = new SimpleJdbcMapper(this.tablename, connectionProvider);
During this the error mentioned above happens.
Just for completeness: The JdbcInsertBolt gets created like this:
new JdbcInsertBolt(this.connectionProvider, this.simpleJdbcMapper)
.withTableName(this.tablename)
.withQueryTimeoutSecs(30);
have you tried to set :
driverClassName -> org.apache.phoenix.jdbc.PhoenixDriver. The current code seems to have set the dataSourceClassName which is different i guess
Refering this

Azure - NoSuchMethodExist error in ApplicationTokenCredential while trying to get key from keyVault

I am trying to get key in this way:
private static String getPolicyKey(String secretName, String keyVaultUrl, String applicationId, String applicationSecret) {
KeyVaultClient keyVaultClient = new KeyVaultClient(new ApplicationTokenCredentials(
applicationId, // Application ID
"myDomain.com", // Azure Active Directory Domain
applicationSecret, // Application Key Value
AzureEnvironment.AZURE
));
return keyVaultClient.getSecret(
keyVaultUrl, // KeyValut URL
secretName // Secret Name
).value();
}
But I am getting an Exception:
java.lang.NoSuchMethodError: com.microsoft.azure.credentials.ApplicationTokenCredentials.proxy()Ljava/net/Proxy;
at com.microsoft.azure.credentials.ApplicationTokenCredentials.acquireAccessToken(ApplicationTokenCredentials.java:137)
at com.microsoft.azure.credentials.ApplicationTokenCredentials.getToken(ApplicationTokenCredentials.java:127)
at com.microsoft.azure.credentials.AzureTokenCredentials.getToken(AzureTokenCredentials.java:39)
at com.microsoft.azure.credentials.AzureTokenCredentialsInterceptor.intercept(AzureTokenCredentialsInterceptor.java:36)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
at okhttp3.RealCall.execute(RealCall.java:57)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(RxJavaCallAdapterFactory.java:171)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:152)
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:138)
at rx.Observable.unsafeSubscribe(Observable.java:10142)
I am using the following dependencies:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs</artifactId>
<version>0.15.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-authentication</artifactId>
<version>1.1.0</version>
</dependency>
Note: I tried with azure-eventhubs version 1.0.1 but even that gave same error.
This is my first time dealing with azure-eventhubs, any kind of direction on this will be extremely helpful.
In Maven, when you have a transitive dependency shared between multiple direct dependencies at the same distance (or depth), the one that will end up in your dependency tree will be one coming from the first direct dependency in order of appearance.
Since com.microsoft.azure:azure-keyvault:1.0.0 appears first in your POM, the project will end up with version 1.0.0 of com.microsoft.azure:azure-client-runtime, which is where the class that would contain the proxy() method resides. The problem is that this method was introduced until version 1.1.0
What you can do here is swapping the order in which the Azure Key Vault and Azure Client Authentication dependencies appear. Another thing you can do is directly declare which version of azure-client-runtime you want to use in your POM:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-runtime</artifactId>
<version>1.1.0</version>
</dependency>

SASS is prepending unicode content with backslash (\)

Problem
I'm trying to produce some unicode characters after compiling my *.scss file.
As an example, I have the following (SCSS):
.element:after {
content: "\a0";
}
When the file is compiled, it outputs the following (CSS):
.element:after {
content: "\\a0";
}
Notice the extra unwanted backslash (\).
Attempted Solution #1
I did try the solution here: Sass: unicode escape is not preserved in .css file, which suggests introducing the following function:
#function unicode($str) {
#return unquote("\"")+unquote(str-insert($str, "\\", 1))+unquote("\"")
}
And using it like so (SCSS):
.element:after {
content: unicode("a0");
}
However, this produces the following (CSS)
.element:after {
content: "\\" ")+unquote(str-insert($str, " \\\\ ", 1))+unquote(" \\ "";
}
Notice, it's not even invoking the function as intended. Why is that?
Project Details
I'm using these libraries in Maven:
<dependency>
<groupId>net.jawr</groupId>
<artifactId>jawr-core</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>net.jawr.extensions</groupId>
<artifactId>jawr-spring-extension</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>com.darrinholst</groupId>
<artifactId>sass-java-gems</artifactId>
<version>3.4.20.0</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-core</artifactId>
<version>9.1.5.0</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-stdlib</artifactId>
<version>9.1.5.0</version>
</dependency>
Temporary solution
Don't use unicodes in SCSS. Instead, use Font Awesome in the HTML (keeping Font Awesome in a CSS file).
I had the same issue while trying to use a custom icons font. The solution I found is creating a mixin which looks like this :
#mixin class-for-icon($name, $code) {
.icon-#{$name}::before {
content: unquote("\"\\#{$code}\"");
}
}
And then I can use it like this :
#include class-for-icon('myIcon', 'e1ff');
/* generates */
.icon-myIcon::before {
content: "\e1ff";
}
I use node-sass 4.5.3 to compile my sass files into css, and this is working well (currently using it in production on a few projects)
Hope this helps !

Which version of Velocity Template will support map creation

Am sending map and accessing in velocity template version 1.2 but I tried to create map in vm I couldn't create and getting exception.Please give you guidance.
#set($buyerActionStat = {
"0":"New",
"5":"Response-Acknowledged",
"6":"Response-Accepted",
"7":"Response-Rejected"
})
Exception :
org.apache.velocity.exception.ParseErrorException: Lexical error: org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 5, column 25. Encountered: "{" (123), after : ""
at org.apache.velocity.Template.process(Template.java:181)
at org.apache.velocity.runtime.resource.ResourceManager.getResource(ResourceManager.java:327)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:736)
at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:355)
at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:533)
at ecnet.rd.core.template.TemplateResolver.<init>(TemplateResolver.java:45)
at ecnet.rd.core.template.TemplateResolver.getInstance(TemplateResolver.java:34)
at ecnet.rd.helper.AMECPOHelper.mergePOTemplate(AMECPOHelper.java:71)
the expcetion is caused by velocity versions only.
Use apache velocity version 1.6.2 or later versions.
Maven dependency
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.6.2</version>
</dependency>

Categories