1

我开发了一个EJB项目并打包成jar文件,然后我用Struts 2.1.15.2创建了一个Web项目,并将jar文件放在WebRoot/WEB-INF/lib目录中。我打算用它们struts2-ejb3-plugin来集成它们。但是当我在中调用execute方法时Action,我得到了这样的Struts问题报告。

堆栈跟踪:

javax.ejb.EJBException: javax.naming.NamingException: [ENCJNDIName = java:comp/env/edu.sdau.tobacco.action.common.LoginAction/userDAORemote][defaultJNDIName = /UserDAORemote/remote]?????????
    cn.agrael.struts.plugin.ejb3.StrutsEJBActionProxyFactory.createActionProxy(StrutsEJBActionProxyFactory.java:33)
    com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:553)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
    org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
    org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
    java.lang.Thread.run(Thread.java:619)
    
javax.naming.NamingException: [ENCJNDIName = java:comp/env/edu.sdau.tobacco.action.common.LoginAction/userDAORemote][defaultJNDIName = /UserDAORemote/remote]?????????
    cn.agrael.struts.plugin.ejb3.AbstractApplicationServer.lookup(AbstractApplicationServer.java:107)
    cn.agrael.struts.plugin.ejb3.AbstractApplicationServer.fieldEJBAnnotationLookup(AbstractApplicationServer.java:30)
    cn.agrael.struts.plugin.ejb3.StrutsEJBUtils.fieldInject(StrutsEJBUtils.java:367)
    cn.agrael.struts.plugin.ejb3.StrutsEJBUtils.executeEJBInjectAnnotation(StrutsEJBUtils.java:270)
    cn.agrael.struts.plugin.ejb3.StrutsEJBActionProxyFactory.createActionProxy(StrutsEJBActionProxyFactory.java:25)
    com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:553)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
    org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
    org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
    java.lang.Thread.run(Thread.java:619)
    
You are seeing this page because development mode is enabled. Development mode, or `devMode`, enables extra debugging behaviors and reports to assist developers. To disable this mode, set:

  struts.devMode=false
in your WEB-INF/classes/struts.properties file.

这是struts2-ejb3-plugin.properties

ENCPath=java:comp/env/
#ENCPath=ejb:/tobaccoWeb//
ejbContainer=cn.agrael.struts.plugin.ejb3.JbossApplicationServer
isParseResource=true
isParseEJB=true
earFileBaseName=
remote=remote
local=local

jboss-ejb-client.properties

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port = 4447

jndi.properties:_

remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
4

1 回答 1

0

您不应该这样做,而是创建一个 Java EE 项目并分别为 EJB 和 Web 添加模块。一旦ear 被部署,JBoss 将发布EJB,以便其他模块(即web 模块)可以访问它们的JNDI。

于 2013-09-30T15:29:11.567 回答