Deployed Tomcat app on Openshift returns 404 - java

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>

Related

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"/>

Error 404 after deploying a simple Spring MVC app (without web.xml)

I want to learn some basics of Spring MVC based fully on annotations. I started with this tutorial.
After cloning the repository
hg clone https://bitbucket.org/arnelism/snoutbook
and building the war file
mvn package
I am deploying the app by simply copying the war file to the webapps directory of my Apache Tomcat 7.0.12 instance. I am stopping and starting the server.
INFORMATION: Starting Servlet Engine: Apache Tomcat/7.0.12
Sep 12, 2014 3:37:18 PM org.apache.catalina.startup.HostConfig deployWAR
INFORMATION: Deploying web application archive Snoutbook-1.0.0-SNAPSHOT.war
Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory
INFORMATION: Deploying web application directory docs
Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory
INFORMATION: Deploying web application directory examples
Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory
INFORMATION: Deploying web application directory host-manager
Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory
INFORMATION: Deploying web application directory manager
Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.HostConfig deployDirectory
INFORMATION: Deploying web application directory ROOT
Sep 12, 2014 3:37:27 PM org.apache.coyote.AbstractProtocolHandler start
INFORMATION: Starting ProtocolHandler ["http-bio-8080"]
Sep 12, 2014 3:37:27 PM org.apache.coyote.AbstractProtocolHandler start
INFORMATION: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 12, 2014 3:37:27 PM org.apache.catalina.startup.Catalina start
INFORMATION: Server startup in 8826 ms
Unfortunately after this operation I am receiving the error 404 by displaying the page.
http://localhost:8080/Snoutbook-1.0.0-SNAPSHOT/
I have been looking for a solution for over 2 hours and have not been able to find the cause. Did somebody have a similar issue?
EDIT
I tried with the newest Tomcat version apache-tomcat-8.0.12. The problem persists. There is however more info printed in the console while deploying the web app.
12-Sep-2014 17:13:20.038 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployWAR Deploying web application archive D:\Users\b21090094\apac
he-tomcat-8.0.12\webapps\Snoutbook-1.0.0-SNAPSHOT.war
12-Sep-2014 17:13:23.132 INFO [localhost-startStop-1] org.apache.catalina.util.S
essionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for s
ession ID generation using [SHA1PRNG] took [255] milliseconds.
12-Sep-2014 17:13:23.169 INFO [localhost-startStop-1] org.springframework.web.se
rvlet.FrameworkServlet.initServletBean FrameworkServlet 'dispatcher': initializa
tion started
12-Sep-2014 17:13:23.182 INFO [localhost-startStop-1] org.springframework.contex
t.support.AbstractApplicationContext.prepareRefresh Refreshing WebApplicationCon
text for namespace 'dispatcher-servlet': startup date [Fri Sep 12 17:13:23 CEST
2014]; root of context hierarchy
12-Sep-2014 17:13:23.278 INFO [localhost-startStop-1] org.springframework.contex
t.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters
JSR-250 'javax.annotation.ManagedBean' found and supported for component scannin
g
12-Sep-2014 17:13:23.281 INFO [localhost-startStop-1] org.springframework.web.co
ntext.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions Register
ing annotated classes: [class com.zeroturnaround.snoutbook.init.WebappConfigJpa]
12-Sep-2014 17:13:23.429 INFO [localhost-startStop-1] org.springframework.contex
t.annotation.ClassPathScanningCandidateComponentProvider.registerDefaultFilters
JSR-250 'javax.annotation.ManagedBean' found and supported for component scannin
g
12-Sep-2014 17:13:23.921 INFO [localhost-startStop-1] org.springframework.beans.
factory.support.DefaultListableBeanFactory.preInstantiateSingletons Pre-instanti
ating singletons in org.springframework.beans.factory.support.DefaultListableBea
nFactory#7169a1: defining beans [org.springframework.context.annotation.internal
ConfigurationAnnotationProcessor,org.springframework.context.annotation.internal
AutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequ
iredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnn
otationProcessor,org.springframework.context.annotation.internalPersistenceAnnot
ationProcessor,webappConfigJpa,org.springframework.context.annotation.Configurat
ionClassPostProcessor$ImportAwareBeanPostProcessor#0,addPetForm,snoutContoller,s
noutDao,org.springframework.aop.config.internalAutoProxyCreator,delegatingWebMvc
Configuration,requestMappingHandlerMapping,viewControllerHandlerMapping,beanName
HandlerMapping,resourceHandlerMapping,defaultServletHandlerMapping,requestMappin
gHandlerAdapter,mvcConversionService,mvcValidator,httpRequestHandlerAdapter,simp
leControllerHandlerAdapter,handlerExceptionResolver,proxyTransactionManagementCo
nfiguration,org.springframework.transaction.config.internalTransactionAdvisor,tr
ansactionAttributeSource,transactionInterceptor,transactionManager,entityManager
Factory,setupViewResolver,getDataSource]; root of factory hierarchy
12-Sep-2014 17:13:24.225 INFO [localhost-startStop-1] org.springframework.orm.jp
a.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory Buildi
ng JPA container EntityManagerFactory for persistence unit 'default'
12-Sep-2014 17:13:24.657 INFO [localhost-startStop-1] org.hibernate.annotations.
common.Version. HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
12-Sep-2014 17:13:24.676 INFO [localhost-startStop-1] org.hibernate.Version.logV
ersion HHH000412: Hibernate Core {4.1.2}
12-Sep-2014 17:13:24.681 INFO [localhost-startStop-1] org.hibernate.cfg.Environm
ent. HHH000206: hibernate.properties not found
12-Sep-2014 17:13:24.686 INFO [localhost-startStop-1] org.hibernate.cfg.Environm
ent.buildBytecodeProvider HHH000021: Bytecode provider name : javassist
12-Sep-2014 17:13:24.772 INFO [localhost-startStop-1] org.hibernate.ejb.Ejb3Conf
iguration.configure HHH000204: Processing PersistenceUnitInfo [
name: default
...]
12-Sep-2014 17:13:25.524 INFO [localhost-startStop-1] org.hibernate.service.jdbc
.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionP
rovider HHH000130: Instantiating explicit connection provider: org.hibernate.ejb
.connection.InjectedDataSourceConnectionProvider
12-Sep-2014 17:13:26.275 INFO [localhost-startStop-1] org.hibernate.dialect.Dial
ect. HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
12-Sep-2014 17:13:26.356 INFO [localhost-startStop-1] org.hibernate.engine.trans
action.internal.TransactionFactoryInitiator.initiateService HHH000268: Transacti
on strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFacto
ry
12-Sep-2014 17:13:26.374 INFO [localhost-startStop-1] org.hibernate.hql.internal
.ast.ASTQueryTranslatorFactory. HHH000397: Using ASTQueryTranslatorFactory
12-Sep-2014 17:13:26.498 INFO [localhost-startStop-1] . HV0000
01: Hibernate Validator 4.3.0.Final
12-Sep-2014 17:13:27.699 INFO [localhost-startStop-1] org.springframework.web.se
rvlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/addP
et],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto
public java.lang.String com.zeroturnaround.snoutbook.controllers.AddPetForm.setu
pForm(org.springframework.ui.Model)
12-Sep-2014 17:13:27.700 INFO [localhost-startStop-1] org.springframework.web.se
rvlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/addP
et],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto
public java.lang.String com.zeroturnaround.snoutbook.controllers.AddPetForm.han
dleSubmit(com.zeroturnaround.snoutbook.form.PetForm,org.springframework.validati
on.BindingResult,org.springframework.web.bind.support.SessionStatus)
12-Sep-2014 17:13:27.701 INFO [localhost-startStop-1] org.springframework.web.se
rvlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/pet/
{petId}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" ont
o public java.lang.String com.zeroturnaround.snoutbook.controllers.SnoutContolle
r.pet(java.lang.Long,org.springframework.ui.Model)
12-Sep-2014 17:13:27.702 INFO [localhost-startStop-1] org.springframework.web.se
rvlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod Mapped "{[/owne
rs],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto pub
lic java.lang.String com.zeroturnaround.snoutbook.controllers.SnoutContoller.lis
tOwners(org.springframework.ui.Model)
12-Sep-2014 17:13:27.762 INFO [localhost-startStop-1] org.springframework.web.se
rvlet.handler.AbstractUrlHandlerMapping.registerHandler Mapped URL path [/**] on
to handler of type [class org.springframework.web.servlet.resource.DefaultServle
tHttpRequestHandler]
12-Sep-2014 17:13:28.129 INFO [localhost-startStop-1] org.springframework.web.se
rvlet.FrameworkServlet.initServletBean FrameworkServlet 'dispatcher': initializa
tion completed in 4960 ms
12-Sep-2014 17:13:28.140 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployWAR Deployment of web application archive D:\Users\b21090094\
apache-tomcat-8.0.12\webapps\Snoutbook-1.0.0-SNAPSHOT.war has finished in 8,103
ms
12-Sep-2014 17:13:28.141 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090
094\apache-tomcat-8.0.12\webapps\docs
12-Sep-2014 17:13:28.167 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2
1090094\apache-tomcat-8.0.12\webapps\docs has finished in 26 ms
12-Sep-2014 17:13:28.168 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090
094\apache-tomcat-8.0.12\webapps\examples
12-Sep-2014 17:13:28.537 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2
1090094\apache-tomcat-8.0.12\webapps\examples has finished in 370 ms
12-Sep-2014 17:13:28.538 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090
094\apache-tomcat-8.0.12\webapps\host-manager
12-Sep-2014 17:13:28.572 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2
1090094\apache-tomcat-8.0.12\webapps\host-manager has finished in 34 ms
12-Sep-2014 17:13:28.573 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090
094\apache-tomcat-8.0.12\webapps\manager
12-Sep-2014 17:13:28.633 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2
1090094\apache-tomcat-8.0.12\webapps\manager has finished in 61 ms
12-Sep-2014 17:13:28.633 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory D:\Users\b21090
094\apache-tomcat-8.0.12\webapps\ROOT
12-Sep-2014 17:13:28.659 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory D:\Users\b2
1090094\apache-tomcat-8.0.12\webapps\ROOT has finished in 26 ms
12-Sep-2014 17:13:28.663 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler ["http-nio-8080"]
12-Sep-2014 17:13:28.676 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler ["ajp-nio-8009"]
12-Sep-2014 17:13:28.682 INFO [main] org.apache.catalina.startup.Catalina.start
Server startup in 8701 ms
After that I am still getting Error 404.
Try to use http://localhost:8080/Snoutbook-1.0.0-SNAPSHOT/owners
When you upload war file to webapp folder of tomcat, by default tomcat let you access the webapp with the war's name. And then when you look at the web app initializer (the subtitute of web.xml), it's registering the DispatcherServlet with / mapping. Next, you look at the controller, it have #RequestMapping pointed to /owners.
Hence, the path is:
host:port + war-name + servlet-mapping + controller-mapping
equals to
localhost:8080/ + Snoutbook-1.0.0-SNAPSHOT/ + / + owners
equals to
http://localhost:8080/Snoutbook-1.0.0-SNAPSHOT/owners

How to hide INFO messages from LocalServiceTestHelper when running GAE/J test cases?

Before deploying my GAE app, I am running several hundreds of unit tests locally. I am using the LocalServiceTestHelper to use GAE services like memcache or the datastore. Setting up and tearing down the helper between tests creates a lot of log output.
How can I re-configure java.util.logging in order to avoid INFO messages caused by LocalServiceTestHelper entirely?
INFO: Local Datastore initialized:
Type: Master/Slave
Storage: In-memory
Feb 08, 2013 7:01:52 PM com.google.appengine.api.taskqueue.dev.LocalTaskQueue init
INFO: LocalTaskQueue is initialized
Feb 08, 2013 7:01:52 PM com.google.appengine.api.taskqueue.dev.LocalTaskQueue init
INFO: Automatic task execution is disabled.
Feb 08, 2013 7:01:52 PM org.quartz.simpl.SimpleThreadPool initialize
INFO: Job execution threads will use class loader of thread: main
Feb 08, 2013 7:01:52 PM org.quartz.core.QuartzScheduler <init>
INFO: Quartz Scheduler v.null.null.null created.
Feb 08, 2013 7:01:52 PM org.quartz.simpl.RAMJobStore initialize
INFO: RAMJobStore initialized.
Feb 08, 2013 7:01:52 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
Feb 08, 2013 7:01:52 PM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler version: null.null.null
Feb 08, 2013 7:01:52 PM com.google.appengine.api.taskqueue.dev.LocalTaskQueue start_
INFO: Local task queue initialized with base url http://localhost:8080
Feb 08, 2013 7:01:52 PM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutting down.
Feb 08, 2013 7:01:52 PM org.quartz.core.QuartzScheduler standby
INFO: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED paused.
Feb 08, 2013 7:01:52 PM org.quartz.core.QuartzScheduler shutdown
INFO: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutdown complete.
EDIT:
I created the file src/test/resources/logging.properties. The file is copied to target/test-classes/ before the tests are executed. It has the following content:
com.google.appengine.api.taskqueue.dev.level=SEVERE
org.quartz.level=WARNING
But I am still seeing the same log output while running the tests.
While the logging.properties file in src/test/resources/ was well-formed, the maven-surefire-plugin was not aware of its location. As described in another stackoverflow post, you have to set the java.util.logging.config.file system property when configuring the plugin. After applying this simple change everything works as expected.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<systemProperties>
<property>
<name>java.util.logging.config.file</name>
<value>${project.build.directory}/test-classes/logging.properties</value>
</property>
</systemProperties>
...
Get a copy of logging.properties from your appengine-java-sdk/config/user/ folder and put it into your project's classpath, for instance src/test/resources folder if using maven, and start configuring your own settings from here:
# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
#
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:
#
# <system-properties>
# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# </system-properties>
#
# Set the default logging level for all loggers to WARNING
.level = WARNING
To configure log level for a particular package, using:
# Set logging level for particular package
com.google.appengine.api.taskqueue.dev.level = SEVERE
org.quartz.level = WARNING
For a complete configuration guide, check out lib/logging.properties in your JRE installation folder.

Why is my simple springmvc web application shutting down Jetty?

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>

Why embedded OpenEJB fails to deploy my application?

I can't understand why an embedded OpenEJB container fails at the beginning with very un-informative message (sorry for a long log):
Running com.XXX.MyTest
Apache OpenEJB 3.1.3 build: 20101015-05:42
http://openejb.apache.org/
INFO - openejb.home = [skipped...]
INFO - openejb.base = [skipped...]
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Found PersistenceModule in classpath: [skipped...]/target/classes
INFO - Found EjbModule in classpath: [skipped...]/target/test-classes
INFO - Beginning load: [skipped...]/target/classes
INFO - AltDD persistence.xml -> file:[skipped...]/target/classes/META-INF/test.persistence.xml
INFO - AltDD persistence.xml -> file:[skipped...]/target/classes/META-INF/test.persistence.xml
INFO - Beginning load: [skipped...]/target/test-classes
INFO - Configuring enterprise application: classpath.ear
INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean Finder: Container(type=STATELESS, id=Default Stateless Container)
INFO - Configuring PersistenceUnit(name=wid, provider=org.hibernate.ejb.HibernatePersistence)
INFO - Configuring Service(id=Default JDBC Database, type=Resource, provider-id=Default JDBC Database)
INFO - Auto-creating a Resource with id 'Default JDBC Database' of type 'DataSource for 'abc'.
INFO - Configuring Service(id=Default Unmanaged JDBC Database, type=Resource, provider-id=Default Unmanaged JDBC Database)
INFO - Auto-creating a Resource with id 'Default Unmanaged JDBC Database' of type 'DataSource for 'abc'.
INFO - Adjusting PersistenceUnit abc <jta-data-source> to Resource ID 'Default JDBC Database' from 'null'
INFO - Adjusting PersistenceUnit abc <non-jta-data-source> to Resource ID 'Default Unmanaged JDBC Database' from 'null'
INFO - Enterprise application "classpath.ear" loaded.
INFO - Assembling app: classpath.ear
Oct 28, 2010 2:00:20 PM org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.5.6-Final
Oct 28, 2010 2:00:20 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.5.6-Final
Oct 28, 2010 2:00:20 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Oct 28, 2010 2:00:20 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : javassist
Oct 28, 2010 2:00:20 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Oct 28, 2010 2:00:20 PM org.hibernate.annotations.common.Version <clinit>
INFO: Hibernate Commons Annotations 3.2.0.Final
Oct 28, 2010 2:00:20 PM org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.5.6-Final
Oct 28, 2010 2:00:20 PM org.hibernate.ejb.Ejb3Configuration configure
INFO: Processing PersistenceUnitInfo [
name: abc
...]
INFO - PersistenceUnit(name=abc, provider=org.hibernate.ejb.HibernatePersistence) - provider time 328ms
INFO - Undeploying app: classpath.ear
ERROR - Application could not be deployed: classpath.ear
org.apache.openejb.OpenEJBException: Creating application failed: classpath.ear: org.apache.openejb.persistence.PersistenceUnitInfoImpl.getValidationMode()Ljavax/persistence/ValidationMode;
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:679)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:450)
at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:368)
at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:280)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:125)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:60)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:271)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:250)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[skipped...]
Could you please help? Thanks.
That's because you're using JPA 2.0 which is AFAIK not yet supported by OpenEJB, see this thread and OPENEJB-1236. If you look closely at the Jira issue, it looks like this is fixed in the trunk. I just don't if the subtask is blocking or if it would work with a SNAPSHOT version of the trunk.

Categories

Resources