As part of my studies I need to implement a custom Lucene codec, targetting Lucene 5.3.1.
I've tried following the instructions here:
http://opensourceconnections.com/blog/2013/06/05/build-your-own-lucene-codec/ to get started, but I am having some trouble getting the codec to load when running Lucene tests.
I've uploaded a minimal project at https://github.com/sigbjornlo/codecs
Running mvn package generates a jar with a file META-INF/services/org.apache.lucene.codecs.Codec containing a single line:
edu.ntnu.sigbjornlo.codecs.HelloCodec
...which is where the codec class resides at. It's just a FilterCodec subclass that does nothing extra.
Running ant -Dtestcase=TestSegmentTermDocs -Dtests.codec=HelloCodec -lib /path/to/hello-1.0.jar test gives me the following error:
java.lang.IllegalArgumentException:
An SPI class of type org.apache.lucene.codecs.Codec with name 'HelloCodec' does not exist.
You need to add the corresponding JAR file supporting this SPI to your classpath.
The current classpath supports the following names: [SimpleText, Asserting, CheapBastard, FastCompressingStoredFields, FastDecompressionCompressingStoredFields, HighCompressionCompressingStoredFields, DummyCompressingStoredFields, Lucene53]
What might I be doing wrong here? Is there any way to make Lucene's SPI loader log what it's trying and/or failing to load, and why?
Related
Can someone tell me how to get protoc to generate dart files with a leading library directive?
I'm using the dart-protoc-plugin (v0.10.2) to generate my dart, c++, c#, js and java models from proto files. I was under the impression there was no way to get protoc to add a 'library' directive to the generated dart files, until I noticed the directive appearing in another project (see date.pb.dart).
If I take the same file (date.proto) I cannot get protoc to generate a dart file containing a 'library' directive.
In short: I want to take a .proto file with the following content
syntax = "proto3";
package another.proj.nspace;
message MyObj {
...
}
and produce a .dart file with a leading 'library' directive similar to the following snippet
///
// Generated code. Do not modify.
///
// ignore_for_file: non_constant_identifier_names,library_prefixes
library another.proj.nspace;
...
NOTE: I don't care about the actual value of the directive since I can restructure my code to get the desired result. I just need a way for protoc to add the library directive...
The basic command I'm using to generate the dart files is
protoc --proto_path=./ --dart_out="./" ./another/proj/nspace/date.proto
Unfortunately the dart-protoc-plugin's README isn't very helpful and I had to go through the source to find out which options are available; and currently it seems like the only dart-specific option is related to grpc.
I've tried options from the other languages (e.g. 'library', and 'basepath') without any success.
It would simplify my workflow quite a bit if this is possible, but I'm starting to get the impression that the library directive in date.pb.dart is added after the code was generated...
After asking around a little bit, it seems that the library directive was removed from the protoc plugin at some stage (see pull request), thus it is no longer supported.
I want to get access to external YAML file which I specify through command-line argument:
java -jar target/app-thorntail.jar -s./test.yaml
This file I need to use to get my custom properties tree by SnakeYaml.
You can use #Inject #ConfigurationValue for your custom properties, and you can #Inject a ConfigView to read the entire configuration tree. I believe that should be enough for your usecase. This approach will also provide correct values in case multiple configuration files are used.
I'm not sure if you can get access to the file itself, except maybe provide a custom main method and parse the command-line arguments yourself.
I want to extract some specific resource from jar (which, in turn, is downloaded as a part of http archive) and while I know how to achieve this in principle I don't know what is the most bazelish and minimal way to achieve this.
I've naïvely tried (after reading this answer) to do something like this:
new_http_archive(
name="some_jar_contents",
url="#some_archive//:lib/some_jar.jar",
build_file_content="""
filegroup(
name = "srcs",
srcs = glob(["*"]),
visibility = ["//visibility:public"]
)
"""
)
However, I'm predictably getting java.net.MalformedURLException: no protocol:
The problem you are getting is caused by the fact that Bazel does not understand the url #some_archive//:lib/some_jar.jar.
It cannot infer the protocol to use for fetching the Jar, and the exception is thrown.
The rule new_http_archive is intended to be used for fetching a compressed archive from certain remote location, then build & expose it as an external target to current repo.
You need to change the url parameter to the actual URL in order to let Bazel fetch the Jar with the resource you want to extract.
Then, in build_file_content parameter part, use genrule to move the desired resource file, and export it.
A working example can be found in this private gist.
The example does the following things:
Fetches the Jar for AutoValue in WORKSPACE
Uses genrule to extract the autovalue.vm file from the Jar
Have a Python Program that reads and prints content of autovalue.vm
Helpful resources:
genrule
"Make" Variables
Updating the runfiles tree structure
I use java and saxonee-9.5.1.6.jar included build path , when run, getting these errors at different times.
Error at xsl:import-schema on line 6 column 169 of stylesheet.xslt:
XTSE1650: net.sf.saxon.trans.LicenseException: Requested feature (xsl:import-schema)
requires Saxon-EE
Error on line 1 column 1
SXXP0003: Error reported by XML parser: Content is not allowed in prolog.
javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
I open .xslt file in hex editor and dont see any different character at the beginning AND
I use transformerfactory in a different project but any error I get.
Check what the implementation class of tFactory is. My guess is it is probably net.sf.saxon.TransformerFactoryImpl - which is basically the Saxon-HE version.
When you use JAXP like this, you're very exposed to configuration problems, because it loads whatever it finds sitting around on the classpath, or is affected by system property settings which could be set in parts of the application you know nothing about.
If your application depends on particular features, it's best to load a specific TransformerFactory, e.g. tFactory = new com.saxonica.config.EnterpriseTransformerFactory().
I don't know whether your stylesheet expects the source document to be validated against the schema, but it it does, note that this isn't automatic: you can set properties on the factory to make it happen.
I would recommend using Saxon's s9api interface rather than JAXP for this kind of thing. The JAXP interface was designed for XSLT 1.0, and it's a real stretch to use it for some of the new 2.0 features like schema-awareness: it can be done, but you keep running into limitations.
I'm unable to pack taglibrary in a war file. I moved tags from project to extra library the current project is depending now. I put the taglibrary file into the META-INF directory of the jar containing tags (how is described here). But the page does not work:
Expression Error: Named Object: eu.barbucha.barbatag.simple.PropertyTag not found.
The server is able to find the taglibrary. Otherwise the page works, just one waring appears:
Warning: This page calls for XML namespace http://barbucha.eu/tags declared with prefix br but no taglibrary exists for that namespace.
Thus the question is: Why the server finds just the descriptor, but not the classes? When I copy classes from WEB-INF/lib/barbatag.jar into WEB-INF/classes and restart the webapp in administration console, the page gets working. The server also finds UI-components only if they are involved directly in classes of the applictation, but not in the jar stored in the WEB-INF/lib directory. On other hand the server loads taglib descriptor from the jar. It's really confusing... Declaration of the critical class:
package eu.barbucha.barbatag.simple;
#FacesComponent("eu.barbucha.barbatag.simple.PropertyTag")
public class PropertyTag extends UIComponentBase { ... }
Definition of critical tag:
<tag>
<display-name>The component taking values from a property file</display-name>
<tag-name>property</tag-name>
<component>
<component-type>eu.barbucha.barbatag.simple.PropertyTag</component-type>
</component>
</tag>
One potentionally important point: I'm using Spring MVC.
You need to supply a /META-INF/faces-config.xml file in the JAR in order to get JSF to scan the JAR file for classes with JSF specific annotations like #FacesComponent. This is done so to prevent JSF from unnecessarily scanning every single JAR file for classes (which might be very time and CPU consuming if you have lot of them).