lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: Lucene Applet
Date Mon, 18 May 2009 01:53:20 GMT

Petros,

Perhaps this old thread will help: http://markmail.org/thread/k3y4d32adwnhbvhw

Otis
--
Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch



----- Original Message ----
> From: Petros <css03045_pet@yahoo.gr>
> To: java-user@lucene.apache.org
> Sent: Sunday, May 17, 2009 2:24:04 PM
> Subject: Lucene Applet
> 
> 
> Hello there.
> 
> I am developing a Lucene search which will search text files 
> using an applet as GUI.
> I create the index file and the searching works 
> when I am running the application from the command line.
> However when I run the applet and I make a searching 
> I get the error :
> 
> Exception in thread "AWT-EventQueue-2" java.lang.ExceptionInInitializerError
>     at gui.search(gui.java:105)
>     at gui$ButtonListener.actionPerformed(gui.java:71)
>     at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>     at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>     at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>     at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
>     at java.awt.Component.processMouseEvent(Unknown Source)
>     at javax.swing.JComponent.processMouseEvent(Unknown Source)
>     at java.awt.Component.processEvent(Unknown Source)
>     at java.awt.Container.processEvent(Unknown Source)
>     at java.awt.Component.dispatchEventImpl(Unknown Source)
>     at java.awt.Container.dispatchEventImpl(Unknown Source)
>     at java.awt.Component.dispatchEvent(Unknown Source)
>     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>     at java.awt.Container.dispatchEventImpl(Unknown Source)
>     at java.awt.Component.dispatchEvent(Unknown Source)
>     at java.awt.EventQueue.dispatchEvent(Unknown Source)
>     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>     at java.awt.EventDispatchThread.run(Unknown Source)
> Caused by: java.security.AccessControlException: access denied
> (java.util.PropertyPermission
> org.apache.lucene.analysis.standard.StandardAnalyzer.replaceInvalidAcronym
> read)
>     at java.security.AccessControlContext.checkPermission(Unknown Source)
>     at java.security.AccessController.checkPermission(Unknown Source)
>     at java.lang.SecurityManager.checkPermission(Unknown Source)
>     at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
>     at java.lang.System.getProperty(Unknown Source)
>     at
> org.apache.lucene.analysis.standard.StandardAnalyzer.(StandardAnalyzer.java:50)
>     ... 26 more
>     
>     
>     Code:
>     
>     
> import java.applet.Applet;
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> import java.io.IOException;
> import java.io.StringReader;
> import org.apache.lucene.queryParser.ParseException;
> import java.lang.*;
> import java.io.*;
> import java.util.*;
> import org.apache.lucene.search.Hits;
> import org.apache.lucene.search.Query;
> import org.apache.lucene.document.Field;
> import org.apache.lucene.search.Searcher;
> import org.apache.lucene.index.IndexWriter;
> import org.apache.lucene.document.Document;
> import org.apache.lucene.store.FSDirectory;
> import org.apache.lucene.search.IndexSearcher;
> import org.apache.lucene.queryParser.QueryParser;
> import org.apache.lucene.analysis.standard.StandardAnalyzer;
> import org.apache.lucene.analysis.Analyzer;
> import org.apache.lucene.search.ScoreDoc;
> import org.apache.lucene.search.TopDocCollector;
> import org.apache.lucene.store.Directory;
> 
> public class gui extends JApplet
> {
>     private Container myContainer;
>     private JTextField myField=new JTextField(20);
>     private JLabel myLabel=new JLabel();
>     String terms=new String();
>     
>     public void init() 
>     {
>         myContainer=getContentPane();
>         myContainer.setLayout(new FlowLayout());
>         JLabel searchLabel=new JLabel("Search");
>         myContainer.add(searchLabel);
>         myContainer.add(myField);
>         JButton myButton=new JButton("start search");
>         myContainer.add(myButton);
>         ButtonListener myListener=new ButtonListener();
>         myButton.addActionListener(myListener);
>         myContainer.add(myLabel);
>     }
>     
>     
>     
>     private class ButtonListener implements ActionListener 
>     {
>         public void actionPerformed(ActionEvent event)
>         {
>             try
>             {
>                terms=myField.getText();
>                 search();
>            }
>         catch(IOException ioe)
>         {}
>            catch(ParseException pe)
>            {}
>         }
>     }
>     
>     public void search() throws IOException, ParseException
>     {
>         StandardAnalyzer analyzer = new StandardAnalyzer();
>         myLabel.setText( terms );
>         
>         Query q = new QueryParser("article", analyzer).parse(terms);
> 
>         int hitsPerPage = 40;
>         IndexSearcher searcher = new
> IndexSearcher(FSDirectory.getDirectory("lucene-index"));
>         
>         
>         TopDocCollector collector = new TopDocCollector(hitsPerPage);
>         searcher.search(q, collector);
>         ScoreDoc[] hits = collector.topDocs().scoreDocs;
>     
>         String filename1="results_machine";
>         
>         FileWriter writeConnToFile = new FileWriter(filename1);
>         PrintWriter printFile = new PrintWriter(new
> BufferedWriter(writeConnToFile));
>     
>         System.out.println("Found " + hits.length + " hits.");
>         for(int i=0;i
>         {
>             int docId = hits[i].doc;
>             Document d = searcher.doc(docId);
>             printFile.println(d.get("docno"));
>             //System.out.println((i + 1) + ". " +
> d.get("headline")+"\n"+"\n"+"\n");
>         }
>         printFile.close();
>         searcher.close();      
>     }
> }
> 
> 
> Thanks
> Petros 
>     
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Lucene-Applet-tp23586143p23586143.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message