org.apache.catalina.ServerFactory.getServer()Tomcat 7中的等价物或者检索org.apache.catalina.Session实例的最佳方法是什么?
以下是用于处理Tomcat 6.0的示例代码:
public List<org.apache.catalina.Session> findActiveSessions() throws ServiceException {
StandardEngine engine = (StandardEngine) ServerFactory.getServer().findService("Catalina").getContainer();
StandardContext context = (StandardContext) engine.findChild(engine.getDefaultHost())
.findChild(ServletActionContext.getServletContext().getContextPath());
List<org.apache.catalina.Session> list = new ArrayList<org.apache.catalina.Session>();
for (org.apache.catalina.Session session : context.getManager().findSessions()) {
list.add(session);
}
return list;
}
Run Code Online (Sandbox Code Playgroud) 我下载并解压缩了apache-tomcat-7.0.根据RUNNING.txt(%CATALINA_BASE%/ RUNNING.txt)中的说明,它应该在"setenv.sh"文件中设置JRE_HOME.
这个文件在哪里?文档说,它将在CATALINA_HOME/bin目录中.但是这个文件不存在.
是否可以配置Tomcat,使其在开发过程中查找我的"webapp"目录的单独位置?
我在一个目录中有我的git源代码,在另一个目录中安装了tomcat.我不想在两个地方进行更改,或者每次我对CSS或Javascript进行简单更改时手动复制文件,或重建/部署.
不幸的是,这些建议都没有效果,我怀疑这可能是因为我没有提供足够的信息来说明我是如何制定的.
我将Tomcat安装在我的主目录(我在Mac上)的目录中,名为"Development".
/Users/dbrogdon/Development/apache-tomcat-7.0.35
Run Code Online (Sandbox Code Playgroud)
我旁边有我的git来源.
/Users/dbrogdon/Development/myproject
Run Code Online (Sandbox Code Playgroud)
在myproject目录中,我的实际Web文件位于:
/Users/dbrogdon/Development/myproject/application/appname/src/main/webapp
Run Code Online (Sandbox Code Playgroud)
当我编译时,我将appname.war放入
/Users/dbrogdon/Development/apache-tomcat-7.0.35/webapps
Run Code Online (Sandbox Code Playgroud)
根据更新的信息,我应该在我的conf/server.xml或者我的docBase中提供什么conf/Catalina/localhost/appname.xml?
我正在尝试登录tomcat管理器应用程序,但我无法在tomcat-users.xml中成功创建登录用户.最初的内容是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, …Run Code Online (Sandbox Code Playgroud) 我正在将我的Web应用程序从Jboss 4.2迁移到tomcat 7.
使用tomcat 7后,我面临以下异常.
java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:855)
at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:201)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1051)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1883)
at org.apache.catalina.startup.ContextConfig.getDefaultWebXmlFragment(ContextConfig.java:1469)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1246)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) …Run Code Online (Sandbox Code Playgroud) 我试图找到一种方法来更改一个弹簧启动应用程序的默认欢迎页面,该应用程序在生产中被部署为战争,但是如果没有web.xml文件,我找不到办法.
根据文档,我们可以使用EmbeddedServletContainerFactory和以下代码来完成它:
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
TomcatContextCustomizer contextCustomizer = new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
context.addWelcomeFile("/<new welcome file>");
}
};
factory.addContextCustomizers(contextCustomizer);
return factory;
}
Run Code Online (Sandbox Code Playgroud)
虽然,因为我们正在创建一个war文件并将其部署到tomcat而不使用Embedded Tomcat,但这并没有做任何事情.
任何的想法?如果我们真的需要添加一个web.xml文件,我们怎么做呢仍然使用spring boot?我们是否应该将Application bean(使用main方法)指定为DispatcherServlet的应用程序上下文?文档不是很清楚.
较旧的Servlet容器不支持Servlet 3.0中使用的ServletContextInitializer引导过程.您仍然可以在这些容器中使用Spring和Spring Boot,但是您需要在应用程序中添加web.xml并将其配置为通过DispatcherServlet加载ApplicationContext.
提前致谢!
佩德罗
我想在我的Windows 2008 Server上安装我的tomcat v7.0.12作为服务.在tomcat页面上,我找到了本教程.但是service.bat我的安装目录中没有文件.
在WS2008的服务概述中,无法轻松创建类似的新服务 new->service ...
我只是想知道如何增加tomcat线程池中的线程数?以及设置最大值的数字,我不知道什么是合适的?
全新下载的Tomcat 7(我使用的是7.0.19)包含一个包含单个文件'tempToDelete.tmp'的'temp'目录.Tomcat使用的目录是什么,Tomcat用户(开发人员)应该如何使用?
我正在尝试通过eclipse luna将web应用程序部署到tomcat7,但我收到此错误:
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.936 s
[INFO] Finished at: 2014-08-15T22:10:04-03:00
[INFO] Final Memory: 13M/112M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project …Run Code Online (Sandbox Code Playgroud) tomcat7 ×10
tomcat ×4
deployment ×1
java ×1
maven ×1
service ×1
setenv ×1
spring ×1
spring-boot ×1
threadpool ×1