解决方案   Solutions
    无分类
联系我们   Contact
搜索   Search
你的位置:首页 > 解决方案

Java调用短信猫报错问题

2017-7-9 11:09:58      点击:

Java调用短信猫的一些报错问题

具体的操作步骤如下:

1、把smslib-3.3.0b2.jarcomm.jarlog4j-1.2.11.jar,放入到工程的lib中;

2、把javax.comm.properties放到%JAVA_HOME%/jre/lib下;

3、把win32com.dll放到%JAVA_HOME%/jre/bin下;

4  comm.jar放到%JAVA_HOME%/jre/ext

注意:路径放错,调用起来就会报错;JDK的版本,用的版本是jdk-1_5_0_04





2013-09-18 10:39:54,859 WARN [org.smslib] - <GTW: modem.com4: Cannot understand SIMPIN response: ERROR

, will wait for a while...>

卡没有插好或者信号不好,要么卡有问题,要么信号不好,要么设备坏了


1、如果报了如下错误: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger 

那是因为没有把log4j-1.2.13.jar倒入到工程中。

2、如果报了如下错误: org.smslib.GatewayException: Comm library exception: java.lang.RuntimeException:javax.comm.NoSuchPortException





运行main,即可发送短信,如果没有配置好之前的几个文件

就会出现报错,如:

org.smslib.GatewayException: Comm library exception: java.lang.reflect.InvocationTargetException

at org.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:93)

at org.smslib.modem.AModemDriver.connect(AModemDriver.java:106)

at org.smslib.modem.ModemGateway.startGateway(ModemGateway.java:111)

at org.smslib.Service$1Starter.run(Service.java:227)




org.smslib.TimeoutException: No response from device.

at org.smslib.modem.AModemDriver$CharQueue.get(AModemDriver.java:474)

at org.smslib.modem.AModemDriver.getResponse(AModemDriver.java:272)

at org.smslib.modem.athandler.ATHandler.getSimStatus(ATHandler.java:127)

at org.smslib.modem.AModemDriver.connect(AModemDriver.java:118)

at org.smslib.modem.ModemGateway.startGateway(ModemGateway.java:111)

at org.smslib.Service$1Starter.run(Service.java:227)

这个错误!害了我差不多俩小时了,公布出来

SerialModemGateway gateway = new SerialModemGateway("modem.com3", "COM3", 9600, "wavecom", "11258");

千万得配好这个东西,要不然,不止这里可能出错,上面的那个异常也可能出现


// 电话号码为空

java.lang.NullPointerException

at org.ajwcc.pduUtils.gsm3040.Pdu.setAddress(Pdu.java:225)

at org.ajwcc.pduUtils.gsm3040.PduParser.parseSmsSubmitMessage(PduParser.java:306)

at org.ajwcc.pduUtils.gsm3040.PduParser.parsePdu(PduParser.java:166)

at org.smslib.modem.ModemGateway.sendMessagePDU(ModemGateway.java:329)

at org.smslib.modem.ModemGateway.sendMessage(ModemGateway.java:162)

at org.smslib.Service.sendMessage(Service.java:530)

at com.gpower.services.util.SendMessage.doIt(SendMessage.java:146)

at com.gpower.web.content.MessageAction.doCreate(MessageAction.java:170)

at com.gpower.web.content.MessageAction.execute(MessageAction.java:50)

at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)

at com.gpower.web.common.SecurityRequestProcessor.processActionPerform(SecurityRequestProcessor.java:76)

at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)

at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)

at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at com.gpower.web.filters.AuthenticationFilter.doFilter(AuthenticationFilter.java:119)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at com.gpower.web.filters.EncodingFilter.doFilter(EncodingFilter.java:95)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

at java.lang.Thread.run(Thread.java:595)