2015-05-25 2 views
0

Я новичок в Java EE, у меня есть проблема, когда весенние синглтоны, которые имеют свойство JndiObjectFactoryBean, создаются до того, как сам JNDI связан. Это приводит к ошибке при развертывании и сбою приложения.Созданы экземпляры Spring синглов перед тем, как произошел JNDI DataSourceBinding

Есть ли способ настроить приоритет инициализации? Как заставить JNDI DataSourceBinding создать экземпляр сначала перед весенними синглонами?

Я использую jboss-5.1.0.GA в качестве моего сервера приложений.

Вот отрывок из server.log:

2015-05-25 16:47:14,410 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (main) Pre-instantiating singletons in org.s[email protected]1f873f7: defining beans [daoAuthenticationProvider,authenticationManager,settingbean,authenticationFailureHandler,authenticationSuccessHandler,sessionRegistry,sessionAuthenticationStrategy,authenticationFilter,sessionManageProcessingFilter,httpSessionContextIntegrationFilter,filterChainProxy,securityContextPersistenceFilter,filterSecurityInterceptor,httpRequestAccessDecisionManager,roleVoter,cxcdataDS,datasourceByJNDI,JTATransactionManager,jdbcTXManager,jdbcTemplate,jdbcTemplateext]; root of factory hierarchy 
2015-05-25 16:47:14,593 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (main) Destroying singletons in org.s[email protected]1f873f7: defining beans [daoAuthenticationProvider,authenticationManager,settingbean,authenticationFailureHandler,authenticationSuccessHandler,sessionRegistry,sessionAuthenticationStrategy,authenticationFilter,sessionManageProcessingFilter,httpSessionContextIntegrationFilter,filterChainProxy,securityContextPersistenceFilter,filterSecurityInterceptor,httpRequestAccessDecisionManager,roleVoter,cxcdataDS,datasourceByJNDI,JTATransactionManager,jdbcTXManager,jdbcTemplate,jdbcTemplateext]; root of factory hierarchy 
2015-05-25 16:47:14,593 ERROR [org.springframework.web.context.ContextLoader] (main) Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider' defined in ServletContext resource [/WEB-INF/classes/CXC_Security.xml]: Cannot create inner bean 'org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl#1437781' of type [org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl] while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl#1437781' defined in ServletContext resource [/WEB-INF/classes/CXC_Security.xml]: Cannot resolve reference to bean 'cxcdataDS' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cxcdataDS' defined in ServletContext resource [/WEB-INF/classes/CXC_DataSource.xml]: Cannot resolve reference to bean 'datasourceByJNDI' while setting bean property 'targetDataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'datasourceByJNDI' defined in ServletContext resource [/WEB-INF/classes/CXC_DataSource.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: cxcdataDS not bound 
... 

и только после долгой трассировки стеки ошибок требуемой JNDI связывания конкретизируется

2015-05-25 16:47:16,759 INFO [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] (main) Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=cxcdataDS' to JNDI name 'java:cxcdataDS' 

Я был бы очень признателен, если кто-то может помочь меня за это.

+0

Я не уверен, но вы пробовали использовать JNDI-имя 'java: cxcdataDS' вместо' cxcdataDS' в '' CXC_Security.xml'? – Vartlok

+0

Привет, @ Vartlok, спасибо за помощь. К счастью, я нашел причину своей проблемы. В самом названии JNDI нет проблем, только проблема с развертыванием. – Henry

ответ

0

В конце концов, синглтоны создаются до того, как JNDI связан из-за проблемы во время развертывания, по какой-либо причине приложение развертывается внутри папки .sar, принадлежащей JBoss. Из-за этого приложение загружается до создания JNDI. После того, как я переместил приложение в нужную папку, он работает нормально, как и раньше.

 Смежные вопросы

  • Нет связанных вопросов^_^