2015-10-07 147 views
1

在從Jboss AS5遷移到Wildfly9的應用程序中,我試圖在wildfly中加載一個模塊:javax.transaction.api 查看Wildfly article以在WF8中加載模塊,它表示您可能不需要顯式加載某些模塊,因爲它們是隱式加載的。Wildfly:使用Spring @Autowired進行UserTransaction

我用我的一個類

@Autowired 
private UserTransaction transaction; 

然後我在applictionContext.xml

在我的JBoss部署,structure.xml定義它
<jee:jndi-lookup id="userTransaction" jndi-name="UserTransaction" expected-type="javax.transaction.UserTransaction"/> 

<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只是爲了以防萬一,他們都沒有工作。我沒有得到ClassNotfoundexceptionClassCastexception。一切似乎都非常簡單。我無法理解這裏缺少的東西。

"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

的錯誤是在堆棧跟蹤:因爲JNDI查找失敗

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

這個bean無法創建。您的應用服務器上沒有名爲「UserTransaction」的資源。

+0

我認爲javax.transaction.UserTransaction是JNDI指向的資源。這是作爲模塊添加的jta.jar的一部分。它似乎看不到jta.jar,即使我已經添加爲模塊,甚至嘗試將它作爲jar添加到WEB-INF/lib中作爲庫。 – sarmahdi

+2

這是資源的類型。如果您正在部署到Wildfly中,則不需要添加jta.jar,它是應用程序服務器的一部分。堆棧跟蹤說明您在jndi-name中有錯誤的值。 jndi名「UserTransaction」對我來說看起來不對。我期望像「java:jboss/UserTransaction」或「java:comp/UserTransaction」。 – sh0rug0ru

+0

謝謝sh0rug0ru:java:jboss/UserTransaction完成了這個任務。奇怪的是,我還有兩個jndi查找,一個是連接工廠,它是java:/ JmsXA,它可以工作,另一個是具有jndi-name:java:/ eis/myeis的eis,並且這也適用。 JmsXa也來自於javax,jms.Connection,我甚至嘗試過java:/ UserTransaction,但是這並不起作用,我不得不在其中添加jboss以使其工作。 – sarmahdi