Hi, I'm working on a prototype with a GWT web presentation layer and a spring backend. To connect both I use GWT Server Library. I configured everything with XML and it worked perfectly fine. Since I found out about spring javaconfig i want to use this for configuration. But I get problems with session scoped beans.
On runtime I get the following warning, although communication works later on.:
[WARN] Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'urlMapping' defined in ServletContext resource [/WEB-INF/benutzerkonto-servlet.xml]: Cannot resolve reference to bean 'serviceBenutzerkonto' while setting bean property 'mappings' with key [TypedStringValue: value [/stammdaten.srv], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'serviceBenutzerkonto': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
When running my Junit Tests I get the following error:
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '...TestBenutzerkontoServiceImpl': Autowiring of methods failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire method: public void ...TestBenutzerkontoServiceImpl.setBenutzerkontoSe rvice(...client.interfaces.BenutzerkontoService); nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No unique bean of type [...client.interfaces.BenutzerkontoService] is defined: Unsatisfied dependency of type [interface ...interfaces.BenutzerkontoService]: expected at least 1 matching bean
My Configuration:
AdminServiceConfig.java
If I remove the session scope, everything is workling withoiut warnings or errors.Code:@Configuration public abstract class AdminServiceConfig { @Bean(scope = DefaultScopes.SESSION) @ScopedProxy(proxyTargetClass = false) public BenutzerkontoServiceImpl serviceBenutzerkonto() { BenutzerkontoServiceImpl service = new BenutzerkontoServiceImpl(); service.setLockingService(serviceLocking()); service.setMaxId(maxIdDAO()); service.setUserDao(userDAO()); service.setPasswordsDao(passwordsDAO()); service.setFunktionsRechteDao(funktionsRechteDAO()); return service; } ... }
Does anybody have an Idea what's going on?
I'm importing in the classpath org.springframework.config.java-1.0.0.M4.jar and org.springframework.config.java-sources-1.0.0.M4.jar plus the files in the lib folder of javaconfig 1.0.0.M3
To get the Tests working with the old XML Configuration I had to extend the AbstractContextLoader, to provide the test with a web Context. If necessary I can also show the code here, but I guess there is a problem with the proxying and I'm probably not using it correct.
TestBenutzerkontoServiceImpl.java:
Code:@ContextConfiguration(locations = { "applicationContext.xml" }, loader=TestWebSessionContextLoader.class) public class TestBenutzerkontoServiceImpl extends AbstrServiceTest{ private BenutzerkontoService BenutzerkontoService; protected IDataSet getDataSet() throws Exception { return new FlatXmlDataSet(new FileInputStream("stammdaten.xml")); //$NON-NLS-1$ } @Autowired public void setBenutzerkontoService(BenutzerkontoService BenutzerkontoService){ this.BenutzerkontoService = BenutzerkontoService; } }


