2015-10-07 3 views
1

Во время моей миграции из Jboss AS5 в Wildfly9 для приложения я пытаюсь загрузить модуль в wildfly: javax.transaction.api Рассматривая Wildfly article для загрузки модулей в WF8, говорится: что вам может не понадобиться загружать некоторые модули явно, поскольку они загружаются неявно.Wildfly: Использование Spring @Autowired для UserTransaction

Я использую в одном из моих классов

@Autowired 
private UserTransaction transaction; 

тогда я определяю его в applictionContext.xml

<jee:jndi-lookup id="userTransaction" jndi-name="UserTransaction" expected-type="javax.transaction.UserTransaction"/> 

в моей JBoss-развертывания-structure.xml

<module name="javax.api"/> 
    <module name="javax.transaction.api"/> 

но я получаю эту ошибку:

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: 
private javax.transaction.UserTransaction com.mycomp.myapp.EventSender.transaction; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type [javax.transaction.UserTransaction] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 

Я попытался добавить jta.jar в lib войны, я попытался добавить зависимости jta. Я попытался добавить javax.transaction только на всякий случай, они все не работали. Я не получаю ClassNotfoundexception или ClassCastexception. Все выглядит так просто. Я не понимаю, чего здесь нет.

"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./myApp" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./myApp: java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myAppManager' defined in \"/C:/JAVA/WF9/wildfly-9.0.0.Final/bin/content/myApp-engine-2.0.2-SNAPSHOT.war/WEB-INF/classes/com/mycomp/myApp/myAppManager.class\": Unsatisfied dependency expressed through constructor argument with index 2 of type [com.mycomp.myApp.EventSender]: : Error creating bean with name 'EventSender': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'EventSender': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Caused by: java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myAppManager' defined in \"/C:/JAVA/WF9/wildfly-9.0.0.Final/bin/content/myApp-engine-2.0.2-SNAPSHOT.war/WEB-INF/classes/com/mycomp/myApp/myAppManager.class\": Unsatisfied dependency expressed through constructor argument with index 2 of type [com.mycomp.myApp.EventSender]: : Error creating bean with name 'EventSender': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'EventSender': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myAppManager' defined in \"/C:/JAVA/WF9/wildfly-9.0.0.Final/bin/content/myApp-engine-2.0.2-SNAPSHOT.war/WEB-INF/classes/com/mycomp/myApp/myAppManager.class\": Unsatisfied dependency expressed through constructor argument with index 2 of type [com.mycomp.myApp.EventSender]: : Error creating bean with name 'EventSender': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'EventSender': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'EventSender': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction Caused by: javax.naming.NameNotFoundException: UserTransaction -- service jboss.naming.context.java.UserTransaction"}}, "rolled-back" => true

Благодарим за помощь.

+0

Проверьте инструмент миграции JBoss Windup (https://github.com/windup/windup/wiki). –

ответ

1

Ошибка в StackTrace:

'userTransaction': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: UserTransaction 

Компонент не может быть создан, потому что JNDI поиск не удался. На вашем сервере приложений нет ресурса с именем «UserTransaction».

+0

Я думаю, что javax.transaction.UserTransaction - это ресурс, на который указывает JNDI. который является частью jta.jar, который добавляется как модуль. кажется, что он не может видеть jta.jar, хотя я добавил его в качестве модуля или даже попытался добавить его как банку в WEB-INF/lib в качестве библиотеки. – sarmahdi

+2

Это тип ресурса. Если вы развертываете в Wildfly, вам не нужно добавлять jta.jar, это часть сервера приложений. Трассировка стека утверждает, что у вас неправильное значение в имени jndi. Имя jndi «UserTransaction» выглядит неправильно для меня. Я бы ожидал чего-то вроде «java: jboss/UserTransaction» или «java: comp/UserTransaction». – sh0rug0ru

+0

Спасибо sh0rug0ru: java: jboss/UserTransaction сделал трюк. Как ни странно, у меня есть еще два jndi-поиска, один из которых - фабрика соединений, и это java:/JmsXA, и она работает, а другая - eis, которая имеет jndi-name: java:/eis/myeis, и это работает также , JmsXa также поступает из javax, jms.Connection, я даже попробовал java:/UserTransaction, но это не сработало, мне пришлось добавить jboss туда, чтобы он работал. – sarmahdi