1
サーブレットコマンドからgetGmailを呼び出そうとしましたが、エラーが発生していて、どこに行ったのか分かりません。サーブレットからgoogle apiを呼び出す
public class GmailCommand implements Command
{
public GmailCommand() { }
public String execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
try
{
GetGmail.run(null, null);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return "/welcome.jsp";
}
}
public class GetGmail
{
//public static void main(String[] args) throws Exception {
public static ArrayList<String[]> run(String username, String password)
throws Exception
{
ArrayList<String[]> result = null;
System.out.println("GetGmail");
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
props.setProperty("mail.imap.port", "993");
props.setProperty("mail.imap.connectiontimeout", "5000");
props.setProperty("mail.imap.timeout", "5000");
try
{
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
//store.connect("imap.googlemail.com", username, password);
//sendMessage(session);
result = readMessage(store);
store.close();
}
catch (NoSuchProviderException e)
{
e.printStackTrace();
System.exit(1);
}
catch (MessagingException e)
{
e.printStackTrace();
System.exit(2);
}
// for(String[] ss:result){
// System.out.println(ss[0]+ss[1]+ss[2]+ss[3]);
// }
return result;
}
これはエラーメッセージ
SEVERE: Servlet.service() for servlet dispatcher threw exception
java.lang.ClassNotFoundException: javax.mail.NoSuchProviderException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
at com.web.command.GmailCommand.execute(GmailCommand.java:35)
at com.web.commandController.ControllerServlet.processRequest(ControllerServlet.java:46)
at com.web.commandController.ControllerServlet.doPost(ControllerServlet.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)