我在服务器7.0.90上使用Maven,成功生成.war文件后,在Tomcat中进行部署后出现以下错误。当我尝试在Tomcat上运行我的项目时,出现了这些异常。 我将Maven 3.5.2与Tomcat Server 7.0.90结合使用。
我已经在pom文件中应用了一些在论坛中找到的解决方案,但是问题仍然存在。
Catalina.log:
INFO: Deploying web application archive C:\apache-tomcat-7.0.90\webapps\testapp-004.001.17.00.war
mar 17, 2019 8:20:26 PM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
mar 17, 2019 8:20:26 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
mar 17, 2019 8:20:26 PM org.apache.catalina.core.StandardContext startInternal
GRAVE: Context [/testapp-004.001.17.00] startup failed due to previous errors
mar 17, 2019 8:20:26 PM org.apache.catalina.startup.HostConfig deployWAR
Localhost.log:
mar 17, 2019 8:20:26 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class mapfre.srv.RepositoryDeployer
java.lang.NullPointerException
at mapfre.srv.RepositoryDeployer.contextInitialized(RepositoryDeployer.java:99)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5157)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5680)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1017)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:993)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1127)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:593)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1815)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1514)
at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:278)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:198)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:603)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1136)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2555)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2544)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.app</groupId>
<artifactId>testapp</artifactId>
<packaging>war</packaging>
<version>004.001.17.00</version>
<name>Tomcat Deploy Test</name>
<!-- TestApp Config Properties -->
<properties>
<dir.files.properties>src/test/properties</dir.files.properties>
</properties>
<!-- Nexus Repos Config -->
<repositories>
<repository>
<id>nexus</id>
<url>http://localhost:8080/nexus/content/repositories/public/</url>
</repository>
<repository>
<id>nexus_testapp</id>
<url>http://localhost:8080/nexus/repository/myrep-testapp-releases/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>releases</id>
<url>${releases.repo.url}</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>${snapshots.repo.url}</url>
</snapshotRepository>
</distributionManagement>
<!-- Build Config -->
<build>
<filters>
<filter>${dir.files.properties}/${build.profile.id}/deploy.properties</filter>
</filters>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
<!-- Plugins -->
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${dir.files.properties}/build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<altDeploymentRepository>nexus_testapp::default::http://localhost:8080/nexus/repository/myrep-testapp-releases/</altDeploymentRepository>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>nexus_testapp</serverId>
<altDeploymentRepository>nexus_testapp::default::http://localhost:8080/nexus/repository/myrep-testapp-releases/</altDeploymentRepository>
<skipStaging>true</skipStaging>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
<archiveClasses>true</archiveClasses>
<warSourceDirectory>WebContent</warSourceDirectory>
<webResources>
<resource>
<directory>WebContent/properties</directory>
<filtering>true</filtering>
<targetPath>properties</targetPath>
</resource>
</webResources>
<outputFileNameMapping>@{artifactId}@.@{extension}@</outputFileNameMapping>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.5.0.1254</version>
<executions>
<execution>
<phase>sonar</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8085/manager/text</url>
<server>tomcat</server>
<path>/tronweb</path>
</configuration>
</plugin>
</plugins>
</build>
<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.0-FINAL</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>com.testapp.dgtp.v2.lib</groupId>
<artifactId>dfc</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>com.testapp.dgtp.v2.lib</groupId>
<artifactId>dfcbase</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>com.testapp.dgtp.cosym.arqos.env.lib</groupId>
<artifactId>ojdbc5</artifactId>
<version>11.2.0.4</version>
</dependency>
<dependency>
<groupId>com.testapp.dgtp.cosym.arqos.env.lib</groupId>
<artifactId>orai18n</artifactId>
<version>11.2.0.4</version>
</dependency>
<dependency>
<groupId>com.testapp.testapp</groupId>
<artifactId>testframework</artifactId>
<version>004.007.00.00</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.90</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>2.0.0</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.5.0.1254</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- Profile -->
<profiles>
<profile>
<id>DESMX</id>
<properties>
<build.profile.id>DESMX</build.profile.id>
</properties>
<dependencies>
<dependency>
<groupId>com.testapp.testapp.testclient</groupId>
<artifactId>trn</artifactId>
<version>004.001.20.00</version>
</dependency>
</dependencies>
</profile>
</project>
我的Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>TestApp Server</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- <listener>
<listener-class>testapp.srv.ServidorCIMSStartUp</listener-class>
</listener> -->
<listener>
<listener-class>testapp.srv.RepositoryDeployer</listener-class>
</listener>
<!-- <servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>org.apache.catalina.servlets.InvokerServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping> -->
<servlet>
<servlet-name>testapp.srv.SVCreaZipFile</servlet-name>
<servlet-class>testapp.srv.SVCreaZipFile</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVCreaZipFile</servlet-name>
<url-pattern>/servlet/testapp.srv.SVCreaZipFile</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVAdmon</servlet-name>
<servlet-class>testapp.srv.SVAdmon</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVAdmon</servlet-name>
<url-pattern>/servlet/testapp.srv.SVAdmon</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVCorreo</servlet-name>
<servlet-class>testapp.srv.SVCorreo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVCorreo</servlet-name>
<url-pattern>/servlet/testapp.srv.SVCorreo</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVInvertedProxy</servlet-name>
<servlet-class>testapp.srv.SVInvertedProxy</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVInvertedProxy</servlet-name>
<url-pattern>/servlet/testapp.srv.SVInvertedProxy</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVJspool</servlet-name>
<servlet-class>testapp.srv.SVJspool</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVJspool</servlet-name>
<url-pattern>/servlet/testapp.srv.SVJspool</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVLst</servlet-name>
<servlet-class>testapp.srv.SVLst</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVLst</servlet-name>
<url-pattern>/servlet/testapp.srv.SVLst</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVRep</servlet-name>
<servlet-class>testapp.srv.SVRep</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVRep</servlet-name>
<url-pattern>/servlet/testapp.srv.SVRep</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVTronWeb</servlet-name>
<servlet-class>testapp.srv.SVTronWeb</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVTronWeb</servlet-name>
<url-pattern>/servlet/testapp.srv.SVTronWeb</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVUtilidades</servlet-name>
<servlet-class>testapp.srv.SVUtilidades</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVUtilidades</servlet-name>
<url-pattern>/servlet/testapp.srv.SVUtilidades</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVWebServices</servlet-name>
<servlet-class>testapp.srv.SVWebServices</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVWebServices</servlet-name>
<url-pattern>/servlet/testapp.srv.SVWebServices</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.utl.Genoma</servlet-name>
<servlet-class>testapp.utl.Genoma</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.utl.Genoma</servlet-name>
<url-pattern>/servlet/testapp.utl.Genoma</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>testapp.srv.SVAyuda</servlet-name>
<servlet-class>testapp.srv.SVAyuda</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp.srv.SVAyuda</servlet-name>
<url-pattern>/servlet/testapp.srv.SVAyuda</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>TestApp Admin URLs</display-name>
<web-resource-collection>
<web-resource-name>TestApp Admin URLs</web-resource-name>
<!-- <url-pattern>/servlet/testapp.srv.SVCreaZipFile</url-pattern> -->
<url-pattern>/servlet/testapp.srv.SVAdmon</url-pattern>
<url-pattern>/tw_labels.html</url-pattern>
<url-pattern>/TWError.htm</url-pattern>
<url-pattern>/TWMensaje.htm</url-pattern>
<url-pattern>/TWDepurar.htm</url-pattern>
<url-pattern>/TWStack.htm</url-pattern>
<url-pattern>/TWTrazas.htm</url-pattern>
<url-pattern>/blank.html</url-pattern>
<url-pattern>/encabezado.html</url-pattern>
<url-pattern>/index.htm</url-pattern>
<!-- <url-pattern>/instalar.html</url-pattern>
<url-pattern>/install.html</url-pattern> -->
<url-pattern>/menu.html</url-pattern>
<url-pattern>/menuUS.html</url-pattern>
<url-pattern>/tw_etiquetas.html</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>testappadmin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>TestApp user URLs</display-name>
<web-resource-collection>
<web-resource-name>TestApp user URLs</web-resource-name>
<url-pattern>/servlet/testapp.srv.SVCreaZipFile</url-pattern>
<url-pattern>/instalar.html</url-pattern>
<url-pattern>/install.html</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>testappuser</role-name>
<role-name>testappadmin</role-name>
</auth-constraint>
</security-constraint>
<!-- Defines the Login Configuration for this Application -->
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Area de acceso restringido</realm-name>
</login-config>
<!--Security roles referenced by this web application -->
<security-role>
<role-name>testappuser</role-name>
</security-role>
<security-role>
<role-name>testappadmin</role-name>
</security-role>
** My RepositoryDeployer.java第47-100行:**
public void contextInitialized(ServletContextEvent arg0) {
long t0 = System.currentTimeMillis();
final ServletContextEvent event = arg0;
try {
//Load TestApp Properties
String rootPath = event.getServletContext().getRealPath("/");
File contextDir = new File(rootPath);
String contextName = contextDir.getName();
//Init logger
configureLogger(contextName);
logger = LogFactory.getLog(RepositoryDeployer.class);
logger.info("Publishing TestApp Repository...");
logger.info("Context name: "+contextName);
TLComun.cargarPropiedades("0", rootPath, contextName);
//Check Property for the Repository Path
String repositoryDir = TLComun.getRRS();
File repFile=new File(repositoryDir);
String[] numSegments=repFile.toURI().normalize().getPath().split("/");
if (numSegments.length<3||!repFile.isAbsolute()){
logger.warn("Incorrect Path "+repositoryDir+". It must have at least 2 segments and it can't be relative. i.e. /ap/testapp or C:\\ap\\testapp");
repositoryDir = System.getProperty("java.io.tmpdir") + File.separator + contextName;
TLComun.setRRS(repositoryDir);
logger.warn("Temporal directory "+repositoryDir+" is used instead");
}
//Jar extraction
String jarUrl = TLComun.getClientLocation();
logger.debug("TestApp Client JAR Location: " + jarUrl);
logger.debug("TestApp Repository Location: " + repositoryDir);
logger.debug("Extracting Repository...");
long t1 = System.currentTimeMillis();
extractJar(jarUrl, repositoryDir);
logger.info("Repository Extracted Successfully in " + (System.currentTimeMillis() - t1) + " ms");
//TestApp Labels generation
logger.debug("Generating Labels...");
t1=System.currentTimeMillis();
boolean res = GeneradorTextosHTTP.generarTodasEtiquetas();
if (res){
logger.info("Labels Generated Successfully in " + (System.currentTimeMillis() - t1) + " ms");
}else{
logger.warn("WARNING: Labels not generated");
}
logger.info("Context "+contextName+" startup in "+(System.currentTimeMillis() - t0)+" ms");
} catch (Throwable e) {//Avoid starting if something wrong happens
System.err.println("TestApp Server context not started due to errors. Check if war contains the client jar.\n" + e.getMessage());
e.printStackTrace(System.err);
logger.error("TestApp Server context not started due to errors. Check if war contains the client jar.\n" + e.getMessage(), e);
throw new Error(e);
}
}
预先感谢您的帮助和指导。