Similar questions in the forum are unanswered, since being noob with Restful Web services i had to raise this question.
A mavenized dynamic Web application to fetch data from database in a JASON format.
Database: apache derby 1.1
Eclipse: Juno
JDK: 1.8
Spring: 4.2.3
Hibernate: 5.0
Jersey: 2.19
Apache tomcat v8.0
Design patterns used: none as its a very basic integration
Design
Model class mimics the table from the database (Spring bean) & JSon model.
DaoImpl class--> a spring bean with dependency satisfied using spring support classes for hibernate.
contextWrapper class -->registered using #Provider used to invoke spring context and fetch results from DaoImpl class
RestService class--> handle rest resource request fetch results from contextWrapper class
Compiles and deploys well without errors in server logs however NullpointerException is being thrown from jersey when resource is accessed.
as per logs Spring context has no issues loading.
Tomcat console logs
Dec 01, 2015 12:11:54 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:JerseySpringHibernate' did not find a matching property.
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.24
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jul 1 2015 20:19:55 UTC
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.24.0
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 7
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.1
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: x86
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jre1.8.0_51
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_51-b16
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\integration\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\apache-tomcat-8.0.24-windows-x86\apache-tomcat-8.0.24
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\integration\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\apache-tomcat-8.0.24-windows-x86\apache-tomcat-8.0.24
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\integration\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\apache-tomcat-8.0.24-windows-x86\apache-tomcat-8.0.24\endorsed
Dec 01, 2015 12:11:54 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Dec 01, 2015 12:11:54 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_51\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_51/bin/client;C:/Program Files/Java/jre1.8.0_51/bin;C:/Program Files/Java/jre1.8.0_51/lib/i386;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\db-derby-10.11.1.1-bin\db-derby\bin;C:\eclipse-jee-luna-SR1-win32\eclipse;;.
Dec 01, 2015 12:11:55 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Dec 01, 2015 12:11:55 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Dec 01, 2015 12:11:55 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Dec 01, 2015 12:11:55 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Dec 01, 2015 12:11:55 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2222 ms
Dec 01, 2015 12:11:55 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 01, 2015 12:11:55 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.24
Dec 01, 2015 12:11:57 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [248] milliseconds.
Dec 01, 2015 12:12:16 AM org.apache.jasper.servlet.TldScanner scanJars
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.
Dec 01, 2015 12:12:16 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Dec 01, 2015 12:12:17 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Dec 01, 2015 12:12:17 AM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Dec 01, 2015 12:12:17 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Tue Dec 01 00:12:17 PST 2015]; root of context hierarchy
Dec 01, 2015 12:12:18 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring.xml]
Dec 01, 2015 12:12:19 AM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: org.apache.derby.jdbc.ClientDriver
Dec 01, 2015 12:12:21 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.0.4.Final}
Dec 01, 2015 12:12:21 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Dec 01, 2015 12:12:21 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Dec 01, 2015 12:12:21 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.0.Final}
Dec 01, 2015 12:12:25 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.DerbyTenSevenDialect
Dec 01, 2015 12:12:32 AM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 14945 ms
Dec 01, 2015 12:12:34 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Dec 01, 2015 12:12:34 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Dec 01, 2015 12:12:34 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 40066 ms
Dec 01, 2015 12:14:21 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Jersey Web Application] in context with path [/JerseySpringHibernate] threw exception [java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at org.shekar.service.RestRequestService.allRows(RestRequestService.java:23)
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.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:205)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:308)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:291)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1140)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:403)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
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
<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>JerseySpringHibernate</groupId>
<artifactId>JerseySpringHibernate</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<jersey.version>2.19</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Jersey 2.19 configuration -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
<!-- Persistence Api » 1.0.2 -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<!-- jersey dependency APIs for CDI (Contexts and Dependency Injection for Java) -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0-EDR1</version>
</dependency>
<!--Ejb Api » 3.0 -->
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
</dependency>
<!-- spring configuration -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<!-- Spring JDBC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<!--JSR250 annotation -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
</dependency>
<!-- Spring orm -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<!-- Spring web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<!--java transaction API JTA configuration -->
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<!-- hibernate configuration -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.4.Final</version>
</dependency>
<!-- Derby dirver config for maven -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.11.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.11.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>webapp</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Web.XML
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>JerseySpringHibernate</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.shekar</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
<!-- loading spring context -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
Spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="circle" class="org.shekar.model.CircleModel" scope="prototype"/>
<bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" autowire="constructor">
<property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="url" value="jdbc:derby://localhost:1527/test;create=true"/>
</bean>
<bean id="sessn" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="datasource"/>
<property name="packagesToScan" value="org.shekar.model"/>
<property name="hibernateProperties">
<props>
<prop key="dialect">org.hibernate.dialect.DerbyDialect</prop>
</props>
</property>
</bean>
<bean id="DaoImpl" class="org.shekar.dao.DaoImpl">
<property name="sessn" ref="sessn"/>
</bean>
</beans>
PS: -Any Design mistakes be forgiven I am noob, this post is solely for learning purpose
Using RESTeasy framework instead of Jersey framework for RESTFUL fixed NPE issue apparently Jersey has issues with Spring 4 and Hibernate 5
Related
It is my first application in SpringMVC using Maven.
here is the application structure.
Controller code:
When I click on the link in the index.jsp the page should be traversed to helloworld.jsp
index.jsp has this link:
<h3>
Click Here
</h3>
helloworld.jsp
<h2>
${message} ${name}
</h2>
The code for dispatcher servlet:
Update: web.xml file.
I understand that it's a silly question, but as a newbie to SpringMVC structure, I am not able to find the error. Please help!
Spring is starting up.
This is the homepage, when I click on the link, it should be traversed to helloworld.jsp.
And this is the pom.xml.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>demoproject</groupId>
<artifactId>demoMVC</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>demoMVC Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>4.0.1.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<build>
<finalName>demoMVC</finalName>
<directory>${basedir}/target</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</build>
</project>
Console:
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:demoMVC' did not find a matching property.
Mar 31, 2017 1:22:08 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Mar 31, 2017 1:22:08 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Mar 31, 2017 1:22:08 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1005 ms
Mar 31, 2017 1:22:08 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 31, 2017 1:22:08 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.34
Mar 31, 2017 1:22:12 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Mar 31, 2017 1:22:12 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Mar 31, 2017 1:22:12 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Mar 31, 2017 1:22:12 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3739 ms
In the logs you should see something like:
19:05:56,530 INFO [io.undertow.servlet] (ServerService Thread Pool -- 106) Initializing Spring FrameworkServlet 'mvc-dispatcher'
19:05:56,531 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 106) FrameworkServlet 'mvc-dispatcher': initialization started
19:05:56,547 INFO [org.springframework.web.context.support.XmlWebApplicationContext] (ServerService Thread Pool -- 106) Refreshing WebApplicationContext for namespace 'mvc-dispatcher-servlet': startup date [Fri Mar 31 19:05:56 UTC 2017]; root of context hierarchy
19:05:56,584 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 106) Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]
19:05:56,741 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (ServerService Thread Pool -- 106) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
19:05:56,859 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 106) Mapped "{[/hello],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto protected org.springframework.web.servlet.ModelAndView com.crramirez.HelloWorldController.showMessage(java.lang.String) throws java.lang.Exception
19:05:57,084 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 106) FrameworkServlet 'mvc-dispatcher': initialization completed in 553 ms
Delete these lines in web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
and rename the file in WEB-INF from dispatcher-servlet.xml to mvc-dispatcher-servlet.xml
With this your program should work.
Im running a jersey web application using Eclipse + Maven + Tomcat (8.5).
When I try to add the geotools dependencies in the pom.xml Tomcat doesnt start due to: "SEVERE: A child container failed during start".
I would like to understand the reason of this error. Are the jar in geotools repositories corrupted?
Tomcat error:
Sep 08, 2016 11:13:52 AM
org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING:
[SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting
property 'source' to 'org.eclipse.jst.jee.server:waytorest' did not
find a matching property. Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: Server
version: Apache Tomcat/8.0.8.5.4 Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: Server
built: Jul 6 2016 08:43:30 UTC Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: Server
number: 8.5.4.0 Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name:
Windows 10 Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: OS
Version: 10.0 Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO:
Architecture: amd64 Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home:
C:\Program Files\Java\jdk1.8.0_101\jre Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: JVM
Version: 1.8.0_101-b13 Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: JVM
Vendor: Oracle Corporation Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO:
CATALINA_BASE:
C:\Users\m_deli02\Documents\Development\workspaceMasterProject.metadata.plugins\org.eclipse.wst.server.core\tmp0
Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO:
CATALINA_HOME: C:\apache-tomcat-8.5.4 Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: Command
line argument:
-Dcatalina.base=C:\Users\m_deli02\Documents\Development\workspaceMasterProject.metadata.plugins\org.eclipse.wst.server.core\tmp0
Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: Command
line argument: -Dcatalina.home=C:\apache-tomcat-8.5.4 Sep 08, 2016
11:13:52 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument:
-Dwtp.deploy=C:\Users\m_deli02\Documents\Development\workspaceMasterProject.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: Command
line argument: -Djava.endorsed.dirs=C:\apache-tomcat-8.5.4\endorsed
Sep 08, 2016 11:13:52 AM
org.apache.catalina.startup.VersionLoggerListener log INFO: Command
line argument: -Dfile.encoding=Cp1252 Sep 08, 2016 11:13:52 AM
org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The
APR based Apache Tomcat Native library which allows optimal
performance in production environments was not found on the
java.library.path: C:\Program
Files\Java\jdk1.8.0_101\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program
Files/Java/jre1.8.0_101/bin/server;C:/Program
Files/Java/jre1.8.0_101/bin;C:/Program
Files/Java/jre1.8.0_101/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program
Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS
Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program
Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files
(x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program
Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program
Files\Intel\WiFi\bin\;C:\Program Files\Common
Files\Intel\WirelessCommon\;C:\Program
Files\Java\jdk1.8.0_101\bin;C:\Program
Files\Java\jre1.8.0_101\bin;C:\Users\m_deli02\AppData\Local\atom\bin;C:\Program
Files\eclipse;;. Sep 08, 2016 11:13:52 AM
org.apache.coyote.AbstractProtocol init INFO: Initializing
ProtocolHandler ["http-nio-9080"] Sep 08, 2016 11:13:52 AM
org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO:
Using a shared selector for servlet write/read Sep 08, 2016 11:13:52
AM org.apache.coyote.AbstractProtocol init INFO: Initializing
ProtocolHandler ["ajp-nio-9009"] Sep 08, 2016 11:13:52 AM
org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO:
Using a shared selector for servlet write/read Sep 08, 2016 11:13:52
AM org.apache.catalina.startup.Catalina load INFO: Initialization
processed in 774 ms Sep 08, 2016 11:13:52 AM
org.apache.catalina.core.StandardService startInternal INFO: Starting
service Catalina Sep 08, 2016 11:13:52 AM
org.apache.catalina.core.StandardEngine startInternal INFO: Starting
Servlet Engine: Apache Tomcat/8.0.8.5.4 Sep 08, 2016 11:13:53 AM
org.apache.catalina.core.ContainerBase startInternal SEVERE: A child
container failed during start java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/waytorest]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122) at
java.util.concurrent.FutureTask.get(FutureTask.java:192) at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/waytorest]]
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
... 6 more Caused by: org.apache.catalina.LifecycleException: Failed
to start component
[org.apache.catalina.webresources.StandardRoot#348149c3] at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at
org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4831)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4963)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 6 more Caused by: org.apache.catalina.LifecycleException: Failed
to initialize component
[org.apache.catalina.webresources.JarResourceSet#3f569107] at
org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:111)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:141)
at
org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:701)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 9 more Caused by: java.lang.IllegalArgumentException:
java.util.zip.ZipException: invalid LOC header (bad signature) at
org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:139)
at
org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
... 12 more Caused by: java.util.zip.ZipException: invalid LOC header
(bad signature) at java.util.zip.ZipFile.read(Native Method) at
java.util.zip.ZipFile.access$1400(ZipFile.java:60) at
java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717) at
java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419)
at
java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at sun.misc.IOUtils.readFully(IOUtils.java:65) at
java.util.jar.JarFile.getBytes(JarFile.java:425) at
java.util.jar.JarFile.getManifestFromReference(JarFile.java:193) at
java.util.jar.JarFile.getManifest(JarFile.java:180) at
org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:137)
... 13 more
Sep 08, 2016 11:13:53 AM org.apache.catalina.core.ContainerBase
startInternal SEVERE: A child container failed during start
java.util.concurrent.ExecutionException:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost]] at
java.util.concurrent.FutureTask.report(FutureTask.java:122) at
java.util.concurrent.FutureTask.get(FutureTask.java:192) at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:791)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.startup.Catalina.start(Catalina.java:655) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495) Caused
by: org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost]] at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by:
org.apache.catalina.LifecycleException: A child container failed
during start at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 6 more
Sep 08, 2016 11:13:53 AM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is
unable to start. org.apache.catalina.LifecycleException: Failed to
start component [StandardServer[9005]] at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at org.apache.catalina.startup.Catalina.start(Catalina.java:655) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495) Caused
by: org.apache.catalina.LifecycleException: Failed to start component
[StandardService[Catalina]] at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:791)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 7 more Caused by: org.apache.catalina.LifecycleException: Failed
to start component [StandardEngine[Catalina]] at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 9 more Caused by: org.apache.catalina.LifecycleException: A child
container failed during start at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
... 11 more
Sep 08, 2016 11:13:53 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-nio-9080"] Sep 08, 2016 11:13:53
AM org.apache.coyote.AbstractProtocol pause INFO: Pausing
ProtocolHandler ["ajp-nio-9009"] Sep 08, 2016 11:13:53 AM
org.apache.catalina.core.StandardService stopInternal INFO: Stopping
service Catalina Sep 08, 2016 11:13:53 AM
org.apache.coyote.AbstractProtocol destroy INFO: Destroying
ProtocolHandler ["http-nio-9080"] Sep 08, 2016 11:13:53 AM
org.apache.coyote.AbstractProtocol destroy INFO: Destroying
ProtocolHandler ["ajp-nio-9009"]
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wayto</groupId>
<artifactId>waytorest</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>waytorest Jersey Webapp</name>
<build>
<finalName>waytorest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Run the application using "mvn embedded-glassfish:run" -->
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>${glassfish.version}</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<app>C:/Users/m_deli02/Documents/Development/workspaceMasterProject/target/${project.build.finalName}.war</app>
<autoDelete>true</autoDelete>
<port>8080</port>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-web</artifactId>
<version>${glassfish.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1202-jdbc42</version>
</dependency>
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.goebl</groupId>
<artifactId>simplify</artifactId>
<version>1.0.0</version>
</dependency>
<!--Can`t add geotools libaries. Tomcat error in extract Jars-->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>${geotools.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>boundless</id>
<name>Boundless Maven Repository</name>
<url>http://repo.boundlessgeo.com/main</url>
</repository>
</repositories>
<properties>
<jersey.version>1.19</jersey.version>
<glassfish.version>3.1.1</glassfish.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<geotools.version>15.1</geotools.version>
</properties>
</project>
Problem solved.
I removed the jitpack repository:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
Then I manually deleted geotools files in the .m2 repository.
Run Maven clean and install and done! Tomcat started normally.
I am trying to create a web project using spring framework. When trying to run the project, I am getting a HTTP Status 404 error in the browser.
Here is the stack trace of the problem from the console:
Apr 17, 2016 8:43:11 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_60\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.8.0_60/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_60/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_60/bin/../jre/lib/amd64;C:\Program Files\IBM\ILOG\CPLEX_Studio_Community1263\opl\bin\x64_win64;C:\Program Files\IBM\ILOG\CPLEX_Studio_Community1263\opl\oplide\;C:\Program Files\IBM\ILOG\CPLEX_Studio_Community1263\cplex\bin\x64_win64;C:\Program Files\IBM\ILOG\CPLEX_Studio_Community1263\cpoptimizer\bin\x64_win64;C:\Program Files\Java\jdk1.8.0_60\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\;C:\Program Files\OpenVPN\bin;C:\Program Files\Java\jdk1.8.0_60;C:\adb;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\Zorba XQuery Processor 3.0.0\bin;C:\Program Files\Java\jdk1.8.0_60;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\Users\prati\AppData\Local\atom\bin;C:\Users\prati\Downloads\eclipse-jee-mars-R-win32-x86_64\eclipse;;.
Apr 17, 2016 8:43:11 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:CRUDWebAppMavenized' did not find a matching property.
Apr 17, 2016 8:43:11 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Apr 17, 2016 8:43:11 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Apr 17, 2016 8:43:11 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 656 ms
Apr 17, 2016 8:43:11 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 17, 2016 8:43:11 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Apr 17, 2016 8:43:13 PM org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'webapp.root' = [C:\Users\prati\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp6\wtpwebapps\CRUDWebAppMavenized\]
Apr 17, 2016 8:43:13 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [classpath:log4j.xml]
Apr 17, 2016 8:43:13 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.NoClassDefFoundError: org/apache/log4j/xml/DOMConfigurator
at org.springframework.util.Log4jConfigurer.initLogging(Log4jConfigurer.java:69)
at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:151)
at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
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.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.xml.DOMConfigurator
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
... 12 more
Apr 17, 2016 8:43:13 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Apr 17, 2016 8:43:13 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/CRUDWebAppMavenized] startup failed due to previous errors
Apr 17, 2016 8:43:13 PM org.apache.catalina.core.ApplicationContext log
INFO: Shutting down log4j
Apr 17, 2016 8:43:13 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.NoClassDefFoundError: org/apache/log4j/LogManager
at org.springframework.util.Log4jConfigurer.shutdownLogging(Log4jConfigurer.java:116)
at org.springframework.web.util.Log4jWebConfigurer.shutdownLogging(Log4jWebConfigurer.java:169)
at org.springframework.web.util.Log4jConfigListener.contextDestroyed(Log4jConfigListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
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.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
... 13 more
Apr 17, 2016 8:43:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Apr 17, 2016 8:43:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Apr 17, 2016 8:43:13 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2193 ms
Here is my log4j.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
</layout>
</appender>
<appender name="util" class="org.apache.log4j.FileAppender">
<param name="File" value="C:\\ITLab\\logs\\GeneralLogs.log" />
<param name="Append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
</layout>
</appender>
<!-- Application Loggers -->
<logger name="com.hp.gcc">
<level value="info" />
</logger>
<!-- 3rdparty Loggers -->
<logger name="org.springframework.core">
<level value="info" />
</logger>
<logger name="org.springframework.beans">
<level value="info" />
</logger>
<logger name="org.springframework.context">
<level value="info" />
</logger>
<logger name="org.springframework.web">
<level value="info" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
Here is web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>CRUDWebAppMavenized</display-name>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<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>
</web-app>
Here is pom.xml:
<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>CRUDWebAppMavenized</groupId>
<artifactId>CRUDWebAppMavenized</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Hibernate resources -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>20030825.184428</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>20030825.183949</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<!-- Log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/main/test</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/webapp</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Kindly tell me what's wrong with my code, and please provide solutions. Thanks a lot! :)
i got it!
Problem is:
org.springframework.web.util.Log4jConfigListener
This is deprecated from Spring Framework 4.2.1. Only delete this listener!
Maybe you should add the dependencies in the pom.xml:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
</dependency>
I fixed by using below pom dependency !
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.5-beta5</version>
</dependency>
This question already has an answer here:
How to properly install and configure JSF libraries via Maven?
(1 answer)
Closed 3 years ago.
I've been trying to deploy JSF components on Apache Tomcat 8. Everytime I restart and deploy server I get ClassNotFoundException.
LOG
Jul 20, 2014 10:31:35 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Jul 20, 2014 10:31:35 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jul 20, 2014 10:31:35 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Jul 20, 2014 10:31:35 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jul 20, 2014 10:31:35 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1451 ms
Jul 20, 2014 10:31:35 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 20, 2014 10:31:35 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.9
Jul 20, 2014 10:31:35 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Jul 20, 2014 10:31:35 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Jul 20, 2014 10:31:35 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 191 ms
Connected to server
[2014-07-20 10:31:35,659] Artifact Java:war exploded: Artifact is being deployed, please wait...
Jul 20, 2014 10:31:36 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Faces Servlet as unavailable
Jul 20, 2014 10:31:36 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet threw load() exception
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:550)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:531)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1041)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4932)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5218)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1588)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
at sun.rmi.transport.Transport$1.run(Transport.java:178)
at sun.rmi.transport.Transport$1.run(Transport.java:175)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:174)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:557)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:812)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:671)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>JavaServerFaces</display-name>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>\index.xhtml</welcome-file>
</welcome-file-list>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
And here is maven dependency
pom.xml
<!-- JSF dependency -->
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
This dependency I added later when I was trying to deploy with GlassFish
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
</dependency>
I also tried with GlassFish 4.0 but unable to resolve the problem.
EDIT
I updated POM with these dependencies
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
But I'm still not able to deploy with Tomcat 8.0.9. When I deploy using console manager of tomcat I get XML parsing error on every page.
For tomcat you have to have both jsf-api and jsf-impl since tomcat don't have bundled JSF. Please add the following dependency
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>
Update the version to which ever version you need.
I have a Java webapp for tomcat 7 that uses an H2 database for the data as well as for the user authentication.
When I deploy the webapp on a standalone Tomcat everything works fine.
Now I want to run integration tests with maven. I use the tomcat7-maven-plugin version 2.1
When I run the integration tests the tomcat (embedded) it uses the tomcat-users.xml only.
I have put my server.xml into src/main/tomcatconf and it will be copied correctly into the target/tomcat/conf.
my realm definition in the server.xml
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.h2.Driver"
connectionURL="jdbc:h2:DB/db;USER=user;PASSWORD=password;AUTO_SERVER=TRUE;"
userTable="userAuth" userNameCol="username" userCredCol="userpass"
userRoleTable="userAuth" roleNameCol="groupname" digest="SHA-512"/>
my pom.xml
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<argLine>${failsafe.argLine}</argLine>
<fork>true</fork>
<path>/</path>
<contextFile>${project.build.directory}/ROOT/META-INF/context.xml</contextFile>
<systemProperties>
<JAVA_OPTS>-Xms128m -Xmx256m -XX:PermSize=512m -XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled</JAVA_OPTS>
</systemProperties>
</configuration>
<executions>
<execution>
<id>tomcat-run</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war-only</goal>
</goals>
<configuration>
<path>/</path>
<serverXml>src/main/tomcatconf/server.xml</serverXml>
<port>8080</port>
</configuration>
</execution>
<execution>
<id>tomcat-shutdown</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.173</version>
</dependency>
</dependencies>
</plugin>
I tried different approaches I've on the Internet (and also on the Apache site) but nothing worked.
When I add a tomcat-users.xml that contains my test users the tests work.
UPDATE
here the log
Running war on http://localhost:8080/
Creating Tomcat server configuration at D:\project\target\tomcat
Coping additional tomcat config files
copy server.xml
copy _tomcat-users.xml
setting SystemProperties:
JAVA_OPTS=-Xms128m -Xmx256m -XX:PermSize=512m -XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled
create webapp with contextPath:
Feb 10, 2014 2:44:40 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Feb 10, 2014 2:44:40 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Feb 10, 2014 2:44:40 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.37
Feb 10, 2014 2:44:42 PM org.jboss.weld.bootstrap.WeldBootstrap <clinit>
INFO: WELD-000900 2.0.3 (Final)
Feb 10, 2014 2:44:42 PM org.jboss.weld.bootstrap.WeldBootstrap startContainer
INFO: WELD-000101 Transactional services not available. Injection of #Inject UserTransaction not available. Transactional observers will be invoked synchronously.
Feb 10, 2014 2:44:43 PM org.jboss.weld.environment.tomcat7.Tomcat7Container initialize
INFO: Tomcat 7 detected, CDI injection will be available in Servlets and Filters. Injection into Listeners is not supported
Feb 10, 2014 2:44:43 PM org.jboss.weld.interceptor.util.InterceptionTypeRegistry <clinit>
WARNING: Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
Feb 10, 2014 2:44:43 PM org.jboss.weld.interceptor.util.InterceptionTypeRegistry <clinit>
WARNING: Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
Feb 10, 2014 2:44:43 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
--- jacoco-maven-plugin:0.6.3.201306030806:prepare-agent (pre-integration-test) # ILS_webapp
--- exec-maven-plugin:1.2.1:exec (gen-mvnopts-bat) # ILS_webapp ---
--- maven-resources-plugin:2.6:copy-resources (copy-resources) # ILS_webapp ---
Using 'UTF-8' encoding to copy filtered resources.
Copying 6 resources
I renamed tomcat-users.xml th _tomcat-users.xml to avoid that this file is used as realm.
The webapps deploys well. Only the authentication doesn't work.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<listener>
<listener-class>
org.jboss.weld.environment.servlet.Listener
</listener-class>
</listener>
<resource-env-ref>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
<security-constraint>
<web-resource-collection>
<url-pattern>/error/*</url-pattern>
<!-- <url-pattern>/css/*</url-pattern>-->
<url-pattern>/js/*</url-pattern>
<url-pattern>/img/*</url-pattern>
<url-pattern>/api/*</url-pattern>
<url-pattern>/resources/*</url-pattern>
<url-pattern>/favicon.ico</url-pattern>
</web-resource-collection>
</security-constraint>
<security-constraint>
<display-name>secure</display-name>
<web-resource-collection>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
<role-name>USER</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>myRealm</realm-name>
<form-login-config>
<form-login-page>/index.html</form-login-page>
<form-error-page>/index_failed.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>ADMIN</role-name>
</security-role>
<security-role>
<role-name>USER</role-name>
</security-role>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>