Привет, пытаюсь запустить вместе Spring и Flex, но возникает ошибка: Код | 28.10.2009 18:21:09 org.springframework.web.servlet.FrameworkServlet initServletBean SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.remoting.RemotingDestinationExporter#0': Invocation of init method failed; nested exception is java.lang.NullPointerException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1395) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:289) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:286) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:188) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:543) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:730) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:387) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:447) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:342) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:308) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4045) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4351) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:566) 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:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: java.lang.NullPointerException at org.springframework.flex.remoting.RemotingDestinationExporter.createDestination(RemotingDestinationExporter.java:135) at org.springframework.flex.core.AbstractDestinationFactory.afterPropertiesSet(AbstractDestinationFactory.java:61) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1454) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1392) ... 31 more
|
Запускаемый код: web.xmlКод | <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>ArchitecturesFlex</display-name>
<servlet> <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/application-base.xml /WEB-INF/application-web.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> <url-pattern>/spring/*</url-pattern> </servlet-mapping>
</web-app>
|
application-base.xmlКод | <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flex="http://www.springframework.org/schema/flex" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/flex http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:/ttd.properties" /> </bean> <bean id="customerService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"> <property name="serviceUrl" value="http://${serverName}/${contextPath}/customer.service" /> <property name="serviceInterface" value="service.CustomerService" /> </bean>
<bean id="customerService2" class="CustomerServiceImpl"/>
</beans>
|
application-web.xmlКод | <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flex="http://www.springframework.org/schema/flex" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/flex http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">
<flex:message-broker /> <flex:remoting-destination ref="customerService"/> <!-- <flex:remoting-destination ref="customerService2"/> --> </beans>
|
CustomerService.javaКод | public interface CustomerService { Collection<CustomerDTO> getCustomers(); }
|
CustomerServiceImpl.javaКод | public class CustomerServiceImpl implements CustomerService {
public Collection<CustomerDTO> getCustomers() { List<CustomerDTO> list = new ArrayList<CustomerDTO>(); CustomerDTO customerDTO = new CustomerDTO(); customerDTO.setFirstName("FirstName"); customerDTO.setLastName("LastName"); list.add(customerDTO); return list; } }
|
Причём всё прекрасно работает, если: 1) В application-base.xml вместо бина "customerService", который находится вне данного проекта и вызывается удалённо: Код | <bean id="customerService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"> <property name="serviceUrl" value="http://${serverName}/${contextPath}/customer.service" /> <property name="serviceInterface" value="service.CustomerService" /> </bean>
|
поставить бин "customerService2", который находится в этом же проекте Код | <bean id="customerService2" class="CustomerServiceImpl"/>
|
2) Если использовать "customerService", но не использовать Flex, а скажем выводить данные в jsp. Т.е. другими словами сам сервис "customerService" работает нормально, а просто по какой-то причине Flex его не хочет принимать. Ошибка появляется при добавлении этой стороки: Код | <flex:remoting-destination ref="customerService"/>
|
Причину выяснить не получается, может флекс не может получать удалённую реализацию интерфейса ? - подскажите пожалуйста!
|