我试图设置一个基本的嵌入式Tomcat服务器,但是无法让Tomcat服务器运行。
public class Main {
public static void main(String[] args) throws LifecycleException {
Tomcat tomcat = new Tomcat();
tomcat.setPort(8888);
tomcat.start();
tomcat.getServer().await();
}
}
在Eclipse中运行这个java应用程序提供了以下输出:
我得到了一个Amazon Linux AMI 2013.03实例,它的dns地址类似于:ec2-22-11-111-105.compute-1.amazonaws.com,我必须在该实例上托管一个java web服务。我以ec2-user的身份连接到它。我已经通过以下命令在其上安装了tomcat6服务器:sudo yum install tomcat6 tomcat6-webapps,并将我的WebService.war文件放在\usr\share\tomcat6\webapps文件夹中。然后,我以sudo service tomcat6 start身份启动tomcat服务器。tomcat在端
当Tomcat启动时,它调用我的ServletContextListener来获得数据库连接,稍后我将通过getServletContext()在其他servlet中使用它。在我的web.xml中,它被称为:
`listener`
`listener-class org.ppdc.database.DBCPoolingListener /listener-class`
`/listener>` (I removed the < > because they wouldn't display properly in this message.>