Why is my simple springmvc web application shutting down Jetty? - java

Looking at my log files of a simple springmvc application (the homecontroller index action outputs 'hello world'), it seems the site is shutting down for some reason?
I simply pushed my .war file to the jetty_home/webapps folder, and started the jetty service.
ubuntu#ip-10-123-44-55:/usr/share/jetty/logs$ cat 2011_11_01.stderrout.log.022538550
2011-11-01 02:15:26.080:INFO::jetty-6.1.24
2011-11-01 02:15:26.192:INFO::Deploy /etc/jetty/contexts/javadoc.xml -> org.mortbay.jetty.handler.ContextHandler#8b819f{/javadoc,file:/usr/share/jetty/javadoc}
2011-11-01 02:15:26.338:INFO::Extract file:/var/lib/jetty/webapps/springmvc.war to /var/cache/jetty/data/Jetty__8080_springmvc.war__springmvc__s1aryk/webapp
2011-11-01 02:15:26.821:INFO::NO JSP Support for /springmvc, did not find org.apache.jasper.servlet.JspServlet
2011-11-01 02:15:28.245:INFO:/springmvc:Initializing Spring FrameworkServlet 'springmvc'
0 [main] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'springmvc': initialization started
69 [main] INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'springmvc-servlet': startup date [Tue Nov 01 02:15:28 UTC 2011]; root of context hierarchy
145 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/servlet-context.xml]
504 [main] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
795 [main] INFO org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
853 [main] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#1cd107f: defining beans [homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0]; root of factory hierarchy
1064 [main] INFO org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Root mapping to handler 'homeController'
1446 [main] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'springmvc': initialization completed in 1445 ms
2011-11-01 02:15:29.738:INFO::NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet
2011-11-01 02:15:29.746:INFO::Opened /var/log/jetty/2011_11_01.request.log
2011-11-01 02:15:29.810:INFO::Started SelectChannelConnector#:8080
hello, world!
2011-11-01 02:24:01.775:INFO::Shutdown hook executing
2011-11-01 02:24:01.775:INFO::Graceful shutdown SelectChannelConnector#:8080
2011-11-01 02:24:01.828:INFO::Graceful shutdown org.mortbay.jetty.handler.ContextHandler#8b819f{/javadoc,file:/usr/share/jetty/javadoc}
2011-11-01 02:24:01.828:INFO::Graceful shutdown org.mortbay.jetty.webapp.WebAppContext#caf0ed{/springmvc,file:/var/lib/jetty/webapps/springmvc.war}
2011-11-01 02:24:01.828:INFO::Graceful shutdown org.mortbay.jetty.webapp.WebAppContext#18f6559{,file:/var/lib/jetty/webapps/root/}
2011-11-01 02:24:02.828:INFO::Stopped SelectChannelConnector#:8080
2011-11-01 02:24:02.829:INFO:/springmvc:Destroying Spring FrameworkServlet 'springmvc'
514583 [Shutdown] INFO org.springframework.web.context.support.XmlWebApplicationContext - Closing WebApplicationContext for namespace 'springmvc-servlet': startup date [Tue Nov 01 02:15:28 UTC 2011]; root of context hierarchy
514584 [Shutdown] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#1cd107f: defining beans [homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0]; root of factory hierarchy
2011-11-01 02:24:02.834:INFO::Shutdown hook complete
This is a IntelliJ .war file that was built using a maven project.
This is my first deploy so please don't assume I know what I'm doing :)
Update
Actually it seems to be up, when I do a wget localhost:8080/springmvc/ I get the message:
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 500 JSP support not configured
2011-11-01 02:33:34 ERROR 500: JSP support not configured.
For some reason this isn't working on jetty, it worked fine on tomcat?

if this is a maven project add the yetty plugin to your pom file
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
</plugin>
</plugins>
then execute the following command
mvn jetty:run

According to this link
Jetty does not implement JSP directly. Instead it uses a servlet to provide this functionality required by the servle specification. [...] the companion of 2.5 servlet specification is the 2.1 JSP specification
So you need a jar with JSP.
If you're using Jetty 6 within the maven plugin I imagine that the dependency that Peter Szanto answered will solve it. On the other hand, if you are using it as part of your application you'll need to add an appropriate jsp jar.
For example for a Maven project using Jetty 6.1 you can include in the pom.xml:
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>6.1.14</version>
</dependency>

Related

How to resolve Tomcat 9 not starting with Mojarra error

I'm porting a Tomcat 6 app to Tomcat 9 I receive this error starting Tomcat:
30-Dec-2022 15:22:16.039 INFO [main] com.sun.faces.config.ConfigureListener.contextInitialized Initializing Mojarra (1.2_12-b01-FCS) for context '/ordini'
SEVERE [main] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
SEVERE [main] org.apache.catalina.core.StandardContext.startInternal Context [/ordini] startup failed due to previous errors
30-Dec-2022 15:22:17.679 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [C:\smiweb\tomcat-9.0.70\conf\Catalina\localhost\ordini.xml] has finished in [5,828] ms
30-Dec-2022 15:22:17.679 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [C:\smiweb\tomcat-9.0.70\conf\Catalina\localhost\ROOT.xml]
30-Dec-2022 15:22:17.679 WARNING [main] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [] in deployment descriptor [C:\smiweb\tomcat-9.0.70\conf\Catalina\localhost\ROOT.xml] has been ignored
30-Dec-2022 15:22:17.679 WARNING [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [C:\smiweb\tomcat-9.0.70\conf\Catalina\localhost\ROOT.xml] with an external docBase means the directory [C:\smiweb\tomcat-9.0.70\webapps\ROOT] in the appBase will be ignored
30-Dec-2022 15:22:20.711 WARNING [main] org.apache.catalina.startup.ContextConfig.validateSecurityRoles Security role name [smi] used in an <auth-constraint> without being defined in a <security-role>
30-Dec-2022 15:22:20.929 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars 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.
30-Dec-2022 15:22:20.992 INFO [main] com.sun.faces.config.ConfigureListener.contextInitialized Initializing Mojarra (1.2_12-b01-FCS) for context ''
30-Dec-2022 15:22:20.992 WARNING [main] com.sun.faces.config.ConfigureListener.contextInitialized JSF1059: WARNING! The com.sun.faces.verifyObjects feature is to aid developers not using tools. It shouldn''t be enabled if using an IDE, or if this application is being deployed for production as it will impact application start times.
30-Dec-2022 15:22:21.586 INFO [main] com.sun.faces.spi.InjectionProviderFactory.createInstance JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
30-Dec-2022 15:22:22.148 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
Resolved thank you I discovered there was a localhost log file and I found was missing a class.

How to deploy a camel java DSL servlet on Tomcat server?

I have found several examples of camel servlet for tomcat server using spring DSL, I want to use Java DSL and create a RouteBuilder as shown below. This servlet works as expected on Jetty when I run using mvn jetty:run command, but doesn't work with tomcat server.
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
public class DefaultRouteBuilder extends RouteBuilder {
#Override
public void configure() throws Exception {
System.out.println("DefaultRouter");
from("servlet:hello?matchOnUriPrefix=true").process(new Processor() {
public void process(Exchange exchange) throws Exception {
String contentType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class);
String path = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
path = path.substring(path.lastIndexOf("/"));
exchange.getOut().setHeader(Exchange.CONTENT_TYPE, contentType + "; charset=UTF-8");
exchange.getOut().setHeader("PATH", path);
exchange.getOut().setBody("<b>Hello World</b>");
}
});
}
}
As per my understanding my web.xml looks like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<webapp>
<display-name>camel-servlet</display-name>
<context-param>
<param-name>name</param-name>
<param-value>MyCamel</param-value>
</context-param>
<context-param>
<param-name>routeBuilder-MyRoute</param-name>
<param-value>org.apache.camel.community.so.servletlistener.DefaultRouteBuilder</param-value>
</context-param>
<listener>
<listener-class>org.apache.camel.component.servletlistener.JndiCamelServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>CamelServlet</servlet-name>
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/camel/*</url-pattern>
</servlet-mapping>
</webapp>
Edit:
Logs from mvn jetty:run command -
[INFO] Scanning elapsed time=1409ms
[INFO] DefaultSessionIdManager workerName=node0
[INFO] No SessionScavenger set, using defaults
[INFO] node0 Scavenging every 660000ms
2022-07-19 11:15:39,454 [main ] INFO CamelServletContextListener - CamelContextServletListener initializing ...
DefaultRouter
2022-07-19 11:15:39,797 [main ] INFO ServletCamelContext - Apache Camel 2.25.0 (CamelContext: MyCamel) is starting
2022-07-19 11:15:39,804 [main ] INFO ManagedManagementStrategy - JMX is enabled
2022-07-19 11:15:40,094 [main ] INFO DefaultTypeConverter - Type converters loaded (core: 195, classpath: 9)
2022-07-19 11:15:40,233 [main ] INFO ServletCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2022-07-19 11:15:40,272 [main ] INFO ServletCamelContext - Route: route1 started and consuming from: servlet:/hello?matchOnUriPrefix=true
2022-07-19 11:15:40,274 [main ] INFO ServletCamelContext - Total 1 routes, of which 1 are started
2022-07-19 11:15:40,276 [main ] INFO ServletCamelContext - Apache Camel 2.25.0 (CamelContext: MyCamel) started in 0.483 seconds
2022-07-19 11:15:40,277 [main ] INFO CamelServletContextListener - CamelContextServletListener initialized
2022-07-19 11:15:40,316 [main ] INFO CamelHttpTransportServlet - Initialized CamelHttpTransportServlet[name=CamelServlet, contextPath=/camel-example-servlet]
[INFO] Started o.e.j.m.p.JettyWebAppContext#2764c546{Camel Servlet Example,/camel-example-servlet,file:///C:/Users/rrdoshi/Downloads/camel-example-servlet/src/main/webapp/,AVAILABLE}{file:///C:/Users/rrdoshi/Downloads/camel-example-servlet/src/main/webapp/}
[INFO] Started ServerConnector#2b73bd6b{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started #8097ms
[INFO] Started Jetty Server
For tomcat deployment, I am placing the war file in tomcat webapps directory and executing startup.bat
19-Jul-2022 11:21:21.403 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars 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.
19-Jul-2022 11:21:21.576 WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [146] milliseconds.
19-Jul-2022 11:21:21.596 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\ApacheCamelDemoServlet]
19-Jul-2022 11:21:21.645 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\ApacheCamelDemoServlet] has finished in [49] ms
19-Jul-2022 11:21:21.646 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\docs]
19-Jul-2022 11:21:21.671 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\docs] has finished in [25] ms
19-Jul-2022 11:21:21.672 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\examples]
19-Jul-2022 11:21:22.097 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\examples] has finished in [425] ms
19-Jul-2022 11:21:22.099 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\host-manager]
19-Jul-2022 11:21:22.135 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\host-manager] has finished in [36] ms
19-Jul-2022 11:21:22.136 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\manager]
19-Jul-2022 11:21:22.175 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\manager] has finished in [38] ms
19-Jul-2022 11:21:22.175 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\ROOT]
19-Jul-2022 11:21:22.202 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\ROOT] has finished in [26] ms
19-Jul-2022 11:21:22.205 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8088"]
19-Jul-2022 11:21:22.224 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [2721] milliseconds
access logs
127.0.0.1 - - [19/Jul/2022:11:23:51 +0530] "GET /camel-servlet/ HTTP/1.1" 200 1675
127.0.0.1 - - [19/Jul/2022:11:24:01 +0530] "GET /camel-servlet/camel/hello HTTP/1.1" 404 784
localhost logs
19-Jul-2022 11:21:22.085 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
19-Jul-2022 11:21:22.085 INFO [main] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
19-Jul-2022 11:21:22.087 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: attributeAdded('StockTicker', 'async.Stockticker#68ab0936')
The WAR file is getting deployed but there are no error logs. There are no logs regarding camelContext starting up.

how to access file in root server with spring security

i am using grails 3.1.1
i already deployment my war file with tomcat 8 and i store all my image's file into /app/Item/
this is my folder's structure in my server.
/app/Item/<all my image>
/home
/root/apache-tomcat-8/
/apache-tomcat-8/webapps
/apache-tomcat-8/webapps/ROOT.war
/apache-tomcat-8/bin
/apache-tomcat-8/logs
/apache-tomcat-8/work
/apache-tomcat-8/temp
/apache-tomcat-8/conf
now i am using symlink to access /app/Item
so i create a symlink in /apache-tomcat-8/webapps/images with name images
so when i access localhost:8080/images/100.JPG it will access to /app/Item/100.JPG
but i will get some error log if i rerun my tomcat, because folder images where i create with symlink isnot in my grails project.
like this..
28-Feb-2017 12:43:44.962 WARNING [localhost-startStop-2] org.apache.naming.NamingContext.lookup Unexpected exception resolving reference
java.sql.SQLException: Unable to load class: com.mysql.jdbc.Driver from ClassLoader:java.net.URLClassLoader#1fb3ebeb;ClassLoader:ParallelWebappClassLoader
context: gambarku
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader#1fb3ebeb
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:283)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:718)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:650)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:468)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143)
now i want to know how to access my folder /app/Item/ without symlink but from my grails application?
i tried to deploy without symlink or images's folder (shortcut)
[root#li1447-147 bin]# cd ..
[root#li1447-147 apache-tomcat-8.5.8]# cd we
-bash: cd: we: No such file or directory
[root#li1447-147 apache-tomcat-8.5.8]# cd webapps/
[root#li1447-147 webapps]# rm -rf *
[root#li1447-147 webapps]# clear
[root#li1447-147 webapps]# cd ..
[root#li1447-147 apache-tomcat-8.5.8]# cd bin/
[root#li1447-147 bin]# ./startup.sh
Using CATALINA_BASE: /root/apache-tomcat-8.5.8
Using CATALINA_HOME: /root/apache-tomcat-8.5.8
Using CATALINA_TMPDIR: /root/apache-tomcat-8.5.8/temp
Using JRE_HOME: /usr/java/jdk1.8.0_112
Using CLASSPATH: /root/apache-tomcat-8.5.8/bin/bootstrap.jar:/root/apache- tomcat-8.5.8/bin/tomcat-juli.jar
Tomcat started.
[root#li1447-147 bin]# tail -f ../logs/catalina.out
28-Feb-2017 16:13:06.353 INFO [main] org.apache.coyote.AbstractProtocol.init Ini tializing ProtocolHandler ["http-nio-80"]
28-Feb-2017 16:13:06.368 INFO [main] org.apache.tomcat.util.net.NioSelectorPool. getSharedSelector Using a shared selector for servlet write/read
28-Feb-2017 16:13:06.370 INFO [main] org.apache.coyote.AbstractProtocol.init Ini tializing ProtocolHandler ["https-jsse-nio-443"]
28-Feb-2017 16:13:06.613 INFO [main] org.apache.tomcat.util.net.NioSelectorPool. getSharedSelector Using a shared selector for servlet write/read
28-Feb-2017 16:13:06.613 INFO [main] org.apache.coyote.AbstractProtocol.init Ini tializing ProtocolHandler ["ajp-nio-8009"]
28-Feb-2017 16:13:06.615 INFO [main] org.apache.tomcat.util.net.NioSelectorPool. getSharedSelector Using a shared selector for servlet write/read
28-Feb-2017 16:13:06.615 INFO [main] org.apache.catalina.startup.Catalina.load I nitialization processed in 796 ms
28-Feb-2017 16:13:06.637 INFO [main] org.apache.catalina.core.StandardService.st artInternal Starting service Catalina
28-Feb-2017 16:13:06.637 INFO [main] org.apache.catalina.core.StandardEngine.sta rtInternal Starting Servlet Engine: Apache Tomcat/8.5.8
28-Feb-2017 16:13:06.657 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployWAR Deploying web application archive /root/apache-tomcat-8.5 .8/webapps/ROOT.war
28-Feb-2017 16:13:13.193 INFO [localhost-startStop-1] org.apache.jasper.servlet. TldScanner.scanJars 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 scan ned but no TLDs were found in them. Skipping unneeded JARs during scanning can i mprove startup time and JSP compilation time.
Configuring Spring Security Core ...
... finished configuring Spring Security Core
28-Feb-2017 16:13:49.628 INFO [localhost-startStop-1] org.apache.catalina.startu p.HostConfig.deployWAR Deployment of web application archive /root/apache-tomcat -8.5.8/webapps/ROOT.war has finished in 42,968 ms
28-Feb-2017 16:13:49.632 INFO [main] org.apache.coyote.AbstractProtocol.start St arting ProtocolHandler [http-nio-80]
28-Feb-2017 16:13:49.638 INFO [main] org.apache.coyote.AbstractProtocol.start St arting ProtocolHandler [https-jsse-nio-443]
28-Feb-2017 16:13:49.639 INFO [main] org.apache.coyote.AbstractProtocol.start St arting ProtocolHandler [ajp-nio-8009]
28-Feb-2017 16:13:49.640 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 43024 ms
------------------this is for symlink
then i tried to read this and add this code to my server.xml
<Context docBase="/app/Item" path="/gambarku" />
then startup.sh again.
i get this log.
28-Feb-2017 17:00:49.701 WARNING [localhost-startStop-1] org.apache.catalina.core.NamingContextListener.addResource Failed to register in JMX: javax.naming.NamingException: Unable to load class: com.mysql.jdbc.Driver from ClassLoader:java.net.URLClassLoader#1fb3ebeb;ClassLoader:ParallelWebappClassLoader
context: gambarku
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader#1fb3ebeb
28-Feb-2017 17:00:49.772 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /root/apache-tomcat-8.5.8/webapps/ROOT.war
28-Feb-2017 17:00:56.238 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars 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.
this log is same when i tried to use symlink.
i tried to find some documentation and i already check in folder WEB-INF/lib/mysql-connector-java-5.1.20.jar and build.gradle with runtime 'mysql:mysql-connector-java:5.1.20'
def image = new File('/app/Item/image1.jpg')
This is a long shot but might solve your issue, it's very similar to the config you had originally, just adding allowLinking="true":
Create a symlink between /app/Item and /apache-tomcat-8/webapps/images
Add this to your configuration
<Context docBase="/app/Item" path="/images" allowLinking="true"/>

Apache tomcat issue with Eclipse dynamic web module 3.0

I created Spring MVC project with default configurations it was working/running on the server but when I changed Project Facets to J2EE 6 as following :
now when I run the project I get following message
UPDATE
Please see this project structure :
Controller.java is
#Controller
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
/**
* Simply selects the home view to render by returning its name.
*/
#RequestMapping(method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate );
return "home";
}
}
New Console out put without any error is :
Jun 20, 2015 6:33:38 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Sat Jun 20 18:33:38 PKT 2015]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/root-context.xml]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#1a8f100: defining beans []; root of factory hierarchy
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 893 ms
Jun 20, 2015 6:33:39 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'appServlet'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'appServlet-servlet': startup date [Sat Jun 20 18:33:39 PKT 2015]; parent: Root WebApplicationContext
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#1c047f0: defining beans [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#1a8f100
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String home.com.web.HomeController.home(java.util.Locale,org.springframework.ui.Model)
INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization completed in 2619 ms
with this at http://localhost:8080 also shows HTTP Status 404 Any hint in this case? What should I do?
Your problem has nothing to do with eclipse or dynamic web modules in eclipse, except there exists more than one problem. You have a general problem in your spring configuration.
You are trying to map '/' via RequestMapping - that does not work even in in Spring MVC 4.1.6 - independent of eclipse or dynamic web module.
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
- Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}"
onto public java.lang.String sd.sdse.dsdds.HomeController.home(java.util.Locale,org.springframework.ui.Model)
There are more similar questions about how define a mapping to the context root in in the spring.io forum like "#RequestMapping pointing to /"
You archive this by mapping the Spring Dispatcher Servlet to "/" not "/*"
and by removing the explicit mapping to "/" from your #RequestMapping annotations.
The Project you've shared is not the one which generates the log output. The project not even starts a SpringContext when deployed and executed on Tomcat.
To start the SpringContext you'll either have to configure the ContextLoadListener and / or DispatcherServlet in the web.xml
like here:
<display-name>Home</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/servlet-config.xml</param-value>
</context-param>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Or you need a class that implements the WebApplicationInitializer interface like this one:
public class WebAppInitializer implements WebApplicationInitializer {
#Override
public void onStartup(ServletContext context) {
XmlWebApplicationContext rootContext =
new XmlWebApplicationContext();
rootContext.setConfigLocation("/WEB-INF/spring/root-context.xml");
context.addListener(new ContextLoaderListener(rootContext));
// Create the dispatcher servlet's Spring application context
XmlWebApplicationContext servletContext =
new XmlWebApplicationContext();
servletContext.setConfigLocation("/WEB-INF/spring/appServlet/servlet-context.xml");
// add the dispatcher servlet and map it to /
ServletRegistration.Dynamic dispatcher =
context.addServlet("springDispatcher", new DispatcherServlet(servletContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
}
which loads the spring configuration files(root-context.xml, servlet-context.xml) from the locations you've used in your project.
The fixed version which uses the WebApplicationInitializer can be found on github. I've sent you a pull request.
The console output of the fixed version is:
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#76dc331c: defining beans [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#5c23f9fd
INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.dom.son.HomeController.home(java.util.Locale,org.springframework.ui.Model)
INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'springDispatcher': initialization completed in 430 ms
Jun 21, 2015 12:45:28 PM org.apache.coyote.AbstractProtocol start
Information: Starting ProtocolHandler ["http-bio-8080"]
Jun 21, 2015 12:45:28 PM org.apache.coyote.AbstractProtocol start
Information: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 21, 2015 12:45:28 PM org.apache.catalina.startup.Catalina start
Information: Server startup in 2048 ms
INFO : com.dom.son.HomeController - Welcome home! The client locale is de_DE.
In order to fix your eclipse problem I would suggest to delete the old project from eclipse and re-import the fixed version from github.
In Eclipse:
In the Servers view stop your Tomcat instances.
Remove the deployments from your Tomcat (context menu - > delete)
Delete the Project (ideally remove it from disk, or move it to a different location)
Check out the fixed version (mine or yours with my changes)
Re-import the fixed version (File -> Import.... -> Maven -> Existing
Maven Project)

Deployed Tomcat app on Openshift returns 404

I've deployed my app under following url: https://migawka-hatak.rhcloud.com/,
but constantly I get a 404 status.
The same app works on my local Tomcat or Jetty. When accessing localhost:8080/ROOT/ it returns the default Openshift index page.
From the logs on openshift I can see that it's started:
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Nov 05, 2014 4:14:32 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/openshift/5458e7d3500446ea91000597/app-root/runtime/dependencies/jbosse
ws/webapps/ROOT.war
SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
47 [localhost-startStop-1] INFO org.quartz.impl.StdSchedulerFactory - Using default implementation for ThreadExecutor
53 [localhost-startStop-1] INFO org.quartz.simpl.SimpleThreadPool - Job execution threads will use class loader of threa
d: localhost-startStop-1
148 [localhost-startStop-1] INFO org.quartz.core.SchedulerSignalerImpl - Initialized Scheduler Signaller of type: class
org.quartz.core.SchedulerSignalerImpl
150 [localhost-startStop-1] INFO org.quartz.core.QuartzScheduler - Quartz Scheduler v.2.2.1 created.
158 [localhost-startStop-1] INFO org.quartz.simpl.RAMJobStore - RAMJobStore initialized.
160 [localhost-startStop-1] INFO org.quartz.core.QuartzScheduler - Scheduler meta-data: Quartz Scheduler (v2.2.1) 'Defau
ltQuartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
161 [localhost-startStop-1] INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler 'DefaultQuartzScheduler' initial
ized from default resource file in Quartz package: 'quartz.properties'
161 [localhost-startStop-1] INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler version: 2.2.1
Nov 05, 2014 4:14:40 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/5458e7d3500446ea91000597/app-root/runtime/dependencies/jb
ossews/webapps/ROOT.war has finished in 7,523 ms
Nov 05, 2014 4:14:40 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.9.148.1-8080"]
Nov 05, 2014 4:14:40 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 7825 ms
I'm using quartz in the context listener, also my app is based on the RestEasy framework.
Any idea what is going on?
I've solved problem, by recreating app from scratch, only difference is that I've used web.xml from from tmplate instead of mine.
What is different on web.xml now:
<web-app version="3.0"
xmlns="java.sun.com/xml/ns/javaee"
xmlns:xsi="w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
metadata-complete="false">
</web-app>

Categories

Resources