Twilio API抛出错误 - 引起:java.lang.VerifyError:无法从最终类

时间:2015-08-12 05:32:43

标签: java axis2 twilio

我正在使用Twilio API使用JAVA AXIS2网络服务拍摄国际短信。在独立应用程序中实现时,Twilio API成功发送SMS,但是当插入Web服务时会引发以下错误:

  

引起:java.lang.VerifyError:无法从最终类继承

我正在使用twilio-java-sdk-4.4.5 jar

示例代码:

    final TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
    List<NameValuePair> params = new ArrayList<NameValuePair>(); 
             params.add(new BasicNameValuePair("To", "+############")); 
             params.add(new BasicNameValuePair("From", "+############")); 
             params.add(new BasicNameValuePair("Body", "Hi, How are you doing today?!")); 
MessageFactory messageFactory = client.getAccount().getMessageFactory(); 
         Message message = messageFactory.create(params); 

StackTrace:

ERROR - Cannot inherit from final class
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
....
....
Caused by: java.lang.VerifyError: Cannot inherit from final class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2928)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1174)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1669)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:157)
    at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:448)
    at com.twilio.sdk.TwilioClient.<init>(TwilioClient.java:143)
    at com.twilio.sdk.TwilioRestClient.<init>(TwilioRestClient.java:19)
    at com.abc.util.SendSMS.sendSmsviaTwilio(SendSMS.java:205)

1 个答案:

答案 0 :(得分:0)

Java Applet - Cannot inherit from final class阅读此问题的答案。我认为这也是一个类似的情况。应该有两个版本的依赖项,一个版本具有最终类,而其他版本具有非最终类。