How to inject a #Named bean into a Junit test - java

I'm trying to inject a #Named bean into a Junit test.
This works in my ejb module, but the same approach in my war module fails.
I'd like to know why I get org.apache.openejb.OpenEJBException: Creating application failed: couldn't start owb context.
I know this looks like the same issue as in Issue with EJB 3.1 injected with CDI bean while running JUnit, but it can't be the same as it works in another module.
The source code is here: https://github.com/Crydust/guestbook
Working test: guestbook/guestbook-ejb/src/test/java/be/crydust/guestbook/ejb/PostBoundaryTest.java
Failing test: guestbook/guestbook-web/src/test/java/be/crydust/guestbook/web/PostBackingTest.java
Source of failing test (imports ommitted):
public class PostBackingTest {
private static EJBContainer ejbContainer;
#Inject
PostBacking cut;
#BeforeClass
public static void startTheContainer() {
ejbContainer = EJBContainer.createEJBContainer();
}
#Before
public void setUp() throws Exception {
ejbContainer.getContext().bind("inject", this);
}
#AfterClass
public static void afterClass() {
if (ejbContainer != null) {
ejbContainer.close();
}
}
// FIXME injection fails
#Test
public void testInjected() {
assertThat(cut, is(not(nullValue())));
}
}
Log of failing test:
cd D:\home\kristof\Projects\guestbook\guestbook-web; JAVA_HOME=C:\\opt\\Java\\jdk1.7.0_45 cmd /c "\"\"C:\\opt\\NetBeans 7.4\\java\\maven\\bin\\mvn.bat\" -Dmaven.ext.class.path=\"C:\\opt\\NetBeans 7.4\\java\\maven-nblib\\netbeans-eventspy.jar\" test\""
Scanning for projects...
------------------------------------------------------------------------
Building guestbook-web 1.0-SNAPSHOT
------------------------------------------------------------------------
--- jacoco-maven-plugin:0.6.3.201306030806:prepare-agent (prepare-agent) # guestbook-web ---
surefireArgLine set to -javaagent:D:\home\kristof\.m2\repository\org\jacoco\org.jacoco.agent\0.6.3.201306030806\org.jacoco.agent-0.6.3.201306030806-runtime.jar=destfile=D:\home\kristof\Projects\guestbook\guestbook-web\target\jacoco.exec
--- maven-resources-plugin:2.5:resources (default-resources) # guestbook-web ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 1 resource
--- maven-dependency-plugin:2.8:copy (copy) # guestbook-web ---
Configured Artifact: org.apache.openejb:openejb-javaagent:4.6.0:jar
org.apache.openejb:openejb-javaagent:4.6.0:jar already exists in D:\home\kristof\Projects\guestbook\guestbook-web\target
--- maven-compiler-plugin:3.1:compile (default-compile) # guestbook-web ---
Nothing to compile - all classes are up to date
--- maven-resources-plugin:2.5:testResources (default-testResources) # guestbook-web ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory D:\home\kristof\Projects\guestbook\guestbook-web\src\test\resources
--- maven-compiler-plugin:3.1:testCompile (default-testCompile) # guestbook-web ---
Nothing to compile - all classes are up to date
--- maven-surefire-plugin:2.16:test (default-test) # guestbook-web ---
Surefire report directory: D:\home\kristof\Projects\guestbook\guestbook-web\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
-------------------------------------------------------
T E S T S
-------------------------------------------------------
98 classpath-bootstrap INFO [main] openjpa.Runtime - OpenJPA dynamically loaded a validation provider.
Running be.crydust.guestbook.web.PostBackingTest
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: ********************************************************************************
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: OpenEJB http://openejb.apache.org/
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Startup: Tue Dec 17 12:16:48 CET 2013
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Version: 4.6.0
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Build date: 20131117
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Build time: 06:49
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: ********************************************************************************
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: openejb.home = D:\home\kristof\Projects\guestbook\guestbook-web\target
dec 17, 2013 12:16:48 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: openejb.base = D:\home\kristof\Projects\guestbook\guestbook-web\target
dec 17, 2013 12:16:48 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFO: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl#31185f32
dec 17, 2013 12:16:48 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFO: Succeeded in installing singleton service
dec 17, 2013 12:16:48 PM org.apache.openejb.util.OptionsLog info
INFO: Using 'javax.ejb.embeddable.EJBContainer=true'
dec 17, 2013 12:16:48 PM org.apache.openejb.config.ConfigUtils searchForConfiguration
INFO: Cannot find the configuration file [conf/openejb.xml]. Will attempt to create one for the beans deployed.
dec 17, 2013 12:16:48 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
dec 17, 2013 12:16:48 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
dec 17, 2013 12:16:48 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating TransactionManager(id=Default Transaction Manager)
dec 17, 2013 12:16:48 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating SecurityService(id=Default Security Service)
dec 17, 2013 12:16:48 PM org.apache.openejb.config.DeploymentsResolver processUrls
INFO: Found PersistenceModule in classpath: d:\home\kristof\.m2\repository\be\crydust\guestbook-entities\1.0-snapshot\guestbook-entities-1.0-snapshot.jar
dec 17, 2013 12:16:49 PM org.apache.openejb.config.DeploymentsResolver processUrls
INFO: Found EjbModule in classpath: d:\home\kristof\.m2\repository\be\crydust\guestbook-ejb\1.0-snapshot\guestbook-ejb-1.0-snapshot.jar
dec 17, 2013 12:16:49 PM org.apache.openejb.config.ConfigurationFactory loadApplication
INFO: Beginning load: d:\home\kristof\.m2\repository\be\crydust\guestbook-entities\1.0-snapshot\guestbook-entities-1.0-snapshot.jar
dec 17, 2013 12:16:49 PM org.apache.openejb.config.ConfigurationFactory loadApplication
INFO: Beginning load: d:\home\kristof\.m2\repository\be\crydust\guestbook-ejb\1.0-snapshot\guestbook-ejb-1.0-snapshot.jar
dec 17, 2013 12:16:49 PM org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: D:\home\kristof\Projects\guestbook\guestbook-web\target
dec 17, 2013 12:16:49 PM org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb PostBoundary: EjbDeployment(deployment-id=PostBoundary)
dec 17, 2013 12:16:49 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
dec 17, 2013 12:16:49 PM org.apache.openejb.config.AutoConfig createContainer
INFO: Auto-creating a container for bean guestbook-ejb-1.0-SNAPSHOT.Comp577600423: Container(type=MANAGED, id=Default Managed Container)
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Container(id=Default Managed Container)
dec 17, 2013 12:16:49 PM org.apache.openejb.core.managed.SimplePassivater init
INFO: Using directory C:\Users\kristof\AppData\Local\Temp for stateful session passivation
dec 17, 2013 12:16:49 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
dec 17, 2013 12:16:49 PM org.apache.openejb.config.AutoConfig createContainer
INFO: Auto-creating a container for bean PostBoundary: Container(type=STATELESS, id=Default Stateless Container)
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Container(id=Default Stateless Container)
dec 17, 2013 12:16:49 PM org.apache.openejb.config.AutoConfig deploy
INFO: Configuring PersistenceUnit(name=guestbookPU)
dec 17, 2013 12:16:49 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Default JDBC Database, type=Resource, provider-id=Default JDBC Database)
dec 17, 2013 12:16:49 PM org.apache.openejb.config.AutoConfig logAutoCreateResource
INFO: Auto-creating a Resource with id 'Default JDBC Database' of type 'DataSource for 'guestbookPU'.
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=Default JDBC Database)
dec 17, 2013 12:16:49 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Default Unmanaged JDBC Database, type=Resource, provider-id=Default Unmanaged JDBC Database)
dec 17, 2013 12:16:49 PM org.apache.openejb.config.AutoConfig logAutoCreateResource
INFO: Auto-creating a Resource with id 'Default Unmanaged JDBC Database' of type 'DataSource for 'guestbookPU'.
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=Default Unmanaged JDBC Database)
dec 17, 2013 12:16:49 PM org.apache.openejb.config.AutoConfig setJtaDataSource
INFO: Adjusting PersistenceUnit guestbookPU <jta-data-source> to Resource ID 'Default JDBC Database' from 'null'
dec 17, 2013 12:16:49 PM org.apache.openejb.config.AutoConfig setNonJtaDataSource
INFO: Adjusting PersistenceUnit guestbookPU <non-jta-data-source> to Resource ID 'Default Unmanaged JDBC Database' from 'null'
dec 17, 2013 12:16:49 PM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "D:\home\kristof\Projects\guestbook\guestbook-web\target" loaded.
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: D:\home\kristof\Projects\guestbook\guestbook-web\target
dec 17, 2013 12:16:49 PM null
INFO: OpenJPA dynamically loaded a validation provider.
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory createDelegate
INFO: PersistenceUnit(name=guestbookPU, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 12ms
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.JndiBuilder bindJava
INFO: Jndi(name="java:global/guestbook-ejb-1.0-SNAPSHOT/PostBoundary!be.crydust.guestbook.ejb.PostBoundary")
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.JndiBuilder bindJava
INFO: Jndi(name="java:global/guestbook-ejb-1.0-SNAPSHOT/PostBoundary")
dec 17, 2013 12:16:49 PM org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl#31185f32
dec 17, 2013 12:16:49 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container is starting...
dec 17, 2013 12:16:49 PM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
dec 17, 2013 12:16:49 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
SEVERE: CDI Beans module deployment failed
org.apache.webbeans.exception.inject.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [be.crydust.guestbook.web.PostBacking] is not found with the qualifiers
Qualifiers: [#javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name : cut, Bean Owner : [PostBackingTest, Name:null, WebBeans Type:ENTERPRISE, API Types:[be.crydust.guestbook.web.PostBackingTest,java.lang.Object,java.io.Serializable], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:213)
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:187)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:162)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:43)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:799)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:612)
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:415)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:43)
at be.crydust.guestbook.web.PostBackingTest.startTheContainer(PostBackingTest.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [be.crydust.guestbook.web.PostBacking] is not found with the qualifiers
Qualifiers: [#javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name : cut, Bean Owner : [PostBackingTest, Name:null, WebBeans Type:ENTERPRISE, API Types:[be.crydust.guestbook.web.PostBackingTest,java.lang.Object,java.io.Serializable], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]
at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:60)
at org.apache.webbeans.container.InjectionResolver.checkInjectionPoint(InjectionResolver.java:195)
at org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:954)
at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:470)
at org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:420)
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:200)
... 25 more
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
INFO: Undeploying app: D:\home\kristof\Projects\guestbook\guestbook-web\target
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.Assembler destroyResource
INFO: Closing DataSource: Default JDBC Database
dec 17, 2013 12:16:49 PM org.apache.openejb.assembler.classic.Assembler destroyResource
INFO: Closing DataSource: Default Unmanaged JDBC Database
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.458 sec <<< FAILURE! - in be.crydust.guestbook.web.PostBackingTest
be.crydust.guestbook.web.PostBackingTest Time elapsed: 1.458 sec <<< ERROR!
org.apache.openejb.OpenEjbContainer$AssembleApplicationException: org.apache.openejb.OpenEJBException: Creating application failed: D:\home\kristof\Projects\guestbook\guestbook-web\target: couldn't start owb context
at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:60)
at org.apache.webbeans.container.InjectionResolver.checkInjectionPoint(InjectionResolver.java:195)
at org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:954)
at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:470)
at org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:420)
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:200)
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:187)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:162)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:43)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:799)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:612)
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:415)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:43)
at be.crydust.guestbook.web.PostBackingTest.startTheContainer(PostBackingTest.java:31)
Results :
Tests in error:
PostBackingTest.startTheContainer:31 » AssembleApplication org.apache.openejb....
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 4.595s
Finished at: Tue Dec 17 12:16:49 CET 2013
Final Memory: 17M/224M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project guestbook-web: There are test failures.
Please refer to D:\home\kristof\Projects\guestbook\guestbook-web\target\surefire-reports for the individual test results.
-> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

I use the needle framework for these kind of tests. It automatically injects mocks that you can configure the usual way, but also can be used to inject real instances if needed (for collaboration/integration testing).
You can find it here: http://needle.spree.de/

I believe OpenEJB expects the beans.xml in META-INF folder, although the war should have it it in the WEB-INF folder. Can you verify this by creating a empty beans.xml in test/resources/META-INF folder?

Related

Tomcat7 doesn't initialize my spring configuration

I have a simple maven spring project, when I run the project on the tomcat server, I don't see tomcat load the configuration on the start up.
MySpringMvcDispatcherServletInitializer.java
package com.abc.xyz.config;
import
org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
public class MySpringMvcDispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
#Override
protected Class<?>[] getRootConfigClasses() {
// TODO Auto-generated method stub
return null;
}
#Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { DemoAppConfig.class };
}
#Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
DemoAppConfig.java
package com.abc.xyz.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
#Configuration
#EnableWebMvc
#ComponentScan("com.abc.xyz")
public class DemoAppConfig implements WebMvcConfigurer {
}
DemoRestController.java
package com.abc.xyz.rest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
#RequestMapping("/test")
public class DemoRestController {
// add code for the "/hello" endpoint
#GetMapping("/hello")
public String sayHello() {
return "Hello World!";
}
}
tomcat7 startup log
Oct 24, 2018 4:15:45 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:spring-rest-demo' did not find a matching property.
Oct 24, 2018 4:15:45 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SIT_Dashboard' did not find a matching property.
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Sep 29 2017 12:23:15 UTC
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 7.0.82.0
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 7
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.1
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\FAST\JDK64\LINKS\JDK8\jre
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_144-b01
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\wtpwebapps
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\endorsed
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Oct 24, 2018 4:15:45 PM 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:\FAST\JDK64\LINKS\JDK8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\FAST\JDK64\1.8.0.144\bin;C:\ProgramData\Oracle\Java\javapath;C:\oracle\product\11.2.0\client_64\BIN\;C:\Program Files\Micro Focus\Reflection\;C:\Program Files (x86)\Micro Focus\Reflection\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\1E\SMSNomad\;C:\Program Files\aim\aim-install\bin\;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Git\cmd;C:\FAST\nodejs\6.11.4\;C:\Program Files\TortoiseSVN\bin;C:\opt\gate\base91\..\perl\bin;C:\Users\R633368\AppData\Roaming\npm;C:\FAST\maven\3.5.0\apache-maven-3.5.0\bin;.
Oct 24, 2018 4:15:45 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Oct 24, 2018 4:15:45 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Oct 24, 2018 4:15:45 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 768 ms
Oct 24, 2018 4:15:45 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 24, 2018 4:15:45 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.82
Oct 24, 2018 4:15:46 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [472] milliseconds.
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\docs
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\docs has finished in 101 ms
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\examples
Oct 24, 2018 4:15:47 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Oct 24, 2018 4:15:47 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Oct 24, 2018 4:15:47 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache#6d4352bf')
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\examples has finished in 499 ms
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\host-manager
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\host-manager has finished in 157 ms
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\manager
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\manager has finished in 82 ms
Oct 24, 2018 4:15:47 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\ROOT
Oct 24, 2018 4:15:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory C:\FAST\ApacheTomcat\7.0.82\apache-tomcat-7.0.82\webapps\ROOT has finished in 77 ms
Oct 24, 2018 4:15:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Oct 24, 2018 4:15:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 24, 2018 4:15:48 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2191 ms
As you can see, the start up doesn't show it read my spring configuration, please help, thanks in advance
tomcat web application manager
Updated: I have a temp fix, (wow,it takes me 2 days to make some progress since there is no ERRORs  at all in the project).
Here is the trick: Right click project => properties=> Deployment
Assembly=> add=> choose Java Build Path Entries=>choose Maven
Dependencies=> apply=> OK
You can see server log refresh and it finally loads spring
configuration, and if you check
tomcat home directory/wtpwebapps/{project name}/WEB-INF/lib, you can
see all the maven dependencies are copied to here
Up to this point, It looks like everything is fine now, but I find the
other issue, every time I right click=>maven=> update project...=> it
will try to remove the dependencies(jars) in tomcat home
directory/wtpwebapps/{project name}/WEB-INF/lib,
If your project is running at the tomcat , you will get a error
because these jars are being used.
But if you stop server, and update project and then run as server
again, everything is back to normal, no error, no spring configuration
in the server startup log, then you have to do the same trick again.
I tried so many online solutions about "maven project update will
remove jars in tomcat server", none of them are working. So if anyone
has the the fix, please shared

Build failure while pushing changes to openshift server

I'm trying to push my project to openshift server, it end up with this error while doing maven build on the server:
[INFO] Packaging webapp
[INFO] Assembling webapp [sani3ee] in [/var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/repo/target/sani3ee]
[INFO] Processing war project
[INFO] Copying webapp resources [/var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/repo/src/main/webapp]
[INFO] Webapp assembled in [112 msecs]
[INFO] Building war: /var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/repo/webapps/ROOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31.677s
[INFO] Finished at: Sat Mar 07 14:01:05 EST 2015
[INFO] Final Memory: 9M/139M
[INFO] ------------------------------------------------------------------------
Preparing build for deployment
Deployment id is c2062771
Activating deployment
Starting PHPMyAdmin cartridge
Starting MySQL 5.5 cartridge
Stopping jbossews cartridge
Sending SIGTERM to jboss:514412 ...
Stopping PHPMyAdmin cartridge
Waiting for stop to finish
Waiting for stop to finish
Stopping MySQL 5.5 cartridge
Repairing links for 1 deployments
Building git ref 'master', commit 0d1853f
Using Maven mirror /var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml
Apache Maven 3.0.4 (r1232336; 2012-12-18 14:36:37-0500)
Maven home: /usr/share/java/apache-maven-3.0.4
Java version: 1.7.0_75, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "2.6.32-504.3.3.el6.x86_64", arch: "i386", family: "unix"
Found pom.xml... attempting to build with 'mvn --global-settings /var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml clean package -Popenshift -DskipTests'
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Sani3ee 1.0.0-BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # sani3ee ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # sani3ee ---
[debug] execute contextualize
[WARNING] Using platform encoding (ANSI_X3.4-1968 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # sani3ee ---
[WARNING] File encoding has not been set, using platform encoding ANSI_X3.4-1968, i.e. build is platform dependent!
[INFO] Compiling 58 source files to /var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/repo/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] bootstrap class path not set in conjunction with -source 1.6
/var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/repo/src/main/java/com/itworx/sani3ee/dao/favorite/FavoriteDaoImpl.java:[84,51] error: diamond operator is not supported in -source 1.6
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.823s
[INFO] Finished at: Sat Mar 07 14:35:34 EST 2015
[INFO] Final Memory: 8M/113M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "openshift" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project sani3ee: Compilation failure
[ERROR] bootstrap class path not set in conjunction with -source 1.6
[ERROR] /var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/repo/src/main/java/com/itworx/sani3ee/dao/favorite/FavoriteDaoImpl.java:[84,51] error: diamond operator is not supported in -source 1.6
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
An error occurred executing 'gear postreceive' (exit code: 1)
Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/54f479214382ec83330000bd/jbossews
For more details about the problem, try running the command again with the '--trace' option.
I have no idea what's the problem here, I've been trying to fix this for a while now, it build fine on my local machine, also openshift recognized that it should be built using JDK 7, thanks in advance everyone :)
Edit: Here is the tomcat log, it shows that the application is deployed correctly I guess.
Mar 08, 2015 11:01:07 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-127.7.36.1-8080"]
Mar 08, 2015 11:01:07 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-127.7.36.1-8080"]
Mar 08, 2015 11:02:29 AM org.apache.catalina.startup.Catalina addClusterRuleSet
INFO: Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.apache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
Mar 08, 2015 11:02:29 AM org.apache.catalina.startup.Catalina addClusterRuleSet
INFO: Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.apache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
Mar 08, 2015 11:02:30 AM 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: /opt/rh/mysql55/root/usr/lib64:/usr/java/packages/lib/i386:/lib:/usr/lib
Mar 08, 2015 11:02:31 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-127.7.36.1-8080"]
Mar 08, 2015 11:02:31 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1867 ms
Mar 08, 2015 11:02:31 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 08, 2015 11:02:31 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Mar 08, 2015 11:02:31 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/dependencies/jbossews/webapps/ROOT.war
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Sun Mar 08 11:02:50 EDT 2015]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/config/BeanLocations.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/database/DataSource.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/database/Hibernate.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/database/hibernate.cfg.xml]
INFO : org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from ServletContext resource [/WEB-INF/properties/database.properties]
WARN : org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.itworx.sani3ee.model.Favorite
WARN : org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.itworx.sani3ee.model.Favorite
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 24507 ms
Mar 08, 2015 11:03:14 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Mar 08, 2015 11:03:14 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.XmlWebApplicationContext).
log4j:WARN Please initialize the log4j system properly.
Mar 08, 2015 11:03:14 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Mar 08, 2015 11:03:14 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
Mar 08, 2015 11:03:14 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [Resource Destroyer in BasicResourcePool.close()] but has failed to stop it. This is very likely to create a memory leak.
Mar 08, 2015 11:03:14 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/dependencies/jbossews/webapps/ROOT.war has finished in 43,453 ms
Mar 08, 2015 11:03:14 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.7.36.1-8080"]
Mar 08, 2015 11:03:14 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 43689 ms
Mar 09, 2015 12:03:22 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-127.7.36.1-8080"]
Mar 09, 2015 12:03:22 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Mar 09, 2015 12:03:22 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-127.7.36.1-8080"]
Mar 09, 2015 12:03:22 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-127.7.36.1-8080"]
Mar 14, 2015 4:41:16 PM org.apache.catalina.startup.Catalina addClusterRuleSet
INFO: Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.apache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
Mar 14, 2015 4:41:16 PM org.apache.catalina.startup.Catalina addClusterRuleSet
INFO: Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.apache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
Mar 14, 2015 4:41:17 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: /opt/rh/mysql55/root/usr/lib64:/usr/java/packages/lib/i386:/lib:/usr/lib
Mar 14, 2015 4:41:18 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-127.7.36.1-8080"]
Mar 14, 2015 4:41:18 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2071 ms
Mar 14, 2015 4:41:18 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 14, 2015 4:41:18 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Mar 14, 2015 4:41:18 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/dependencies/jbossews/webapps/ROOT.war
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Sat Mar 14 16:41:38 EDT 2015]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/config/BeanLocations.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/database/DataSource.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/database/Hibernate.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/database/hibernate.cfg.xml]
INFO : org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from ServletContext resource [/WEB-INF/properties/database.properties]
WARN : org.hibernate.mapping.RootClass - HHH000038: Composite-id class does not override equals(): com.itworx.sani3ee.model.Favorite
WARN : org.hibernate.mapping.RootClass - HHH000039: Composite-id class does not override hashCode(): com.itworx.sani3ee.model.Favorite
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 6553 ms
Mar 14, 2015 4:41:45 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Mar 14, 2015 4:41:45 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.XmlWebApplicationContext).
log4j:WARN Please initialize the log4j system properly.
Mar 14, 2015 4:41:45 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Mar 14, 2015 4:41:45 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
Mar 14, 2015 4:41:45 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [Resource Destroyer in BasicResourcePool.close()] but has failed to stop it. This is very likely to create a memory leak.
Mar 14, 2015 4:41:45 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/54f479214382ec83330000bd/app-root/runtime/dependencies/jbossews/webapps/ROOT.war has finished in 26,168 ms
Mar 14, 2015 4:41:45 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.7.36.1-8080"]
Mar 14, 2015 4:41:45 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 26418 ms
Looks like you are probably missing the "openshift" profile in your pom.xml file. You can see an example of it here:
https://github.com/openshift/origin-server/blob/master/cartridges/openshift-origin-cartridge-jbossas/versions/7/template/pom.xml
You need to have that in your pom.xml if you are deploying from source with a git push, or openshift won't know how to deploy the .war file that it builds.
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app will need. -->
<!-- By default that is to put the resulting archive into the 'deployments' folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<finalName>{APP_NAME}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Pass custom class instance to JAX-WS service method

I've been having a lot of trouble trying to pass a custom object into a JAX-WS service method. Nothing I do seems to work.
How do I get an instance of this trivial class
public class User
{
// Private instance variables
public String firstname;
public String lastname;
public User() {}
// // Constructor for a new user doesn't have an ID parameter
public User (String firstname, String lastname) {
this.firstname = firstname;
this.lastname = lastname;
}
// Get & Set Methods
/* Returns the user's last name */
public String getLastName() {
return lastname;
}
/* Sets the user's last name */
public void setLastName(String newLastName) {
lastname = newLastName;
}
/* Returns the user's first name */
public String getFirstName() {
return firstname;
}
/* Sets the user's first name */
public void setFirstName(String newfirstname) {
firstname = newfirstname;
}
}
To be passed into a web service method, like so:
#WebService(serviceName = "UserService",
endpointInterface = "IUserService",
targetNamespace = "http://bioflip.org")
public class UserService implements IUserService
{
#Override
public String getUserName(User user)
{
return user.getFirstName() + " " + user.getLastName();
}
}
Here is the service interface:
#WebService(targetNamespace = "http://bioflip.org")
public interface IUserService
{
#WebMethod
String getUserName(User user);
}
My service doesn't deploy on Tomcat EE 7. What is wrong? Also, any good tutorials on a topic (that is NOT a hello world tutorial, which seem to be everywhere and are super useless) would be highly appreciated.
The error part of the stack trace:
Sep 11, 2014 5:16:18 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: /Users/Dmitry/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Sep 11, 2014 5:16:18 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:BioFlipServiceTest' did not find a matching property.
Sep 11, 2014 5:16:18 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Sep 11, 2014 5:16:18 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Sep 11, 2014 5:16:19 PM org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: ********************************************************************************
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: OpenEJB http://openejb.apache.org/
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Startup: Thu Sep 11 17:16:19 EDT 2014
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Version: 4.7.0
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Build date: 20140810
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: Build time: 12:40
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: ********************************************************************************
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: openejb.home = /Users/Dmitry/apache-tomee-plus-1.7.0
Sep 11, 2014 5:16:19 PM org.apache.openejb.OpenEJB$Instance <init>
INFO: openejb.base = /Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1
Sep 11, 2014 5:16:19 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFO: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl#1a9a098e
Sep 11, 2014 5:16:19 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
INFO: Succeeded in installing singleton service
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.ConfigurationFactory init
INFO: openejb configuration file is '/Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/conf/openejb.xml'
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My DataSource, type=Resource, provider-id=Default JDBC Database)
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My Unmanaged DataSource, type=Resource, provider-id=Default JDBC Database)
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My Singleton Container, type=Container, provider-id=Default Singleton Container)
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My Stateful Container, type=Container, provider-id=Default Stateful Container)
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My Stateless Container, type=Container, provider-id=Default Stateless Container)
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.DeploymentsResolver loadFrom
WARNING: File error: <Deployments dir="apps/"> - Does not exist: /Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/apps
Sep 11, 2014 5:16:19 PM org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.system.apps=true'
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: openejb
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.InitEjbDeployments deploy
INFO: Using openejb.deploymentId.format '{ejbName}'
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb openejb/Deployer: EjbDeployment(deployment-id=openejb/Deployer)
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb openejb/ConfigurationInfo: EjbDeployment(deployment-id=openejb/ConfigurationInfo)
Sep 11, 2014 5:16:19 PM org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb MEJB: EjbDeployment(deployment-id=MEJB)
Sep 11, 2014 5:16:20 PM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "openejb" loaded.
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating TransactionManager(id=Default Transaction Manager)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating SecurityService(id=Tomcat Security Service)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=My DataSource)
Sep 11, 2014 5:16:20 PM org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource readOnly
INFO: Disabling testOnBorrow since no validation query is provided
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=My Unmanaged DataSource)
Sep 11, 2014 5:16:20 PM org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource readOnly
INFO: Disabling testOnBorrow since no validation query is provided
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Container(id=My Singleton Container)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Container(id=My Stateful Container)
Sep 11, 2014 5:16:20 PM org.apache.openejb.core.stateful.SimplePassivater init
INFO: Using directory /var/folders/l4/p46wd9cx2yd85xyq1jrm2k840000gn/T for stateful session passivation
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Container(id=My Stateless Container)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: openejb
Sep 11, 2014 5:16:20 PM org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.jndiname.format={deploymentId}{interfaceType.openejbLegacyName}'
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=openejb/DeployerBusinessRemote) --> Ejb(deployment-id=openejb/Deployer)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/Deployer!org.apache.openejb.assembler.Deployer) --> Ejb(deployment-id=openejb/Deployer)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/Deployer) --> Ejb(deployment-id=openejb/Deployer)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=openejb/ConfigurationInfoBusinessRemote) --> Ejb(deployment-id=openejb/ConfigurationInfo)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/ConfigurationInfo!org.apache.openejb.assembler.classic.cmd.ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=MEJB) --> Ejb(deployment-id=MEJB)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/MEJB!javax.management.j2ee.ManagementHome) --> Ejb(deployment-id=MEJB)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/MEJB) --> Ejb(deployment-id=MEJB)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Created Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=My Stateless Container)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Created Ejb(deployment-id=MEJB, ejb-name=MEJB, container=My Stateless Container)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Created Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=My Stateless Container)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Started Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=My Stateless Container)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Started Ejb(deployment-id=MEJB, ejb-name=MEJB, container=My Stateless Container)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler startEjbs
INFO: Started Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=My Stateless Container)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler deployMBean
INFO: Deployed MBean(openejb.user.mbeans:application=openejb,group=org.apache.openejb.assembler.monitoring,name=JMXDeployer)
Sep 11, 2014 5:16:20 PM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=openejb)
Sep 11, 2014 5:16:20 PM org.apache.openejb.server.ServiceManager initServer
INFO: Creating ServerService(id=cxf)
Sep 11, 2014 5:16:21 PM org.apache.openejb.server.ServiceManager initServer
INFO: Creating ServerService(id=cxf-rs)
Sep 11, 2014 5:16:21 PM org.apache.openejb.server.SimpleServiceManager start
INFO: ** Bound Services **
Sep 11, 2014 5:16:21 PM org.apache.openejb.server.SimpleServiceManager printRow
INFO: NAME IP PORT
Sep 11, 2014 5:16:21 PM org.apache.openejb.server.SimpleServiceManager start
INFO: -------
Sep 11, 2014 5:16:21 PM org.apache.openejb.server.SimpleServiceManager start
INFO: Ready!
Sep 11, 2014 5:16:21 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2932 ms
Sep 11, 2014 5:16:21 PM org.apache.tomee.catalina.OpenEJBNamingContextListener bindResource
INFO: Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
Sep 11, 2014 5:16:21 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=UserDatabase)
Sep 11, 2014 5:16:21 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 11, 2014 5:16:21 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.55 (1.7.0)
Sep 11, 2014 5:16:21 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: ------------------------- localhost -> /
Sep 11, 2014 5:16:21 PM org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: /Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ROOT
Sep 11, 2014 5:16:21 PM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "/Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ROOT" loaded.
Sep 11, 2014 5:16:21 PM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: /Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ROOT
Sep 11, 2014 5:16:21 PM org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl#1a9a098e
Sep 11, 2014 5:16:21 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container is starting...
Sep 11, 2014 5:16:21 PM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
Sep 11, 2014 5:16:21 PM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
Sep 11, 2014 5:16:21 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
INFO: All injection points were validated successfully.
Sep 11, 2014 5:16:21 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container has started, it took 81 ms.
Sep 11, 2014 5:16:21 PM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=/Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/ROOT)
Sep 11, 2014 5:16:21 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: ------------------------- localhost -> /BioFlipServiceTest
Sep 11, 2014 5:16:21 PM org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: /Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/BioFlipServiceTest
Sep 11, 2014 5:16:21 PM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "/Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/BioFlipServiceTest" loaded.
Sep 11, 2014 5:16:21 PM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: /Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/BioFlipServiceTest
Sep 11, 2014 5:16:21 PM org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl#1a9a098e
Sep 11, 2014 5:16:21 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container is starting...
Sep 11, 2014 5:16:21 PM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
Sep 11, 2014 5:16:21 PM org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
Sep 11, 2014 5:16:21 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
INFO: All injection points were validated successfully.
Sep 11, 2014 5:16:21 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container has started, it took 8 ms.
Sep 11, 2014 5:16:21 PM org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=/Users/Dmitry/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/BioFlipServiceTest)
Sep 11, 2014 5:16:21 PM org.apache.openejb.server.webservices.WsService afterApplicationCreated
SEVERE: Error deploying CXF webservice for servlet UserService
java.lang.NullPointerException
at org.apache.cxf.jaxb.Utils.getMethodXJTA(Utils.java:294)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:375)
at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:329)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:232)
at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:222)
at org.apache.cxf.jaxb.JAXBContextInitializer.walkReferences(JAXBContextInitializer.java:365)
at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:329)
at org.apache.cxf.jaxb.JAXBContextInitializer.begin(JAXBContextInitializer.java:183)
at org.apache.cxf.service.ServiceModelVisitor.visitOperation(ServiceModelVisitor.java:97)
at org.apache.cxf.service.ServiceModelVisitor.walk(ServiceModelVisitor.java:74)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:325)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:490)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:697)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:550)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:214)
at org.apache.openejb.server.cxf.CxfEndpoint.doServiceCreate(CxfEndpoint.java:101)
at org.apache.openejb.server.cxf.pojo.PojoEndpoint.<init>(PojoEndpoint.java:89)
at org.apache.openejb.server.cxf.pojo.PojoWsContainer.createEndpoint(PojoWsContainer.java:70)
at org.apache.openejb.server.cxf.pojo.PojoWsContainer.createEndpoint(PojoWsContainer.java:45)
at org.apache.openejb.server.cxf.CxfWsContainer.start(CxfWsContainer.java:50)
at org.apache.openejb.server.cxf.CxfService.createPojoWsContainer(CxfService.java:102)
at org.apache.openejb.server.webservices.WsService.afterApplicationCreated(WsService.java:393)
at org.apache.tomee.webservices.TomeeJaxWsService.afterApplicationCreated(TomeeJaxWsService.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.openejb.observer.ObserverManager$MethodInvocation.invoke(ObserverManager.java:399)
at org.apache.openejb.observer.ObserverManager$InvocationList.invoke(ObserverManager.java:514)
at org.apache.openejb.observer.ObserverManager.doFire(ObserverManager.java:110)
at org.apache.openejb.observer.ObserverManager.fireEvent(ObserverManager.java:99)
at org.apache.openejb.loader.SystemInstance.fireEvent(SystemInstance.java:134)
at org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(TomcatWebAppBuilder.java:1651)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:116)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:168)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Sep 11, 2014 5:16:21 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 11, 2014 5:16:22 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 11, 2014 5:16:22 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 952 ms

Not able to run spring web socket demo

I am trying to run a demo of spring web socket but not able to test it completely. I am using java 7 and tomcat 7.0.50. I don't get any error while server startup, but when I open the web page with js making the connection to it I got 404 page not found. I am not sure if I am missing anything in configuration to make it run and how can I be able to connect it from js side.
I have following xml file:
<beans ....>
<context:annotation-config />
<websocket:message-broker
application-destination-prefix="/app">
<websocket:stomp-endpoint path="/hello">
<websocket:sockjs />
</websocket:stomp-endpoint>
<websocket:simple-broker prefix="/topic" />
</websocket:message-broker>
</beans>
My controller class is:
#Controller
public class SwsService {
#MessageMapping("/hello")
#SendTo("/topic/greetings")
public Greeting greeting(HelloMessage message) throws Exception {
return new Greeting("Hello, " + message.getName() + "!");
}
public String getGreeting() {
return "Hello, you are in!";
}
}
The js from which I am calling this is:
var sock = new SockJS("/hello");
sock.onopen = function () {
console.log("open");
};
sock.onclose = function () {
console.log("closed");
};
sock.onmessage = function (message) {
console.log("msg", message);
};
The console output when I run the tomcat:
Feb 19, 2014 3:28:47 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\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\TortoiseGit\bin;C:\Python24;C:\Program Files\TortoiseSVN\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\harsh\AppData\Roaming\npm;E:\IDE\eclipse_indigo;;.
Feb 19, 2014 3:28:47 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SWS' did not find a matching property.
Feb 19, 2014 3:28:48 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Feb 19, 2014 3:28:48 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Feb 19, 2014 3:28:48 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1412 ms
Feb 19, 2014 3:28:48 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Feb 19, 2014 3:28:48 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.50
Feb 19, 2014 3:28:51 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Feb 19, 2014 3:28:51 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Feb 19, 2014 3:28:51 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Feb 19, 2014 3:28:51 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Wed Feb 19 15:28:51 IST 2014]; root of context hierarchy
Feb 19, 2014 3:28:52 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/conf/SwsContext.xml]
Feb 19, 2014 3:28:53 PM org.springframework.scheduling.concurrent.ExecutorConfigurationSupport initialize
INFO: Initializing ExecutorService 'clientInboundChannelExecutor'
Feb 19, 2014 3:28:53 PM org.springframework.scheduling.concurrent.ExecutorConfigurationSupport initialize
INFO: Initializing ExecutorService 'clientOutboundChannelExecutor'
Feb 19, 2014 3:28:53 PM org.springframework.scheduling.concurrent.ExecutorConfigurationSupport initialize
INFO: Initializing ExecutorService 'messageBrokerSockJsScheduler'
Feb 19, 2014 3:28:53 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello/**] onto handler of type [class org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler]
Feb 19, 2014 3:28:53 PM org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup start
INFO: Starting beans in phase 2147483647
Feb 19, 2014 3:28:53 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 2173 ms
Feb 19, 2014 3:28:53 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Feb 19, 2014 3:28:53 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Feb 19, 2014 3:28:53 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5842 ms
The browser console output:
GET http://localhost:8080/hello/info 404 (Not Found) sockjs-0.3.min.js:27
closed
How can I successfully test it?
Updates
I also tried running the portfolio example from here: https://github.com/rstoyanchev/spring-websocket-portfolio as suggested by #jhadesdev
But it also doesn't help. When I run mvn tomcat7:run, I see following output and open url on browser tells 404.
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethrea
ded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building spring-websocket-portfolio 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) # spring-websocket-portfol
io >>>
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # spring-web
socket-portfolio ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\libraries\spring-websocket-portfol
io\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # spring-websoc
ket-portfolio ---
[INFO] No sources to compile
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) # spring-websocket-portfol
io <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) # spring-websocket-portfol
io ---
[INFO] Running war on http://localhost:8080/spring-websocket-portfolio
[INFO] Using existing Tomcat server configuration at E:\libraries\spring-websock
et-portfolio\target\tomcat
[INFO] create webapp with contextPath: /spring-websocket-portfolio
Feb 27, 2014 10:20:46 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Feb 27, 2014 10:20:46 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Feb 27, 2014 10:20:46 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Feb 27, 2014 10:20:49 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Feb 27, 2014 10:20:49 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
It stuck there and doesn't go ahead.
I was facing the same problem. This thread gave me enough clues to solve the problem. Thanks a lot.
SOLUTION:
In case you have a Spring MVC Dispatcher Servlet configured in your web.xml and mapped to a url-pattern as shown below
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/webui/*</url-pattern>
</servlet-mapping>
Then you have to create the SockJS instance as shown below
var socket = new SockJS('/contextPath/webui/hello');
NOTE: Replace contextPath with your application context path.
This Chrome extension can help you test Websockets.
Also you can have a look at my simple-chat project that uses Spring Boot with Websockets.
Try adding an assets folder inside webapp, where all the stomp and sockjs.js files are made available. Have a look at this example of a running application, that can be run with mvn clean install jetty:run.
The problem seems to be that either the sockjs is not on the server or some path is wrong. Based on the example on the link, a stomp endpoint can be configured like this:
#EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/portfolio").withSockJS();
}
}
Then in javascript the end point can be called like this:
var socket = new SockJS('/spring-websocket-portfolio/portfolio')
var stompClient = Stomp.over(socket);
where /spring-websocket-portfolio is the root deployment path of your application.
Your application looks fine.
You should definitely prefix JavaScript requests with the root context of your application, as jhadesdev mentioned.
Does your application registers additional filters or customize messageconverters? Maybe some other element of configuration is interfering here.
The latest portfolio example should definitely work, here are some questions:
Could you tell us more about your client setup (browser, version)?
Does your browser support websocket (test it there)?
Could you also try in incognito mode (maybe a 3rd party browser extension is at fault here)?
Could you check that your browser is not using a HTTP proxy for localhost requests?
Could you check if this HTTP 404 is in Tomcat access log? (and see if you've got something interesting in those or in catalina.out?)
How is your DispatcherServlet mapped? Here might be what you're looking for
I solved this problem in thats way:
when you create the SockJS add localhost:8080/
like this
new SockJS('http://localhost:8080/spring-websocket-portfolio/portfolio')
For me the solution was to enable SockJS in by WebSocketConfig class:
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/search")
.setAllowedOrigins("*")
.setHandshakeHandler(new DefaultHandshakeHandler())
.withSockJS();
}

mvn tomcat:run terminates

When I call 'mvn tomcat:run' from my project, it starts up, then closes down immediately after a successful startup:
2011-01-18 13:02:10,636 INFO [org.springframework.web.servlet.DispatcherServlet] - FrameworkServlet 'myProject': initialization completed in 2010 ms
Jan 18, 2011 1:02:10 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 18, 2011 1:02:10 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 minutes 26 seconds
[INFO] Finished at: Tue Jan 18 13:02:10 CET 2011
[INFO] Final Memory: 146M/274M
[INFO] ------------------------------------------------------------------------
2011-01-18 13:02:11,645 INFO [org.springframework.web.context.support.XmlWebApplicationContext] - Closing WebApplicationContext for namespace 'myProjectWS-servlet': startup date [Tue Jan 18 13:02:06 CET 2011]; parent: Root WebApplicationContext
Even running tomcat:run-war-only gives the same:
[INFO] Running war on http://localhost:8080/myProject
[INFO] Creating Tomcat server configuration at /Users/niklas/Documents/Eclipse/myProject/target/tomcat
Jan 18, 2011 1:19:21 PM org.apache.catalina.startup.Embedded start
INFO: Starting tomcat server
Jan 18, 2011 1:19:21 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
Jan 18, 2011 1:19:22 PM org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'myProject-SNAPSHOT' = [/Users/niklas/Documents/Eclipse/myProject/target/myProject-4.1.0-SNAPSHOT/]
Jan 18, 2011 1:19:22 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [/Users/niklas/Documents/Eclipse/myProject/target/myProject-4.1.0-SNAPSHOT/WEB-INF/classes/log4j.properties]
Jan 18, 2011 1:19:22 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jan 18, 2011 1:22:05 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'myProjectWS'
Jan 18, 2011 1:22:06 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'myProject'
Jan 18, 2011 1:22:08 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 18, 2011 1:22:08 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 minutes 56 seconds
[INFO] Finished at: Tue Jan 18 13:22:08 CET 2011
[INFO] Final Memory: 120M/226M
[INFO] ------------------------------------------------------------------------
Jan 18, 2011 1:22:09 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
Any idea what could cause it to shut down right away? No System.exit's anywhere in the code
Cheers
Nik
One possible reason is if fork parameter is set to true.

Categories