localhost上的apache tomcat v9.0服务器无法启动

时间:2016-09-03 12:06:09

标签: java apache tomcat javamail

基本上我有一个配置了apache v9.0和eclipse的java ee项目,基于研究我发现gmail有一个免费的smtp服务器,允许我们执行我们的邮件服务。现在的问题是,当我将smtp邮件代码输入到我的项目发送简单邮件时,apache弹出一个错误说:

  

localhost上的服务器Tomcat v9.0服务器无法启动?

Apache日志:

model

这是我的smtp实现代码:

First file:
02-Sep-2016 09:03:21.045 INFO [main]      org.apache.catalina.startup.VersionLoggerListener.log Server version:             Apache Tomcat/9.0.0.M9
 02-Sep-2016 09:03:21.045 INFO [main]      org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 4 2016 18:22:47 UTC
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         9.0.0.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 8
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.2
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          x86
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files (x86)\Java\jre1.8.0_101
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_101-b13
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:              C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\temp
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -     Djava.util.logging.config.file=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\conf\logging.properties
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: exit
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.8 using APR version 1.5.2.
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
 02-Sep-2016 09:03:21.548 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2h  3 May 2016)
 02-Sep-2016 09:03:23.095 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-30012"]
 02-Sep-2016 09:03:25.548 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
 02-Sep-2016 09:03:25.564 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-30013"]
 02-Sep-2016 09:03:25.564 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
 02-Sep-2016 09:03:25.564 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 8457 ms
 02-Sep-2016 09:03:25.814 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
 02-Sep-2016 09:03:25.814 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.0.M9
 02-Sep-2016 09:03:25.861 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\docs
 02-Sep-2016 09:03:26.548 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\docs has finished in 687 ms
 02-Sep-2016 09:03:26.548 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\examples
 02-Sep-2016 09:03:28.142 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\examples has finished in 1,594 ms
 02-Sep-2016 09:03:28.142 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\host-manager
 02-Sep-2016 09:03:28.251 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\host-manager has finished in 109 ms
 02-Sep-2016 09:03:28.251 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\manager
 02-Sep-2016 09:03:28.267 INFO [localhost-startStop-1]      org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web      application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat      9.0\webapps\manager has finished in 16 ms
 02-Sep-2016 09:03:28.267 INFO [localhost-startStop-1]      org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application      directory C:\Program Files (x86)\Apache Software Foundation\Tomcat      9.0\webapps\ROOT
 02-Sep-2016 09:03:28.314 INFO [localhost-startStop-1]           org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web      application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat      9.0\webapps\ROOT has finished in 47 ms
 02-Sep-2016 09:03:28.314 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-30012]
 02-Sep-2016 09:03:28.439 INFO [main] org.apache.coyote.AbstractProtocol.start      Starting ProtocolHandler [ajp-nio-30013]
 02-Sep-2016 09:03:28.454 INFO [main] org.apache.catalina.startup.Catalina.start     Server startup in 2888 

 Second File:
 [2016-09-02 09:03:11] [info]  [ 3436] Commons Daemon procrun (1.0.15.0 32-bit) started
 [2016-09-02 09:03:11] [info]  [ 3436] Running 'Tomcat9' Service...
 [2016-09-02 09:03:12] [info]  [ 3468] Starting service...
 [2016-09-02 09:03:17] [info]  [ 3468] Service started in 5035 ms.

 Third File:
 02-Sep-2016 09:03:28.095 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
 02-Sep-2016 09:03:28.095 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()

Fourth File:

 2016-09-02 09:03:11 Commons Daemon procrun stderr initialized
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/9.0.0.M9
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 4 2016 18:22:47 UTC
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         9.0.0.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 8
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.2
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          x86
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files (x86)\Java\jre1.8.0_101
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_101-b13
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\temp
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\conf\logging.properties
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: exit
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.8 using APR version 1.5.2.
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
 02-Sep-2016 09:03:21.045 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
 02-Sep-2016 09:03:21.548 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2h  3 May 2016)
 02-Sep-2016 09:03:23.095 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-30012"]
 02-Sep-2016 09:03:25.548 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
 02-Sep-2016 09:03:25.564 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-30013"]
 02-Sep-2016 09:03:25.564 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
 02-Sep-2016 09:03:25.564 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 8457 ms
 02-Sep-2016 09:03:25.814 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
 02-Sep-2016 09:03:25.814 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.0.M9
 02-Sep-2016 09:03:25.861 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\docs
 02-Sep-2016 09:03:26.548 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\docs has finished in 687 ms
 02-Sep-2016 09:03:26.548 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\examples
 02-Sep-2016 09:03:28.142 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\examples has finished in 1,594 ms
 02-Sep-2016 09:03:28.142 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\host-manager
 02-Sep-2016 09:03:28.251 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\host-manager has finished in 109 ms
 02-Sep-2016 09:03:28.251 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\manager
 02-Sep-2016 09:03:28.267 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\manager has finished in 16 ms
 02-Sep-2016 09:03:28.267 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\ROOT
 02-Sep-2016 09:03:28.314 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\ROOT has finished in 47 ms
 02-Sep-2016 09:03:28.314 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-30012]
 02-Sep-2016 09:03:28.439 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-30013]
 02-Sep-2016 09:03:28.454 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 2888 ms

Last File Log:
2016-09-02 09:03:11 Commons Daemon procrun stdout initialized

我的Web.xml文件:

package duck.reg.pack;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

@WebServlet("/sendmailtls")
public class SendMailTLS extends HttpServlet {
public static void main() {

    final String username = "hello@gmail.com";
    final String password = "MYPassword";

    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.port", "587");

    Session session = Session.getInstance(props,
      new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username, password);
        }
      });

    try {

        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress("myemail@gmail.com"));
        message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse("myemail@yahoo.com"));
        message.setSubject("Testing Subject");
        message.setText("Dear Mail Crawler,"
            + "\n\n No spam to my email, please!");

        Transport.send(message);

        System.out.println("Done");

    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }
}
}

0 个答案:

没有答案