javax.mail.NoSuchProviderException:无法找到协议提供程序:smtp

时间:2016-04-03 07:16:05

标签: smtp jetty javamail transport nosuchproviderexception

我尝试在Java EE应用程序中运行此代码并且它有效:

Transport transport = session.getTransport("smtp");

但是,当我在Web应用程序中使用它时,它会抛出NoSuchProviderException。我该如何解决?使用java EE应用程序并在servlet中使用smtp时,smtp的提供程序有什么不同吗?

堆栈跟踪是:

javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp
    at javax.mail.Session.getProvider(Session.java:229)
    at javax.mail.Session.getTransport(Session.java:338)
    at com.shree.email.EmailServlet.doGet(EmailServlet.java:49)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)atcom.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter (ParseBlobUploadFilter.java:125) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:50)at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:260)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:78) at org.mortbay.jetty.HttpConnection.handle (HttpConnection.java:404) at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:148) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:469) at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:439) at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:446) at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256) at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:310) at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:302) at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:443) at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:235) at java.lang.Thread.run(Thread.java:745)

0 个答案:

没有答案