I am trying to send SMS from java web application using Twillo app. But I am getting the following error at Glassfish server 4.1.1
java.lang.NoClassDefFoundError:
org/apache/http/conn/HttpClientConnectionManager
at
Message message = Message.creator(new PhoneNumber(""),
I have added Twilio 7.41.2 jar in my netbeans ide library folder. But I have not added any maven dependency in pom.xml as this is not maven enabled the project, is this the error due to missing maven dependency?
index.jsp
<form action="sms" method="post">
<input type ="submit"/>
</form>
Servlet sms.java
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
try{
final String ACCOUNT_SID = "myaccountsid";
final String AUTH_TOKEN = "my string authtoken";
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Message message = Message.creator(new PhoneNumber("recipient phone no"),
new PhoneNumber("recipient phone no"),"Hello This is Tom").create();
out.println(message.getSid());
processRequest(request, response);
}
catch(IOException | ServletException e){
}
}
Any help is much appreciated.