appServer是weblogic 6.1.
我觉得是jndi解析有问题,好像找不到DataSource,但是这些代码是jbuilder自动生成的,不应该会有这种错误呀?

解决方案 »

  1.   

    可能是dataSource = (DataSource) context.lookup("java:comp/env/jdbc/DataSource");
          错误!
    改为
    dataSource =(DataSource)PortableRemoteObject.narrow(Context.lookup("java:comp/env/jdbc/DataSource"),DataSource.class) 
    ,试试看
      

  2.   

    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>
      

  3.   

    我觉得: pipen() (  )方法值得试一下。因为这样的问题不是你忘了设置JDNI的名字就是由于RMI/IIOP使用的方式不一样引起的。
      

  4.   

    我试过pipen()的方法,除了抛出同样的错误信息,我没发现有什么不同。
      

  5.   

    为什么我在测试程序中查找bmp中任何一个jndi名称都抛出NoNameException,而在weblogic的Web管理端中却可以看到这些jndi名?是我测试程序中哪里配置有问题吗?一般碰上这类问题,都是什么原因造成的?我可真的没办法了呀!
      

  6.   

    你的那个错误是因为找不到DATASOURCE,你到WL的CONSOLE中,在JDBC
    下的Data Sources下建立一个JNDIName叫:DataSource的数据源,然后
    把:context.lookup("java:comp/env/jdbc/DataSource");
    改为:context.lookup("DataSource");
    就可以了