Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 83488 invoked from network); 4 Jan 2010 21:33:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Jan 2010 21:33:25 -0000 Received: (qmail 43320 invoked by uid 500); 4 Jan 2010 21:33:23 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 43242 invoked by uid 500); 4 Jan 2010 21:33:23 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 43232 invoked by uid 99); 4 Jan 2010 21:33:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jan 2010 21:33:23 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of aseldawy@gmail.com designates 209.85.218.222 as permitted sender) Received: from [209.85.218.222] (HELO mail-bw0-f222.google.com) (209.85.218.222) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jan 2010 21:33:12 +0000 Received: by bwz22 with SMTP id 22so9758398bwz.5 for ; Mon, 04 Jan 2010 13:32:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=jzglZX/Phyr1I2deEYmJSXZvdRk/jKPDj1ous54qNkI=; b=Hs/RTvPnpJgN2e4VpSGmrA8Eslp0moH0K0YDp1yeQoxZy0TKnPx3yzqrDWpsSHzZ5w 9GaSilMyZfO1Je9At18SeECJZSEwXfF1VG7oKX1Lkn++OGITxUZMZA5umUDr3hN3kSqW rPor+tu0k7wSyc+uQpcCc3Ncb705RX3aOLwd8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=ZOSG8dxTD8NLB3JlsIBN4lcgoJnxopD5EQ47VyBsya5rE+iC7zbrHL16KEMzmdROGn lTzei6M4TLmQlzr65w+C6CzerKwE59iqbIr833EFeEfNzsIs3Dg6ZTECa+mHlVqReSon hg9ML5g5MypEt4olgX4ZvFvpSFz/y9KI9wqkA= MIME-Version: 1.0 Received: by 10.204.27.14 with SMTP id g14mr1416762bkc.15.1262640772176; Mon, 04 Jan 2010 13:32:52 -0800 (PST) In-Reply-To: References: <7054C18D96924AA187F6D3A3FBDFC8DB@VEGA> <6B18B9E94727414D87F8F7E91EBC5F90@VEGA> From: Ahmed El-dawy Date: Mon, 4 Jan 2010 23:32:32 +0200 Message-ID: Subject: Re: Using the new tokenizer API from a jar file To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=000325557b22b45d11047c5d7699 X-Virus-Checked: Checked by ClamAV on apache.org --000325557b22b45d11047c5d7699 Content-Type: text/plain; charset=UTF-8 Sorry for this delay. I was having a silly problem compiling solr but I figured it out. I tested it and it worked correctly. Thanks On Wed, Dec 30, 2009 at 8:31 PM, Uwe Schindler wrote: > That would be good, if you could test it! > > Please checkout Lucene 2.9 branch from svn > (http://svn.apache.org/repos/asf/lucene/java/branches/lucene_2_9), compile > the whole package (at least lucene-core.jar) and then replace the lucene > jar > files in solr's lib folder. > > Uwe > > ----- > Uwe Schindler > H.-H.-Meier-Allee 63, D-28213 Bremen > http://www.thetaphi.de > eMail: uwe@thetaphi.de > > > > -----Original Message----- > > From: Ahmed El-dawy [mailto:aseldawy@gmail.com] > > Sent: Wednesday, December 30, 2009 11:56 AM > > To: java-user@lucene.apache.org > > Cc: solr-user@lucene.apache.org > > Subject: Re: Using the new tokenizer API from a jar file > > > > Thanks all for your interest, especially Uwe. I asked this question on > > solr-user at the beginning but I got no reply. That's why I re-asked the > > question at java-user. > > Thanks for your efforts. I will try it now. > > > > On Mon, Dec 28, 2009 at 12:02 PM, Uwe Schindler wrote: > > > > > I opened https://issues.apache.org/jira/browse/LUCENE-2182 about this > > > problem and already have a fix. > > > > > > This is really a bug. The solution is simple because you have to load > > the > > > IMPL class using the same classloader as the passed in interface. The > > > default for Class.forName is the classloader of AttributeSource.class, > > > which > > > is the wrong one. > > > > > > ----- > > > Uwe Schindler > > > H.-H.-Meier-Allee 63, D-28213 Bremen > > > http://www.thetaphi.de > > > eMail: uwe@thetaphi.de > > > > > > > -----Original Message----- > > > > From: Uwe Schindler [mailto:uwe@thetaphi.de] > > > > Sent: Monday, December 28, 2009 9:20 AM > > > > To: java-user@lucene.apache.org > > > > Cc: solr-user@lucene.apache.org > > > > Subject: RE: Using the new tokenizer API from a jar file > > > > > > > > The question on this list was ok,as it shows a minor problem of using > > the > > > > new TokenStream API with Solr. > > > > > > > > His plugin was loaded correctly, because if Lucene says, that it > > cannot > > > > find > > > > the *Impl class, it was able to load the interface class before -> > the > > > JAR > > > > file is "visible" to the JVM. > > > > > > > > The problem is the following and has to do with classloaders: > > > > > > > > 1. We have different class loaders for different places in Solr. Solr > > > uses > > > > for plugins a SolrResourceLoader that searches for JAR files in the > > local > > > > lib folder before handling over to the webapp's classloader. > > > > > > > > 2. Initially, the lucene JAR is loaded by the Webapp's class loader > > > > > > > > 3. If a AttributeImpl is placed into a jar file e.g. in the plugin > > folder > > > > of > > > > solr (the lib folder where solr loads all resources, stop words,...), > > the > > > > loading mechanism inside AttributeSource.DEFAULT_ATTRIBUTE_FACTORY is > > > > unable > > > > to locate the class file, because Class.forName() always uses the > > class' > > > > classloader and not the global/thread one's. So AttributeSource will > > only > > > > find the class file if it is in the *same* directory as the lucene- > > > > core.jar > > > > file (WEB-INF/lib) and so accessible by the webapp's class loader. > > > > > > > > A good introduction about the problem is this one: > > > > > > > > > > http://www.theserverside.com/tt/articles/content/dm_classForname/DynLoad.p > > > > df > > > > > > > > The problem is here described for the JVM extensions folder but also > > > > applies > > > > to solr, because it has another classloader for plugins. > > > > > > > > A solution to fix this would be in lucene to use the thread's context > > > > class > > > > loader in AttributeSource.DEFAULT_ATTRIBUTE_FACTORY, but I strongly > > > > discourage this, as it would break the whole AttributeSource > > > functionality > > > > if you add two different attributes with same class names from > > different > > > > class loaders to the AttributeSource. > > > > > > > > The only solution to the problem is placing the JAR file inside the > > > > WEB-INF/lib folder where lucene-core.jar is. Plugins in Solr cannot > > > define > > > > own attribute implementations. Alternatively he could try to force > > > preload > > > > the class by calling Class.forName in his plugin initialization code > > on > > > > the > > > > Impl class. But I am not sure if this works (as Java handles classes > > from > > > > different classloaders different). > > > > > > > > Uwe > > > > > > > > ----- > > > > Uwe Schindler > > > > H.-H.-Meier-Allee 63, D-28213 Bremen > > > > http://www.thetaphi.de > > > > eMail: uwe@thetaphi.de > > > > > > > > > -----Original Message----- > > > > > From: Chris Hostetter [mailto:hossman_lucene@fucit.org] > > > > > Sent: Monday, December 28, 2009 4:27 AM > > > > > To: java-user@lucene.apache.org > > > > > Subject: Re: Using the new tokenizer API from a jar file > > > > > > > > > > > > > > > : I tried to use it with solr and the problems began. It's always > > > > telling > > > > > me > > > > > : that it cannot find the class GlossAttributeImpl. I think the > > problem > > > > is > > > > > : that my jar file is added to the class path at run time not from > > the > > > > > command > > > > > : line. Do you have a good solution or workaround? > > > > > > > > > > You're likely to get mmore helpful answers from other people in the > > > Solr > > > > > User community (solr-user@lucene.a.o) > > > > > > > > > > As long as you put your jar in the "lib" directory under your solr > > home > > > > > (or refrence it using a directive in your solrconfig.xml) > > Solr's > > > > > plugin loader will take care of hte classloading for you. > > > > > > > > > > if you are confident you have your jar in the correct place, please > > > > email > > > > > solr-user with the ClassNotFound stack trace from your solr logs, > as > > > > well > > > > > as hierarchy of files from your solr home (ie: the output of "find > > .") > > > > > > > > > > > > > > > -Hoss > > > > > > > > > > > > > > > > -------------------------------------------------------------------- > > - > > > > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > > > > > For additional commands, e-mail: java-user-help@lucene.apache.org > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > > > > For additional commands, e-mail: java-user-help@lucene.apache.org > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > > > For additional commands, e-mail: java-user-help@lucene.apache.org > > > > > > > > > > > > -- > > regards, > > Ahmed Saad > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > -- regards, Ahmed Saad --000325557b22b45d11047c5d7699--