Hi,
Yes you are right, using the ClasspathResourceLoader class did solved the issue, passing my on class as parameter: ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader(MySearchApp.class); Analyzer analyzer = CustomAnalyzer.builder(resourceLoader) .withTokenizer(StandardTokenizerFactory.class) .addTokenFilter(StandardFilterFactory.class) .addTokenFilter(LowerCaseFilterFactory.class) .addTokenFilter(ASCIIFoldingFilterFactory.class) .addTokenFilter(StopFilterFactory.class, "ignoreCase", "true", "words", "", "format", "wordset") .build(); As you can see, what I am trying to achieve is to add ASCIIFolfingFilterFactory to a custom analyzer chain. Thanks very much! Leonardo. ________________________________ From: Uwe Schindler <u...@thetaphi.de> Sent: 30 March 2017 02:58 AM To: java-user@lucene.apache.org Subject: RE: CustomAnalyzer.Builder builder() Hi, the resources must be setup inside the JAR file in the same way like in classpath of your IDE. As you did not give any examples and also removed the resource name from your stack trace so we cannot figure out what you are doing! The default builder uses the context classloader of current thread. This means that your application server (runtime environment) has to be setup correctly. In most cases for production use this is not ideal, as you have no control where the classes are loaded from and leave it to the externally defined properties. To fully define where the reosurces should be loaded from, construct your own ClasspathResourceLoader, e.g. by giving your own class as parameter. Then all resources are loaded directly from you Class's package inside the JAR file. You say that you have the resources below META-INF: If you do this, the path you pass to load the resources must also start with /META-INF! Resources in Java have nothing to do with the META-INF folder. They are loaded like classes from the root folder of the JAR, so the path must be relative to JAR file's root. Uwe ----- Uwe Schindler Achterdiek 19, D-28357 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: Leonardo Pérez Pulido [mailto:leoperezpul...@hotmail.com] > Sent: Thursday, March 30, 2017 12:34 AM > To: java-user@lucene.apache.org > Subject: CustomAnalyzer.Builder builder() > > Hi, > > > The documentation for the CustomAnalyzer Analyzer is very specific, one can > create an instance of a custom analyzer in three different ways. > > > Using the default CustomAnalizer.builder(...), is supposed to load all > resources from the classpath, and it works ok inside the IDE. But when I > deploy the app I get the exception: > > > java.io.IOException: Resource not found: > > at > org.apache.lucene.analysis.util.ClasspathResourceLoader.openResource(Clas > spathResourceLoader.java:67) > at > org.apache.lucene.analysis.util.AbstractAnalysisFactory.getLines(AbstractAna > lysisFactory.java:254) > at > org.apache.lucene.analysis.util.AbstractAnalysisFactory.getWordSet(Abstract > AnalysisFactory.java:243) > at > org.apache.lucene.analysis.core.StopFilterFactory.inform(StopFilterFactory.ja > va:96) > at > org.apache.lucene.analysis.custom.CustomAnalyzer$Builder.applyResourceL > oader(CustomAnalyzer.java:413) > at > org.apache.lucene.analysis.custom.CustomAnalyzer$Builder.addTokenFilter( > CustomAnalyzer.java:308) > at > org.apache.lucene.analysis.custom.CustomAnalyzer$Builder.addTokenFilter( > CustomAnalyzer.java:299) > at mysearchapp.Page.<init>(Page.java:36) > at mysearchapp.MySearchApp.main(MySearchApp.java:53) > > > When I check the classpath for the resources inside MANIFEST.MF everything > seems to be in order. > > > > Leonardo. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org