Results 1 to 3 of 3
  1. #1
    RCruz is offline Member
    Join Date
    Mar 2013
    Posts
    6
    Rep Power
    0

    Default Desperation and and misadventures with java.lang.NoClassDefFoundError

    Hi fellows! I'm in a bit of a pickle with using our dear POI, for I'm having this dastard error and I really can't identify why it's happening.
    Would you guys mind helping me?

    My SO is win7(x64) and I have the following libs included on my Eclipse IDE:

    poi-3.9-20121203.jar
    poi-ooxml-3.9-20121203.jar
    poi-ooxml-schemas-3.9-20121203.jar
    ooxml-lib\dom4j-1.6.1.jar
    xmlbeans-2.3.0.jar

    To which, as far as I'm aware, should be more than enough to run the following class:

    Java Code:
    public class Extracao 
    {
    	public void extrai(List<Noticia> passagem, String chave) throws FileNotFoundException, IOException
    	{
    		XWPFDocument doc = new XWPFDocument();
    		XWPFParagraph paragrafo = doc.createParagraph();
    		XWPFRun aplicacao = paragrafo.createRun();
    		Noticia temporario;
    		
    		System.out.println("Ponto!" + passagem.size());
    		
    		while(!passagem.isEmpty())
    		{
    			temporario = passagem.remove(0);
    			
    			aplicacao.setText("Data : " + temporario.getData());
    			aplicacao.addBreak();
    			
    			aplicacao = paragrafo.createRun();
    
    			aplicacao.setText("Classe : " + temporario.getClasse() + "     Setor : " + temporario.getSetor());
    			aplicacao.addBreak();
    			
    			aplicacao = paragrafo.createRun();
    		
    			aplicacao.setText("Tipo : " + temporario.tipoTexto() + "     Estado : " + temporario.getEstado());
    			aplicacao.addBreak();
    			
    			aplicacao = paragrafo.createRun();
    			
    			divideTexto(doc,paragrafo, aplicacao, temporario.getNoticia());
    			aplicacao.addBreak();
    			aplicacao.addBreak();
    			aplicacao.addBreak();
    		}
    		
    		doc.write(new FileOutputStream(new File(chave + "\"" + "arquivoDeSaida.docx")));
    	}
    	
    	private void divideTexto(XWPFDocument documento, XWPFParagraph paragrafo, XWPFRun app, String alvo)
    	{	
    		if(alvo.length() > 50)
    		{
    			int j, limite = 0;
    			
    			for(j = 0; j <= alvo.length(); j += 50)
    			{
    				app.setText(alvo.substring(j, j + 50));
    				app.addBreak();
    				
    				app = paragrafo.createRun();
    				limite = j;
    			}
    			
    			if(limite != alvo.length())
    			{
    				app.setText(alvo.substring(j - 50, alvo.length()));
    				app.addBreak();
    			}
    		}
    		else app.setText(alvo);
    		
    		app.addBreak();
    	}
    }
    The following error :
    Java Code:
    WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
    javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org/apache/poi/xwpf/usermodel/XWPFDocument
    	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    is thrown when running the line 18 or, in the current case, the declaration of doc (XWPFDocument doc = ...).

    I really am totally lost here guys, please help this lad here: why is the error being thrown? How do I fix it?

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,970
    Rep Power
    19

    Default Re: Desperation and and misadventures with java.lang.NoClassDefFoundError

    Where is this running?
    Looks like a server...so have a look in WEB-INF/lib and see whether those libraries are being deployed.
    If not then you'll have to look into how the deployment is being determined.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    RCruz is offline Member
    Join Date
    Mar 2013
    Posts
    6
    Rep Power
    0

    Default Re: Desperation and and misadventures with java.lang.NoClassDefFoundError

    Issue solved, I copied all the jars to lib and, after some refreshs our good lad Eclipse found them!

    Thank you very much Tolls, you helped me get on track for my research!
    Last edited by RCruz; 03-15-2013 at 08:42 PM.

Similar Threads

  1. java.lang.NoClassDefFoundError:
    By Gowramma in forum New To Java
    Replies: 0
    Last Post: 05-02-2012, 08:57 PM
  2. Replies: 5
    Last Post: 06-02-2010, 01:05 PM
  3. Replies: 3
    Last Post: 06-01-2010, 03:01 PM
  4. java.lang.NoClassDefFoundError
    By noobie in forum Java Applets
    Replies: 5
    Last Post: 04-22-2009, 02:35 AM
  5. java.lang.NoClassDefFoundError:
    By jeepcreep11 in forum New To Java
    Replies: 3
    Last Post: 03-13-2009, 11:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •