2017-05-25 8 views
0

私は、このクラスは、私がWEB-INF/libに入れているいくつかの外部のjarファイルを使用し、Converterという名前の別のclassを使用servletを持っていますが、まだ私はjava.lang.ClassNotFoundExceptionを取得し、このクラスを使用しようとすると、私は数え切れないほどの試行を持っていますここに解決策はありますが、依然として機能していません。サーブレット - 他のクラスから他のjarファイルを含む

  • classpathにジャーを入れます。

    private Converter htmlCon = new Converter(webInfPath); 
    
    protected void doPost(HttpServletRequest request, 
          HttpServletResponse response) throws ServletException, IOException { 
         StringBuffer jb = new StringBuffer(); 
         String line = null; 
         try { 
          BufferedReader reader = request.getReader(); 
          while ((line = reader.readLine()) != null) { 
           jb.append(line); 
          } 
         } catch (IOException IOE) { 
          IOE.printStackTrace(); 
         } 
         try { 
          htmlCon.createPdf(jb.toString(), "pdf.pdf"); 
         } catch (DocumentException e) { 
          // TODO Auto-generated catch block 
          e.printStackTrace(); 
         } 
    

    Converter

    package com.mataf.converters; 
    
    import java.io.File; 
    import java.io.FileOutputStream; 
    import java.io.IOException; 
    //the external jars 
    import org.xhtmlrenderer.pdf.ITextRenderer; 
    
    import com.lowagie.text.DocumentException; 
    
    public class Converter { 
    
        private Types m_type; 
        private String m_pathToCreateFileIn; 
    
        public Converter(String i_path) { 
         this.m_pathToCreateFileIn = i_path; 
        } 
    
        public void createPdf(String html, String fileName) throws IOException, DocumentException{ 
    
         ITextRenderer renderer = new ITextRenderer(); 
         // if you have html source in hand, use it to generate document object 
         renderer.setDocumentFromString(html); 
         renderer.layout(); 
         String fileNameWithPath = m_pathToCreateFileIn + File.separator + "PDF-FromHtmlString.pdf"; 
         FileOutputStream fos = new FileOutputStream(fileNameWithPath); 
         renderer.createPDF(fos); 
         fos.close(); 
         System.out.println("File 2: '" + fileNameWithPath + "' created."); 
         System.out.println(html); 
         System.out.println(fileName); 
        } 
    
    } 
    

  • は、ここに私のservletから関連する部分があり、/クラス

そしてそれらの非動作するWEB-INFの下のjarファイルを置きます完全なものstacktrace

com.ibm.ws.webcontainer.servlet.ServletWrapper run SRVE8052E: Logging ClassNotFoundException 
           java.lang.ClassNotFoundException: class java.lang.NullPointerException: null 
    at java.beans.Beans.instantiate(Beans.java:190) 
    at java.beans.Beans.instantiate(Beans.java:75) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.java:1461) 
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:1450) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.load(ServletWrapper.java:1348) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:980) 
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703) 
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304) 
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962) 
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662) 
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:522) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:311) 
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:87) 
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) 
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) 
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) 
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) 
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) 
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) 
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) 
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783) 
+0

例外について質問するとき、**常に**例外の完全なスタックトレースをポストします。 –

+0

追加、ありがとう。 –

+0

@JBNizet - スタックトレースを追加します。何か他のものが必要かどうかを教えてください。 –

答えて

1

あなたが見ている例外の原因については、このリンクをご覧ください。Odd behavior in WAS 7.0: java.lang.ClassNotFoundException: class java.lang.NullPointerException: null

「WebSphere Application Serverで含まれたJava 6のバージョンは、実際の原因を曖昧にするJavaのバグ4256569、の修正を失いました失敗。

websphereアプリケーションでJavaバージョンを更新すると、問題の実際の原因が明らかになります。

関連する問題