当前位置: 技术问答>java相关
实体Bean本地接口访问问题?
来源: 互联网 发布时间:2017-03-27
本文导语: 我做了一个Entity Bean 和一个sesseion Bean如下: Dept ........... Dept SessionBeanful SessionBeanful 实体Bean Dept只实现了本地接口,在session be...
我做了一个Entity Bean 和一个sesseion Bean如下:
Dept
...........
Dept
SessionBeanful
SessionBeanful
实体Bean Dept只实现了本地接口,在session bean访问实体Bean代码如下:
DeptHome deptHome = null;
Dept dept = null;
String url = "t3://192.168.0.153:7001";
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
InitialContext context= new InitialContext(properties);
deptHome = (DeptHome) context.lookup("java:comp/env/ejb/Dept");
dept = deptHome.create("1111");
dept.setDeptName("aaaaaa");
错误如下:
javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Untitled1.jar#SessionBeanful/comp/env/ejb/Dept' Resolved: 'app/ejb/Untitled1.jar#SessionBeanful/comp/env' Unresolved:'ejb' ; remaining name 'ejb/Dept
Dept
...........
Dept
SessionBeanful
SessionBeanful
实体Bean Dept只实现了本地接口,在session bean访问实体Bean代码如下:
DeptHome deptHome = null;
Dept dept = null;
String url = "t3://192.168.0.153:7001";
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
InitialContext context= new InitialContext(properties);
deptHome = (DeptHome) context.lookup("java:comp/env/ejb/Dept");
dept = deptHome.create("1111");
dept.setDeptName("aaaaaa");
错误如下:
javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/Untitled1.jar#SessionBeanful/comp/env/ejb/Dept' Resolved: 'app/ejb/Untitled1.jar#SessionBeanful/comp/env' Unresolved:'ejb' ; remaining name 'ejb/Dept
|
NameNotFoundException from test client
错误代码描述:
javax.naming.NameNotFoundException: Unable to resolve
问题发生时机:
部署完EJB JAR文件后,运行的时候
产生原因:
不能找到EJB的JNDI名。
解决方法:
打开Weblogic Server console检查部署是否有错,在Deployments——>EJB里找到EJB的模块名。检查名称后,点击右边窗口的Deploy,如果JAR部署正确的话,你将在右边的窗口的Deployment状态是true
错误代码描述:
javax.naming.NameNotFoundException: Unable to resolve
问题发生时机:
部署完EJB JAR文件后,运行的时候
产生原因:
不能找到EJB的JNDI名。
解决方法:
打开Weblogic Server console检查部署是否有错,在Deployments——>EJB里找到EJB的模块名。检查名称后,点击右边窗口的Deploy,如果JAR部署正确的话,你将在右边的窗口的Deployment状态是true
|
以下是我写过一个,参考一下:
ejb-jar.xml:
Module/Account
com.xxx.module.AccountLocalHome
com.xxx.module.AccountLocal
com.xxx.module.AccountBean
Container
com.xxx.module.AccountPK
False
jdbc/ModuleOracle
javax.sql.DataSource
Container
Shareable
Module/Manager
com.xxx.module.ManagerHome
com.xxx.module.Manager
com.xxx.module.ManagerBean
Stateless
Container
ejb/Module/AccountLocal
Entity
com.xxx.module.AccountLocalHome
com.xxx.module.AccountLocal
Module/Account
weblogic-ejb-jar.xml:
Module/Manager
ejb/Module/AccountLocal
Module/AccountLocal
Module/Manager
Module/Account
Exclusive
default
true
jdbc/ModuleOracle
jdbc/ModuleOracle
Module/Account
Module/AccountLocal
ejb-jar.xml:
Module/Account
com.xxx.module.AccountLocalHome
com.xxx.module.AccountLocal
com.xxx.module.AccountBean
Container
com.xxx.module.AccountPK
False
jdbc/ModuleOracle
javax.sql.DataSource
Container
Shareable
Module/Manager
com.xxx.module.ManagerHome
com.xxx.module.Manager
com.xxx.module.ManagerBean
Stateless
Container
ejb/Module/AccountLocal
Entity
com.xxx.module.AccountLocalHome
com.xxx.module.AccountLocal
Module/Account
weblogic-ejb-jar.xml:
Module/Manager
ejb/Module/AccountLocal
Module/AccountLocal
Module/Manager
Module/Account
Exclusive
default
true
jdbc/ModuleOracle
jdbc/ModuleOracle
Module/Account
Module/AccountLocal
|
如果是单独发布,最好用ejb-local-ref描述一下