求助EJB错误的解决方法,多谢! appServer是weblogic 6.1.我觉得是jndi解析有问题,好像找不到DataSource,但是这些代码是jbuilder自动生成的,不应该会有这种错误呀? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可能是dataSource = (DataSource) context.lookup("java:comp/env/jdbc/DataSource"); 错误!改为dataSource =(DataSource)PortableRemoteObject.narrow(Context.lookup("java:comp/env/jdbc/DataSource"),DataSource.class) ,试试看 to pipen() : 你的方法我试过了,还是出现同样的错误信息。以下是我的ejb-jar.xml文件,由jbuilder自动生成,应该不会错吧?<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd"><ejb-jar> <enterprise-beans> <entity> <ejb-name>Account</ejb-name> <home>eshop.AccountHome</home> <remote>eshop.Account</remote> <ejb-class>eshop.AccountBeanBMP</ejb-class> <persistence-type>Bean</persistence-type> <prim-key-class>java.lang.String</prim-key-class> <reentrant>False</reentrant> <resource-ref> <res-ref-name>jdbc/DataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </entity> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>Account</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> </assembly-descriptor></ejb-jar> 我觉得: pipen() ( )方法值得试一下。因为这样的问题不是你忘了设置JDNI的名字就是由于RMI/IIOP使用的方式不一样引起的。 我试过pipen()的方法,除了抛出同样的错误信息,我没发现有什么不同。 为什么我在测试程序中查找bmp中任何一个jndi名称都抛出NoNameException,而在weblogic的Web管理端中却可以看到这些jndi名?是我测试程序中哪里配置有问题吗?一般碰上这类问题,都是什么原因造成的?我可真的没办法了呀! 你的那个错误是因为找不到DATASOURCE,你到WL的CONSOLE中,在JDBC下的Data Sources下建立一个JNDIName叫:DataSource的数据源,然后把:context.lookup("java:comp/env/jdbc/DataSource");改为:context.lookup("DataSource");就可以了 java 监控程序 高分在线等 奇怪:tomcat重启导致乱码!!!100分求救!!! 如何转换 求助,哥们们,我的tomcat在lomboz-eclipse用不了。 一个很急很急的问题 怎么样一个ejb从jboss3.2移植到 jboss4.0???? jdogenie的问题 高分求救XML的问题!!! 请教几个问题,分可以另外开贴再补。 servlet中输出xml数据出错!![求助] 请问高手:EJB中的远程接口、本地接口、HOME接口的联系与区别是什么?应用时应注意哪些问题?
错误!
改为
dataSource =(DataSource)PortableRemoteObject.narrow(Context.lookup("java:comp/env/jdbc/DataSource"),DataSource.class)
,试试看
你的方法我试过了,还是出现同样的错误信息。以下是我的ejb-jar.xml文件,由jbuilder自动生成,应该不会错吧?<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>Account</ejb-name>
<home>eshop.AccountHome</home>
<remote>eshop.Account</remote>
<ejb-class>eshop.AccountBeanBMP</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<res-ref-name>jdbc/DataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Account</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
下的Data Sources下建立一个JNDIName叫:DataSource的数据源,然后
把:context.lookup("java:comp/env/jdbc/DataSource");
改为:context.lookup("DataSource");
就可以了