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();
}
Related
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>
While executing my simple hello world program I am getting a the Tomcat Server error as
“Starting Tomcat Server v7.0 at localhost (2) has encountered a problem”
I am using jdk7 nd spring 3.1.0 and I have not yet introduced hibernate or maven. Can Anyone help me fix the error. The Console output is as follows:
Aug 21, 2014 10:15:31 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: C:\Program Files (x86)\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre8/bin/client;C:/Program Files (x86)/Java/jre8/bin;C:/Program Files (x86)/Java/jre8/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\VisualSVN\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Java\jre8\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\VisualSVN\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\MySQL\MySQL Server 5.0\bin\;C:\Program Files (x86)\Java\jre8;C:\Program Files (x86)\Java\jre8\lib;D:\Program Files\apache-ant-1.9.4\bin;C:\Program Files (x86)\Java\jre8\bin;D:\Softwares\Eclipse Dump\EclipseForSpring;;.
Aug 21, 2014 10:15:31 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HelloWorld' did not find a matching property.
Aug 21, 2014 10:15:31 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Aug 21, 2014 10:15:31 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Aug 21, 2014 10:15:31 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1082 ms
Aug 21, 2014 10:15:31 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Aug 21, 2014 10:15:31 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.55
Aug 21, 2014 10:15:32 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [203] milliseconds.
Aug 21, 2014 10:15:34 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Aug 21, 2014 10:15:34 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'HelloWorld'
Aug 21, 2014 10:15:34 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'HelloWorld': initialization started
Aug 21, 2014 10:15:34 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'HelloWorld-servlet': startup date [Thu Aug 21 10:15:34 IST 2014]; root of context hierarchy
Aug 21, 2014 10:15:34 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/HelloWorld-servlet.xml]
Aug 21, 2014 10:15:35 AM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
Aug 21, 2014 10:15:35 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#4258426: defining beans [helloWorldController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
Aug 21, 2014 10:15:35 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello] onto handler 'helloWorldController'
Aug 21, 2014 10:15:35 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello.*] onto handler 'helloWorldController'
Aug 21, 2014 10:15:35 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello/] onto handler 'helloWorldController'
Aug 21, 2014 10:15:35 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'HelloWorld': initialization completed in 936 ms
Aug 21, 2014 10:15:35 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Aug 21, 2014 10:15:35 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Aug 21, 2014 10:15:35 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4138 ms
Its seems this problem doesn't have anything to do with spring, hibernate or maven. As it is saying
its expecting an native library which it cant find. You can find that native library in Tomcat Native
and store it in position as tomcat expect it
This Thread discuss the same problem as yours.
As you are using windows i recommend you to use tomcat installer to avoid unnecessary problems.
The message you are getting is normal. You can ignore it as i think its not creating any issue
But still you want or solve this you need to compile the source package that comes as Tomcat Native
Which i haven't tried yet. It is said in tomcat site Use MS Visual Studio to open the workspace of the APR sources and build the library (libapr). and further instruction also given.
You can change the eclipse tomcat server configuration. Open the server view, double click on you server to open server configuration. Then click to activate "Publish module contents to separate XML files". Finally, restart your server, the message must disappear.
This time page will come without any issues.
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?
Im trying to setup Apache Axis2 web services in eclipse, but im getting the following errors in my console. I followed this blog to setup a simple web service. But I seem to be missing something. I'm using windows 7 64bit.
Jan 07, 2013 2:57:33 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 (x86)\PC Connectivity Solution\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\bin;C:\Program Files (x86)\git\cmd;C:\Program Files\nodejs\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Ruby193\bin;C:\Users\intern\AppData\Roaming\npm\;C:\Python27;C:\Python27\Lib\site- packages\django\bin;D:\shortcuts;C:\Python27\Scripts;C:\mongodb\bin;D:\shortcuts\ffmpg;C:\Program Files\Java\jdk1.7.0_10\bin;;.
Jan 07, 2013 2:57:34 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:myFirstWebService' did not find a matching property.
Jan 07, 2013 2:57:34 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MyWebService' did not find a matching property.
Jan 07, 2013 2:57:34 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 07, 2013 2:57:34 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 639 ms
Jan 07, 2013 2:57:34 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jan 07, 2013 2:57:34 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.36
[WARN] Web application uses org.apache.axis2.transport.http.AxisAdminServlet; please update web.xml to use org.apache.axis2.webapp.AxisAdminServlet instead
[INFO] Clustering has been disabled
[INFO] Deploying module: addressing-1.6.2 - file:/C:/Users/intern/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyWebService/WEB-INF/modules/addressing-1.6.2.mar
[INFO] Deploying module: metadataExchange-1.6.2 - file:/C:/Users/intern/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyWebService/WEB-INF/modules/mex-1.6.2.mar
[INFO] Deploying module: mtompolicy-1.6.2 - file:/C:/Users/intern/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyWebService/WEB-INF/modules/mtompolicy-1.6.2.mar
[INFO] Deploying module: ping-1.6.2 - file:/C:/Users/intern/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyWebService/WEB-INF/modules/ping-1.6.2.mar
[INFO] Deploying module: script-1.6.2 - file:/C:/Users/intern/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyWebService/WEB-INF/modules/scripting-1.6.2.mar
[INFO] Deploying module: soapmonitor-1.6.2 - file:/C:/Users/intern/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyWebService/WEB-INF/modules/soapmonitor-1.6.2.mar
[INFO] Deploying Web service: version.aar - file:/C:/Users/intern/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyWebService/WEB-INF/services/version.aar
[INFO] Deploying Web service: WebService - file:/C:/Users/intern/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyWebService/WEB-INF/services/WebService/
[WARN] No transportReceiver for org.apache.axis2.transport.http.AxisServletListener found. An instance for HTTP will be configured automatically. Please update your axis2.xml file!
Jan 07, 2013 2:57:35 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 07, 2013 2:57:35 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jan 07, 2013 2:57:35 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/15 config=null
Jan 07, 2013 2:57:35 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1706 ms
Jan 07, 2013 2:57:35 PM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[8005]:
java.net.BindException: Address already in use: JVM_Bind
at java.net.DualStackPlainSocketImpl.bind0(Native Method)
at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:406)
at org.apache.catalina.startup.Catalina.await(Catalina.java:676)
at org.apache.catalina.startup.Catalina.start(Catalina.java:628)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Jan 07, 2013 2:57:35 PM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
Jan 07, 2013 2:57:36 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Jan 07, 2013 2:57:36 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/MyWebService] created a ThreadLocal with key of type [org.apache.axiom.util.UIDGenerator$1] (value [org.apache.axiom.util.UIDGenerator$1#29fbe6f8 ]) and a value of type [long[]] (value [[J#58f8b950]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Jan 07, 2013 2:57:37 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
I found out the problem. My Tomcat was running as a windows service and it was blocking the localhost port number at 8080. I had to disable the service and ran in eclipse it worked great :)
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.