我按照例子:(只是表不一样,数据库是Oracle)
http://www.csdn.net/develop/Read_Article.asp?Id=15250-- Initializing bean access.javax.naming.NameNotFoundException: Unable to resolve 'AccountsRemote' Resolved: '' Unresolved:'AccountsRemote' ; remaining name 'AccountsRemote' at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:109) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:262) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:229)-- Failed initializing bean access. at weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown Source) at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337) at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332) at javax.naming.InitialContext.lookup(InitialContext.java:345) at cmp.Client.<init>(Client.java:28) at cmp.Client.main(Client.java:330)-- Calling findByPrimaryKey(cmp.AccountsPK@168c03)java.lang.NullPointerException at cmp.Client.findByPrimaryKey(Client.java:107) at cmp.Client.main(Client.java:332)-- Failed: findByPrimaryKey(cmp.AccountsPK@168c03)-- Return value from findByPrimaryKey(cmp.AccountsPK@168c03): null.Error no AccountsRemote 

解决方案 »

  1.   

    CMP Bean的jndi名字 与 你lookup的名字是否相同
      

  2.   

    都是 AccountsRemote ,我看 weblogic-ejb-jar.xml 文件了。
      

  3.   

    完了,这回连make都make不了了。是不是他的例子有问题?
      

  4.   

    你给我 mail 我给你 一些EJB的例子
      

  5.   

    [email protected]我按照书上的例子作,在jb里make的时候,都出现:"CMPDemo.ejbgrpx": Missing data source name for "Product". Use the WebLogic Properties viewer for your EJB Module to set this value."CMPDemo.ejbgrpx": C:\bea\jdk131_03\bin\javaw -classpath "C:\bea\weblogic700\server\lib\weblogic_sp.jar;C:\bea\weblogic700\server\lib\weblogic.jar;"  weblogic.ejbc -keepgenerated -compiler E:/JBuilder7/bin/bcjW E:/CMP/CMPDemo.jar.jar E:/CMP/CMPDemo.jar"CMPDemo.ejbgrpx": ERROR: Error from ejbc: For cmp-field 'untitledField1' of bean 'Product', we expected to find a corresponding 'getUntitledField1' method in the abstract bean class.  Compilation cannot continue without this 'get' method"CMPDemo.ejbgrpx": ERROR: ejbc found errors
    前两段是警告,后两段是错误。这是什么原因呢?
      

  6.   

    'Product' bean中有 名字为'untitledField1' 的字段 ,
    但是找不到'getUntitledField1' 方法in the abstract bean class
    ejb 编译就error了通过JB做CMP的时候, 首先new EJB 2.0 Module
    然后再 Import Schema From Database 
    那里你会看到类是数据库连接的东西 填入选择driver 写入url
    user password, 以及你的datasource名字 ,(对应你weblogic中datasource的jndi) 
    然后ok连接到数据库,你将看到数据库的表,然后选择这些表 右健点 就可以new cmp beansgood luck , 我给你发个例子 不过我用的数据库是DB2 :)