When I try to deploy the sample Java Spring application with MongoDB (hello-spring-mongodb) I get the error pasted below, which suggests the MongoDB service is failing to bind. I have been getting this error in all my own applications too, deploying both from the command line and from STS 3.0.0. The key error is:
Error creating bean with name 'mongoDbFactory': Invocation of init method failed; nested exception is
org.cloudfoundry.runtime.env.CloudServiceException: Expected 1 service of class org.cloudfoundry.runtime.env.MongoServiceInfo type, but found0
Full trace:
Bind existing services to 'hello-weeels'? [yN]:
Create services to bind to 'hello-weeels'? [yN]: y
1: mongodb
2: mysql
3: postgresql
4: rabbitmq
5: redis
What kind of service?: 1
Specify the name of the service [mongodb-9c56b]:
Create another? [yN]: n
Would you like to save this configuration? [yN]: y
Manifest written to manifest.yml.
Creating Application: OK
Creating Service [mongodb-9c56b]: OK
Binding Service [mongodb-9c56b]: OK
Uploading Application:
Checking for available resources: OK
Processing resources: OK
Packing application: OK
Uploading (3K): OK
Push Status: OK
Staging Application 'hello-weeels': OK
Starting Application 'hello-weeels': ..
Error: Application [hello-weeels] failed to start, logs information below.
====> /logs/stderr.log <====
Aug 27, 2012 9:17:24 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-54519
Aug 27, 2012 9:17:24 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 392 ms
Aug 27, 2012 9:17:24 PM org.apache.catalina.realm.JAASRealm setContainer
INFO: Set JAAS app name Catalina
Aug 27, 2012 9:17:24 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Aug 27, 2012 9:17:24 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
Aug 27, 2012 9:17:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Aug 27, 2012 9:17:24 PM org.cloudfoundry.reconfiguration.CloudAutoStagingBeanFactoryPostProcessor usingCloudService
INFO: Found an instance of org.cloudfoundry.runtime.service.AbstractCloudServiceFactory. Autostaging will be skipped.
Aug 27, 2012 9:17:25 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Aug 27, 2012 9:17:25 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [] startup failed due to previous errors
====> /logs/stdout.log <====
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Mon Aug 27 21:17:24 UTC 2012]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [root-context.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cloud/cloudfoundry-auto-reconfiguration-context.xml]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#c292cb2: defining beans [mongoTemplate,mongoDbFactory,__appCloudJpaPostgreSQLReplacementProperties,__appCloudJpaMySQLReplacementProperties,__appCloudHibernatePostgreSQLReplacementProperties,__appCloudHibernateMySQLReplacementProperties,org.cloudfoundry.reconfiguration.CloudAutoStagingBeanFactoryPostProcessor#0]; root of factory hierarchy
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#c292cb2: defining beans [mongoTemplate,mongoDbFactory,__appCloudJpaPostgreSQLReplacementProperties,__appCloudJpaMySQLReplacementProperties,__appCloudHibernatePostgreSQLReplacementProperties,__appCloudHibernateMySQLReplacementProperties,org.cloudfoundry.reconfiguration.CloudAutoStagingBeanFactoryPostProcessor#0]; root of factory hierarchy
ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource [root-context.xml]: Cannot resolve reference to bean 'mongoDbFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDbFactory': Invocation of init method failed; nested exception is org.cloudfoundry.runtime.env.CloudServiceException: Expected 1 service of class org.cloudfoundry.runtime.env.MongoServiceInfo type, but found0
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
Replace:
<beans profile="default">
<mongo:db-factory id="mongoDbFactory" dbname="pwdtest" host="127.0.0.1" port="27017" username="mongo_user" password="passwd"/>
</beans>
<beans profile="cloud">
<cloud:mongo-db-factory id="mongoDbFactory"/>
</beans>
With:
<mongo:db-factory
id="mongoDbFactory"
dbname="${mongo.name}"
host="${mongo.host}"
port="27017"
username="${mongo.username}"
password="${mongo.password}" />
...and cloudfoundry auto reconfig will do it's job properly. If you still have a problem, Right-click on your project in the Spring Explorer View > Properties, and enable the "Beans Validator".
Did you change the name of the expected mongo db? The hello-spring-mondgodb app is configured to to look for a db named 'hello' (The second constructor arg of SimpleMongoDbFactory). Maybe try updating this property to reflect the name of your mongo db and re-push.
Hope this helps
Chris
The hello-spring-mongodb runs without configuration changes. It deploys successfully on my CF installation. First, I create a mongoDB service with:
vmc create-service mongoDB
and then I run: vmc push hello-sping-mongodb from the target directory
C:\eclipseWork\Indigo\hello-spring-mongodb\target>vmc push hello-spring-mongodb
Would you like to deploy from the current directory? [Yn]:
Detected a Java SpringSource Spring Application, is this correct? [Yn]:
Application Deployed URL [hello-spring-mongodb.vcap.me]:
Memory reservation (128M, 256M, 512M, 1G, 2G) [512M]:
How many instances? [1]:
Bind existing services to 'hello-spring-mongodb'? [yN]: y
1: mongodb-86f0e
Which one?: 1
Create services to bind to 'hello-spring-mongodb'? [yN]:
Would you like to save this configuration? [yN]:
Creating Application: OK
Binding Service [mongodb-86f0e]: OK
Uploading Application:
Checking for available resources: OK
Processing resources: OK
Packing application: OK
Uploading (2K): OK
Push Status: OK
Staging Application 'hello-spring-mongodb': OK
Starting Application 'hello-spring-mongodb': OK
Can you try to create the mongoDB service first and then push the application?
It seems that the cloud profile configuration isn't defined in your root-context.xml. Check again that you have the following configuration:
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongoDbFactory"/>
</bean>
<beans profile="default">
<mongo:db-factory id="mongoDbFactory" dbname="pwdtest" host="127.0.0.1" port="27017" username="mongo_user" password="passwd"/>
</beans>
<beans profile="cloud">
<cloud:mongo-db-factory id="mongoDbFactory"/>
</beans>
Make sure the service name matches, and update the cloudfoundry-runtime version. See my answer to another question with the same exception here.
Related
This question already has an answer here:
UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
(1 answer)
Closed 5 years ago.
I have to finish my homework this week to build a web site based on the SSH framework(my version:struts2 spring3.1.1 hibernate4.1.4). So I used the MyEclipse (2015 CI) to rewrite the struts2 project I've finished before, for the use of the site, everything is going well, until I imported the framework of spring (using MyProject->MyEclipse->Project Facets->Install Spring Facet to import). Now when I open ANY JSP pages in MyEclipse, console will display context:
Exception to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name'transactionManager'defined in class path resource [applicationContext.xml] of init method: Invocation failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]. MyEclipse Web Browser shows that this page cannot be found.
Later, I tried to write a Hello-world project that would work properly, so it shouldn't be a server problem (I'm using MyEclipseTomcat 7.0).
My whole project code is here. And
the complete information in Console is as follows:
June 23, 2017 11:56:20 afternoon org.apache.catalina.core.AprLifecycleListener init
Information: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: E:\Program Files\myeclipse\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\bin;C:\WINDOWS\Sun\Java\bin;C:\Program Files (x86)\Java\jdk1.8.0_91\bin;.
June 23, 2017 11:56:20 afternoon org.apache.tomcat.util.digester.SetPropertiesRule begin
Warning: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:TestSystem_2143521' did not find a matching property.
June 23, 2017 11:56:20 afternoon org.apache.tomcat.util.digester.SetPropertiesRule begin
Warning: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:FileUploadAndDownLoad' did not find a matching property.
June 23, 2017 11:56:21 afternoon org.apache.coyote.AbstractProtocol init
Information: Initializing ProtocolHandler ["http-bio-8880"]
June 23, 2017 11:56:21 afternoon org.apache.coyote.AbstractProtocol init
Information: Initializing ProtocolHandler ["ajp-bio-8009"]
June 23, 2017 11:56:21 afternoon org.apache.catalina.startup.Catalina load
Information: Initialization processed in 957 ms
June 23, 2017 11:56:21 afternoon org.apache.catalina.core.StandardService startInternal
Information: Starting service Catalina
June 23, 2017 11:56:21 afternoon org.apache.catalina.core.StandardEngine startInternal
Information: Starting Servlet Engine: Apache Tomcat/7.0.30
June 23, 2017 11:56:24 afternoon org.apache.catalina.startup.TaglibUriRule body
Information: TLD skipped. URIhttp://www.springframework.org/tags/form is already defined
June 23, 2017 11:56:24 afternoon org.apache.catalina.startup.TaglibUriRule body
Information: TLD skipped. URIhttp://www.springframework.org/tags is already defined
June 23, 2017 11:56:24 afternoon org.apache.catalina.core.ApplicationContext log
Information: No Spring WebApplicationInitializer types detected on classpath
June 23, 2017 11:56:24 afternoon org.apache.catalina.core.ApplicationContext log
Information: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN Seehttp://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
June 23, 2017 11:56:26 afternoon org.apache.catalina.core.StandardContext listenerStart
Severe: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java: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:744) Caused by: org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.unwrap(DriverManagerConnectionProviderImpl.java:91)
at org.springframework.orm.hibernate4.SessionFactoryUtils.getDataSource(SessionFactoryUtils.java:101)
at org.springframework.orm.hibernate4.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 21 more
June 23, 2017 11:56:26 afternoon org.apache.catalina.core.StandardContext startInternal
Severe: Error listenerStart
June 23, 2017 11:56:26 afternoon org.apache.catalina.core.StandardContext startInternal
Severe: Context [/TestSystem] startup failed due to previous errors
June 23, 2017 11:56:26 afternoon org.apache.catalina.core.ApplicationContext log
Information: Closing Spring root WebApplicationContext
June 23, 2017 11:56:26 afternoon org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
Severe: The web application [/TestSystem] 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.
June 23, 2017 11:56:26 afternoon org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
Severe: The web application [/TestSystem] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
June 23, 2017 11:56:27 afternoon org.apache.coyote.AbstractProtocol start
Information: Starting ProtocolHandler ["http-bio-8880"]
June 23, 2017 11:56:27 afternoon org.apache.coyote.AbstractProtocol start
Information: Starting ProtocolHandler ["ajp-bio-8009"]
June 23, 2017 11:56:27 afternoon org.apache.catalina.startup.Catalina start
Information: Server startup in 6302 ms
you need to set hibernamt property as bellow code :-
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/******</property>
<property name="hibernate.connection.username">***</property>
<property name="hibernate.connection.password">***</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
and also use bellow dependencies :-
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.1.9.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.1.9.Final</version>
</dependency>
I would like to use the Specs2 test framework for testing, but I am getting an java.lang.reflect.MalformedParameterizedTypeException when I try to integrate it with Spring.
There is a specs2-spring library, but that is using 2.10 and an old version of specs2. I looked at this question about scalaTest and it got me to this code:
#ContextConfiguration(Array("classpath:applicationContext.xml"))
class TryItTest extends SpecificationWithJUnit{
#Autowired val db:DriverManagerDataSource = null
new TestContextManager(this.getClass()).prepareTestInstance(this)
"this thing should" should{
"run ok" in {
db.getConnection
success
}
}
}
but when I try to run the test I get:
Nov 09, 2015 2:11:31 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
Nov 09, 2015 2:11:31 PM org.springframework.context.support.GenericApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.GenericApplicationContext#243d315f: startup date [Mon Nov 09 14:11:31 EST 2015]; root of context hierarchy
Nov 09, 2015 2:11:31 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: oracle.jdbc.driver.OracleDriver
Nov 09, 2015 2:11:31 PM org.springframework.test.context.TestContextManager prepareTestInstance
SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#131746d9] to prepare test instance [my.package.TryItTest#12474a03]
java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:51)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:92)
at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94)
at java.lang.reflect.Executable.getGenericParameterTypes(Executable.java:284)
at java.lang.reflect.Method.getGenericParameterTypes(Method.java:282)
at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387)
at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:116)
If I switch from SpecificationWithJUnit to SpecWithJUnit it runs the test without error, but I do not want to have in include all those traits by hand. I think (at least) one of the traits in Matchers is causing the problem. Has anyone else tried to do this with Specs2? Am I missing something important?
(I am using Spring V4.1.0.RELEASE)
Got it. I was not using the latest version of scalaz and specs2. Everything works perfectly now.
Using the directions at https://github.com/ArcBees/ArcBees-tools/blob/master/archetypes/gwtp-basic/README.md and http://c.gwt-examples.com/home/maven/ide-import/eclipse I've created a GWTP project with maven. It works well on the debug mode but I'm having problems deploying it.
1) run the command mvn gwt:compile
2) copy the .war file to two different Tomcat servers
3) Restart the server
4) Browse to the location of the file and I get a 404 error
HTTP Status 404 - /transpohubAdmin/Project.html
type Status report
message /transpohubAdmin/Project.html
description The requested resource is not available.
Apache Tomcat/7.0.32
This error occurs also if I go directly to a css file (unless I delete the Project.html file first)
The catalina.out is:
May 2, 2013 9:22:01 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/local/apache-tomcat-7.0.32/webapps/transpohubAdmin.war
May 2, 2013 9:22:02 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/Library/Tomcat/webapps/transpohubAdmin/WEB-INF/lib/gwt-user-2.5.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
May 2, 2013 9:22:02 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
May 2, 2013 9:22:02 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/transpohubAdmin] startup failed due to previous errors
I've googled See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class and not found any help with this error.
Any suggestions?
Cheers,
You shouldn't have gwt-user in your WAR. There should be gwt-servlet if your use GWT-RPC, or requestfactory-server if you use RequestFactory.
In other words, the gwt-user dependency in the pom.xml should have <scope>provided</scope> and you should add a dependency on gwt-servlet with <scope>runtime</scope>.
Please file an issue on Brandon's archetype.
I'm trying to learn about Spring using SpringSource Tool Suite. I haven't had much successful experience with either at this stage.
So far I've been able to install STS and create a new project, but haven't gotten much further. The problem seems to occur when running the application on the tc Server. I'll run through the steps I've taken and perhaps someone can point out where I'm going wrong. For the record, I'm using Ubuntu 11.10.
I installed STS using the this link, which I found on the
SpringSource Tool Suite Download page.
During installation of STS, I chose to install in my home folder
/home/luke/springsource. I left all of the packs selected:
SpringSource Tool Suite 2.8.0.RELEASE; vFabric tc Server
2.6.1.RELEASE; Spring Roo 1.1.5.RELEASE; Apache Maven 3.0.3
When selecting the JDK path, I chose /usr/lib/jvm/default-java, which
links to /usr/lib/jvm/java-6-openjdk.
The installation completes successfully and I launch STS manually by
going to the installation directory
/home/luke/springsource/sts-2.8.0.RELEASE and executing the file STS.
I had to do this to get STS to run despite having checked the box to
run STS now at the end of installation (not sure if that's a real
problem but thought it'd be worth mentioning).
I choose my workspace
/home/luke/Documents/workspace-sts-2.8.0.RELEASE and clicked OK. So
far so good?
In the dashboard I click Create > Spring Template Project.
In the following dialog I click Spring MVC Project and click Next,
then agree to download.
In the Project Settings dialog, I give the project a name, springmvc,
and a valid top-level package, then click Finish.
I can now see my newly created project in the Package Explorer, as
well as a Servers folder, plus the VMware vFabric tc Server Developer
Edition v2.6 in the Server window.
I drag the project to the server in the Server window and the project
appears there with a [Synchronized] status. I then right-click the
project in the Package Explorer and click Run As > Run on Server.
The aforementioned server is there and selected, so I click Next. The
project I created is in the Configured section of the next screen, so
I click Finish. I'm asked if I want to use Spring Insight, so I click
Yes and the server starts up.
Here's where the big trouble begins.
I get the following output to the console and a 404 message in the
browser window, which is pointed at http://localhost:8080/springmvc/
Console output:
Nov 3, 2011 4:21:29 PM com.springsource.tcserver.security.PropertyDecoder <init>
INFO: tc Runtime property decoder using memory-based key
Nov 3, 2011 4:21:30 PM com.springsource.tcserver.security.PropertyDecoder <init>
INFO: tcServer Runtime property decoder has been initialized in 924 ms
Nov 3, 2011 4:21:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Nov 3, 2011 4:21:32 PM com.springsource.tcserver.serviceability.rmi.JmxSocketListener init
INFO: Started up JMX registry on 127.0.0.1:6969 in 368 ms
Nov 3, 2011 4:21:32 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3809 ms
Nov 3, 2011 4:21:32 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 3, 2011 4:21:32 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: VMware vFabric tc Runtime 2.6.1.RELEASE/7.0.20.B.RELEASE
Nov 3, 2011 4:21:32 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor springmvc.xml from /home/luke/springsource/vfabric-tc-server-developer-2.6.1.RELEASE/spring-insight-instance/conf/Catalina/localhost
Nov 3, 2011 4:21:33 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:springmvc' did not find a matching property.
Nov 3, 2011 4:21:33 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start
INFO: Context [localhost|springmvc] will not be woven
Nov 3, 2011 4:21:34 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2406)
at java.lang.Class.getConstructor0(Class.java:2716)
at java.lang.Class.newInstance0(Class.java:343)
at java.lang.Class.newInstance(Class.java:325)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
... 14 more
Nov 3, 2011 4:21:34 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Nov 3, 2011 4:21:34 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Nov 3, 2011 4:21:34 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [227] milliseconds.
Nov 3, 2011 4:21:34 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/springmvc] startup failed due to previous errors
Nov 3, 2011 4:21:34 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor insight.xml from /home/luke/springsource/vfabric-tc-server-developer-2.6.1.RELEASE/spring-insight-instance/conf/Catalina/localhost
Nov 3, 2011 4:21:41 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start
INFO: Context [localhost|insight] will not be woven
Nov 3, 2011 4:21:42 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Nov 3, 2011 4:22:00 PM org.apache.jasper.compiler.TldLocationsCache tldScanJar
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Nov 3, 2011 4:22:11 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'Spring MVC Dispatcher Servlet'
Nov 3, 2011 4:22:18 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory manager
Nov 3, 2011 4:22:18 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start
INFO: Context [localhost|manager] will not be woven
Nov 3, 2011 4:22:18 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Nov 3, 2011 4:22:18 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start
INFO: Context [localhost|ROOT] will not be woven
Nov 3, 2011 4:22:18 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Nov 3, 2011 4:22:19 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 46286 ms
Any help in deciphering this, figuring out a solution and pointing out what I'm doing wrong here in what seems like a very simple use case of STS, would be greatly appreciated.
ditto Ralph.
selected the top level project, went to
Run As > Maven Clean
Run As > Maven Install
Run As > Run on Server
and it went through correctly. I'm not sure why it was failing on the first place though, or why installing it twice fixes it.
Looks like the Project is not correct deployed to the server.
The context menu, for the server contains a option to clean it. After you have clean it use the same context menu and publish the application.
Then try it again.
(An other cause for this problem can be that there is a compiler failure.)
I am building a GWT app with Spring. I am having some issues to inject a dependency to one of my Servlets, so I am trying to narrow down what can be wrong.
First, when my app starts I get:
[WARN] Server class
'org.springframework.web.context.ContextLoaderListener'
could not be found in the web app, but
was found on the system classpath
[WARN] Adding classpath entry
'file:/home/macarse/.m2/repository/org/springframework/spring/2.5.6/spring-2.5.6.jar'
to the web app classpath for this
session For additional info see:
file:/home/macarse/tpf/eclipse/plugins/com.google.gwt.eclipse.sdkbundle.2.0.4_2.0.4.v201006301309/gwt-2.0.4/doc/helpInfo/webAppClassPath.html
[WARN] Server class
'org.apache.commons.collections.map.CaseInsensitiveMap'
could not be found in the web app, but
was found on the system classpath
[WARN] Adding classpath entry
'file:/home/macarse/tpf/eclipse/plugins/com.google.gwt.eclipse.sdkbundle.2.0.4_2.0.4.v201006301309/gwt-2.0.4/gwt-dev.jar' to the web app classpath for this
session For additional info see:
file:/home/macarse/tpf/eclipse/plugins/com.google.gwt.eclipse.sdkbundle.2.0.4_2.0.4.v201006301309/gwt-2.0.4/doc/helpInfo/webAppClassPath.html
Jul 18, 2010 11:07:00 AM
org.springframework.web.context.ContextLoader
initWebApplicationContext INFO: Root
WebApplicationContext: initialization
started Jul 18, 2010 11:07:00 AM
org.springframework.context.support.AbstractApplicationContext
prepareRefresh INFO: Refreshing
org.springframework.web.context.support.XmlWebApplicationContext#16b904d:
display name [Root
WebApplicationContext]; startup date
[Sun Jul 18 11:07:00 ART 2010]; root
of context hierarchy Jul 18, 2010
11:07:00 AM
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory INFO: Bean
factory for application context
[org.springframework.web.context.support.XmlWebApplicationContext#16b904d]:
org.springframework.beans.factory.support.DefaultListableBeanFactory#1a8dfb3
Jul 18, 2010 11:07:01 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons INFO:
Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory#1a8dfb3:
defining beans []; root of factory
hierarchy Jul 18, 2010 11:07:01 AM
org.springframework.web.context.ContextLoader
initWebApplicationContext
Is that OK?
In my web.xml I have:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:/META-INF/spring-presentation.xml, classpath*:/META-INF/spring-persistence.xml
</param-value>
</context-param>
Is there a way to know if those two xml were loaded?
Scan your application startup logs. You should find logs telling you which context files it loaded in the following format (log pattern might differ based on your log config):
org.springframework.beans.factory.xml.XmlBeanDefinitionReader (315): Loading XML bean definitions from ServletContext resource [/META-INF/spring-presentation.xml]
org.springframework.beans.factory.xml.XmlBeanDefinitionReader (315): Loading XML bean definitions from ServletContext resource [/META-INF/spring-persistence.xml]