2016-10-01 16 views
0

別のマシンでアプリケーションを実行しようとすると、このエラーが発生します。私はスタックトレースと私のJavaクラスファイルを貼り付けます。私はプロジェクトのクラスパスのjarファイル内のすべてのjarファイルを破壊していないので、ライブサーバーマシンからコピーしました。java.lang.NoClassDefFoundError:org/apache/log4j/Priority

スタックトレース:ここ

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Priority 
    at org.smslib.Service.listSystemInformation(Service.java:113) 
    at org.smslib.Service.initializeService(Service.java:103) 
    at org.smslib.Service.<init>(Service.java:95) 
    at org.smslib.Service.<clinit>(Service.java:90) 
    at javaapplication1.GsmModem.doIt(GsmModem.java:59) 
    at javaapplication1.GsmModem.Sender(GsmModem.java:40) 
    at javaapplication1.Smslive.main(Smslive.java:33) 
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 7 more 
C:\Users\s\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1 
BUILD FAILED (total time: 0 seconds) 

は私のメインのJavaクラスここ

/* 
* To change this license header, choose License Headers in Project Properties. 
* To change this template file, choose Tools | Templates 
* and open the template in the editor. 
*/ 
package javaapplication1; 

/** 
* 
* @author s 
*/ 
public class Smslive { 


      private static String port = "COM5"; //Modem Port. 
    private static int bitRate = 115200; //this is also optional. leave as it is. 
    private static String modemName = "Qualcomm"; //this is optional. 
    private static String modemPin = "0000"; //Pin code if any have assigned to the modem. 
    private static String SMSC = "+923455000010"; //Message Center Number e 
    public static void main(String[] args) { 



GsmModem gsmModem = new GsmModem(); 
     GsmModem.configModem(port, bitRate, modemName, modemPin, SMSC); 
     String num1 = "somenumber"; 
     String num2 = "somenumber"; 
String number[] = {num1,num2};  // Robot r = new Robot(); 
     //int keyCode = KeyEvent.VK_ENTER; // the A key 
       try { 


gsmModem.Sender("Mobileno", "String message"); // (tp, msg) 
       } catch (Exception ex) { 
        System.out.println("exception"+ex); 
       } 


    } 
} 

であるGSM方式Modem.javaクラス

/* 
* To change this license header, choose License Headers in Project Properties. 
* To change this template file, choose Tools | Templates 
* and open the template in the editor. 
*/ 
package javaapplication1; 




import org.smslib.AGateway; 
import org.smslib.IOutboundMessageNotification; 
import org.smslib.Library; 
import org.smslib.OutboundMessage; 
import org.smslib.Service; 
import org.smslib.modem.SerialModemGateway; 

public class GsmModem 
{ 
    private static String port; 
    private static int bitrate; 
    private static String modem; 
    private static String modemPin; 
    private static String smsc; 
    private static String tp; 
    private static String msgBody; 

    public static void configModem(String p, int b, String m, String pi, String s) 
    { 
    port = p; 
    bitrate = b; 
    modem = m; 
    modemPin = pi; 
    smsc = s; 
    } 

    public void Sender(String tpnum, String message) throws Exception { 
    tp = tpnum; 
    msgBody = message; 
    doIt(); 
    } 

    public void doIt() throws Exception 
    { 
    OutboundNotification outboundNotification = new OutboundNotification(); 
    System.out.println("-----------------------------"); 
    System.out.println("*** author***"); 
    System.out.println("author"); 
    System.out.println("-----------------------------"); 
    System.out.println("Example: Send message from a serial gsm modem."); 
    System.out.println(Library.getLibraryDescription()); 
    System.out.println("Version: " + Library.getLibraryVersion()); 
    SerialModemGateway gateway = new SerialModemGateway("modem.com1", port, bitrate, modem, ""); 
    gateway.setInbound(true); 
    gateway.setOutbound(true); 
    gateway.setSimPin(modemPin); 

    gateway.setSmscNumber(smsc); 
    Service.getInstance().setOutboundMessageNotification(outboundNotification); 
    Service.getInstance().addGateway(gateway); 
    Service.getInstance().startService(); 
    System.out.println(); 
    System.out.println("Modem Information:"); 
    System.out.println(" Manufacturer: " + gateway.getManufacturer()); 
    System.out.println(" Model: " + gateway.getModel()); 
    System.out.println(" Serial No: " + gateway.getSerialNo()); 
    System.out.println(" SIM IMSI: " + gateway.getImsi()); 
    System.out.println(" Signal Level: " + gateway.getSignalLevel() + " dBm"); 
    System.out.println(" Battery Level: " + gateway.getBatteryLevel() + "%"); 
    System.out.println(); 

    OutboundMessage msg = new OutboundMessage(tp, msgBody); 
    Service.getInstance().sendMessage(msg); 
    System.out.println(msg); 

    // System.out.println("Now Sleeping - Hit <enter> to terminate."); 
    // System.in.read(); 
    Service.getInstance().stopService(); 
    } 
    public class OutboundNotification implements IOutboundMessageNotification { 
    public OutboundNotification() { 
    } 

    public void process(AGateway gateway, OutboundMessage msg) { 
     System.out.println("Outbound handler called from Gateway: " + gateway.getGatewayId()); 
     System.out.println(msg); 
    } 
    } 
} 
+0

これはLog4jのバージョンが間違っている可能性があります。 –

+0

いいえ、別のマシンで実行している同じバージョンのlog4jをそこからコピーしました。 – mgk22

+0

どのようにクラスを実行しますか? – kuhajeyan

答えて

0

私はちょうど両方のJDKの再インストールすることで問題を解決していますNetbeans IDEを再インストールします。私は問題がJDKのLIBフォルダのどこかにあったと思う。