2016-04-27 63 views
0

我正在嘗試使用Lucene搜索我的實用程序。該應用程序在jboss上運行,搜索代碼寫入ejb bean。IllegalAccessError:org/apache/lucene/index/DirectoryReader

public List<String> textSearch(String text,String folder,String subfolder) throws IOException, RemoteException{ 

    final String indexloc="/index/"+folder+"/"+subfolder; 
    IndexReader reader = DirectoryReader.open(FSDirectory.open(new File(indexloc))); 
      List<String> data = new ArrayList<String>(); 
      String fileList; 
      try { 
        IndexSearcher searcher = new IndexSearcher(reader); 
        TopScoreDocCollector collector = TopScoreDocCollector.create(500, true); 

        Query q = new QueryParser(Version.LUCENE_CURRENT, "contents", analyzer).parse(text); 
        searcher.search(q, collector); 
        ScoreDoc[] hits = collector.topDocs().scoreDocs; 
        for(int i=0;i<hits.length;++i) { 
         int docId = hits[i].doc; 
         Document d = searcher.doc(docId); 

         data.add(d.get("FileName")); 

        } 
      }catch(ParseException pe) 
      {} 
      catch(Exception e) { 
        logger.log(Level.SEVERE,"Error:" + e); 
      } 


      return data; 
} 

當應用程序在調用當前內部豆遙控功能,我收到以下錯誤:

java.lang.IllegalAccessError: org/apache/lucene/index/DirectoryReader 
at offlineMApackage.TextSearchSessionBean.textSearch(TextSearchSessionBean.java:73) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.jboss.invocation.Invocation.performCall(Invocation.java:386) 
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:228) 
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:156) 
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:173) 
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63) 
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121) 
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350) 
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181) 
at org.jboss.ejb.plugins.SecurityInterceptor.process(SecurityInterceptor.java:267) 
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:211) 
at org.jboss.ejb.plugins.security.PreSecurityInterceptor.process(PreSecurityInterceptor.java:134) 
at org.jboss.ejb.plugins.security.PreSecurityInterceptor.invoke(PreSecurityInterceptor.java:81) 
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205) 
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138) 
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:650) 
at org.jboss.ejb.Container.invoke(Container.java:1029) 
at sun.reflect.GeneratedMethodAccessor309.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) 
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) 
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) 
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668) 
at org.jboss.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:232) 
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:891) 
at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:744) 
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:697) 
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:551) 
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:232) 

請建議的東西,如果沒有人遇到過類似的問題..?

回答

0

好了,我的問題得到解決,通過在jboss lib文件夾中包含lucene jars並設置適當的類路徑。