免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2308 | 回复: 7
打印 上一主题 下一主题

一ejb客户端运行时出现问题,请指点迷津[已结] [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-06-17 16:21 |只看该作者 |倒序浏览
informix没有报错,weblogic服务端也没有报错。百思不解其所,还望高手赐教。
环境:xp+weblogic8.1+hp unix 下的 informix
客户端代码:
  1. package com.titan.cabin;

  2. import com.titan.cabin.CabinHome;
  3. import com.titan.cabin.Cabin;
  4. import com.titan.cabin.CabinPK;

  5. import javax.naming.InitialContext;
  6. import javax.naming.Context;
  7. import javax.naming.NamingException;
  8. import java.rmi.RemoteException;
  9. import java.util.Properties;

  10. public class Client_1 {
  11.     public static void main(String [] args){
  12.         try {
  13.         System.out.println("Enter main...");
  14.         System.out.println("get context...");
  15.             Context jndiContext = getInitialContext();
  16.         System.out.println("get context ok,lookup CabinHome...");
  17. //            Object obj = jndiContext.lookup("java:comp/env/ejb/CabinHome");
  18.             Object obj = jndiContext.lookup("cabin");
  19.             CabinHome home = (CabinHome) javax.rmi.PortableRemoteObject.narrow(obj, CabinHome.class);

  20.         System.out.println("lookup CabinHome ok,creating Cabin...");
  21.             Cabin cabin_1 = home.create(1);
  22.             System.out.println("created it!");
  23.             cabin_1.setName("Master Suite");
  24.             cabin_1.setDeckLevel(1);
  25.             cabin_1.setShip(1);
  26.             cabin_1.setBedCount(3);
  27.                   
  28.             CabinPK pk = new CabinPK();
  29.             pk.id = 1;
  30.             System.out.println("keyed it! ="+ pk);
  31.             
  32.             Cabin cabin_2 = home.findByPrimaryKey(pk);
  33.             System.out.println("found by key! ="+ cabin_2);
  34.             System.out.println("Ship.name is:"+cabin_2.getName());
  35.             System.out.println("Ship.deckLevel is:"+cabin_2.getDeckLevel());
  36.             System.out.println("Ship.shipno is:"+cabin_2.getShip());
  37.             System.out.println("Ship.bedCount is:"+cabin_2.getBedCount());

  38. } catch (java.rmi.RemoteException re){System.out.println("RE");re.printStackTrace();}
  39.           catch (javax.naming.NamingException ne){System.out.println("NE");ne.printStackTrace();}
  40.           catch (javax.ejb.CreateException ce){System.out.println("CE");ce.printStackTrace();}
  41.           catch (javax.ejb.FinderException fe){System.out.println("FE");fe.printStackTrace();}
  42.     }


  43.     public static Context getInitialContext()
  44.                           throws javax.naming.NamingException {

  45.         Context ctx;
  46.         try {
  47.         Properties p = new Properties();
  48.         // ... Specify the JNDI properties specific to the vendor.
  49.         //return new javax.naming.InitialContext(p);
  50. /** weblogic */
  51.         p.put(Context.INITIAL_CONTEXT_FACTORY,
  52.                 "weblogic.jndi.TengahInitialContextFactory");
  53.         p.put(Context.PROVIDER_URL, "t3://localhost:7001");
  54. //        return getJ2EERIInitialContext();
  55.         ctx = new InitialContext(p);

  56.       } catch (NamingException ne) {
  57.         System.err.println("** Unable to connect to the server at:t3://localhost:7001");
  58.         ne.printStackTrace();
  59.         throw ne;
  60.       }

  61.     return ctx;
  62.   }
  63. //        return new javax.naming.InitialContext(p);
  64. //    }
  65.     public static Context getJ2EERIInitialContext()
  66.                           throws javax.naming.NamingException {

  67.         return new javax.naming.InitialContext();
  68.     }

  69.     public static Context getGemstoneInitialContext()
  70.                           throws javax.naming.NamingException {
  71.        Properties p = new Properties();
  72.        // Uncomment if you have the com.gemstone.* classes available
  73.        //p.put(com.gemstone.naming.Defaults.NAME_SERVICE_HOST,"localhost");
  74.        String port = System.getProperty("com.gemstone.naming.NameServicePort",
  75.                                         "10200");
  76.        // Uncomment if you have the com.gemstone.* classes available
  77.        //p.put(com.gemstone.naming.Defaults.NAME_SERVICE_PORT, port);
  78.        p.put(Context.INITIAL_CONTEXT_FACTORY,"com.gemstone.naming.GsCtxFactory");
  79.        return new InitialContext(p);
  80.     }

  81.     public static Context getWeblogicInitialContext()
  82.                           throws javax.naming.NamingException {
  83.        Properties p = new Properties();
  84.        p.put(Context.INITIAL_CONTEXT_FACTORY,
  85.              "weblogic.jndi.TengahInitialContextFactory");
  86.        p.put(Context.PROVIDER_URL, "t3://localhost:7001");
  87.        return new javax.naming.InitialContext(p);
  88.     }

  89. }
复制代码

bean代码:
  1. package com.titan.cabin;

  2. import javax.ejb.EntityContext;

  3. public abstract class CabinBean implements javax.ejb.EntityBean {

  4.    
  5.     public CabinPK ejbCreate(int id){
  6.         setId(id);
  7.         return null;
  8.     }
  9.     public void ejbPostCreate(int id){
  10.         // Do nothing. Required.
  11.     }
  12.     public abstract int getId();
  13.     public abstract void setId(int id);
  14.     public abstract String getName();
  15.     public abstract void setName(String str);
  16.     public abstract int getShip();
  17.     public abstract void setShip(int sp);
  18.     public abstract int getBedCount();
  19.     public abstract void setBedCount(int bc);
  20.     public abstract int getDeckLevel();
  21.     public abstract void setDeckLevel(int level );

  22.      public void setEntityContext(EntityContext ctx){
  23.          // Not implemented.
  24.     }
  25.     public void unsetEntityContext(){
  26.          // Not implemented.
  27.     }
  28.     public void ejbActivate(){
  29.         // Not implemented.
  30.     }
  31.     public void ejbPassivate(){
  32.         // Not implemented.
  33.     }
  34.     public void ejbLoad(){
  35.         // Not implemented.
  36.     }
  37.     public void ejbStore(){
  38.         // Not implemented.
  39.     }
  40.     public void ejbRemove(){
  41.         // Not implemented.
  42.     }
  43. }
复制代码

出错提示信息:
  1. Enter main...
  2. get context...
  3. get context ok,lookup CabinHome...
  4. lookup CabinHome ok,creating Cabin...
  5. created it!
  6. keyed it! =1
  7. found by key! =weblogic.rmi.cluster.ClusterActivatableRemoteRef@5a0abe8 - hostID
  8. : '163223322531701330S:112.23.190.23:[7001,7001,7002,7002,7001,7002,-1,0,0]:examp
  9. les:examplesServer', oid: '291', aid: '1', jndiName: 'cabin'
  10. Ship.name is:Master Suite
  11. RE
  12. java.rmi.RemoteException: EJB Exception: ; nested exception is:
  13.         java.sql.SQLException: [BEA][Informix JDBC Driver][Informix]System error
  14. - invalid statement id received by the sqlexec process.
  15.         at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.j
  16. ava:108)
  17.         at weblogic.rmi.internal.activation.ActivatableRemoteRef.invoke(Activata
  18. bleRemoteRef.java:83)
  19.         at weblogic.rmi.cluster.ClusterActivatableRemoteRef.invoke(ClusterActiva
  20. tableRemoteRef.java:65)
  21.         at com.titan.cabin.CabinBean_mludcw_EOImpl_812_WLStub.getDeckLevel(Unkno
  22. wn Source)
  23.         at com.titan.cabin.Client_1.main(Client_1.java:39)
  24. Caused by: java.sql.SQLException: [BEA][Informix JDBC Driver][Informix]System er
  25. ror - invalid statement id received by the sqlexec process.
  26.         at com.titan.cabin.CabinBean_mludcw__WebLogic_CMP_RDBMS.getDeckLevel(Cab
  27. inBean_mludcw__WebLogic_CMP_RDBMS.java:375)
  28.         at com.titan.cabin.CabinBean_mludcw_EOImpl.getDeckLevel(CabinBean_mludcw
  29. _EOImpl.java:147)
  30.         at com.titan.cabin.CabinBean_mludcw_EOImpl_WLSkel.invoke(Unknown Source)

  31.         at weblogic.rmi.internal.activation.ActivatableServerRef.invoke(Activata
  32. bleServerRef.java:87)
  33.         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
  34.         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
  35. dSubject.java:353)
  36.         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
  37. 144)
  38.         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
  39. a:415)
  40.         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
  41. .java:30)
  42.         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
  43.         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
复制代码

论坛徽章:
0
2 [报告]
发表于 2004-06-17 17:08 |只看该作者

一ejb客户端运行时出现问题,请指点迷津[已结]

System error
- invalid statement id received by the sqlexec process


应该是WL的问题
问题比较棘手,可以问下BEA那边

论坛徽章:
0
3 [报告]
发表于 2004-06-17 17:19 |只看该作者

一ejb客户端运行时出现问题,请指点迷津[已结]

谢谢猫小版主的关注,我的weblogic8.1是从bea网站上free download
的,license 允许同时不超过5个连接,无时间限制。

数据插到数据库里了,这个我看到了。你的意思是说要和bea公司的技术人员联系吗?

那好麻烦的。

论坛徽章:
0
4 [报告]
发表于 2004-06-17 17:32 |只看该作者

一ejb客户端运行时出现问题,请指点迷津[已结]

找他们的售前技术工程师
尽量把自己描述成他们的潜在客户就好了

论坛徽章:
0
5 [报告]
发表于 2004-06-17 20:53 |只看该作者

一ejb客户端运行时出现问题,请指点迷津[已结]

谢谢版主,我试试,等有了答案,我再来结贴。

论坛徽章:
0
6 [报告]
发表于 2004-06-24 19:00 |只看该作者

一ejb客户端运行时出现问题,请指点迷津[已结]

我反编译了CabinEJB_o1ckw5__WebLogic_CMP_RDBMS.class类文件,
发现有两个参数
weblogic.ejb20.cmp.rdbms.codegen.debug
weblogic.ejb20.cmp.rdbms.codegen.verbose
设为true,在webligic服务端可以看到一些跟踪信息:

  1. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : __WL_superEjbStore 1
  2. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=1
  3. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value :1
  4. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=1, executeQuery:
  5. SELECT WL0.BED_COUNT, WL0.DECK_LEVEL, WL0.NAME, WL0.NO, WL0.SHIP_ID  FROM CABIN
  6. WL0  WHERE WL0.NO = ?
  7. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=1 now read column
  8. s from Results.
  9. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : __WL_superEjbStore 1
  10. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=1
  11. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value :1
  12. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=1, executeQuery:
  13. SELECT WL0.BED_COUNT, WL0.DECK_LEVEL, WL0.NAME, WL0.NO, WL0.SHIP_ID  FROM CABIN
  14. WL0  WHERE WL0.NO = ?
  15. [CabinEJB_o1ckw5__WebLogic_CMP_RDBMS] : wrapping Exception in PersistenceRuntime
  16. Exception.
  17. java.sql.SQLException: [BEA][Informix JDBC Driver][Informix]System error - inval
  18. id statement id received by the sqlexec process.
  19.         at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
  20.         at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
  21.         at weblogic.jdbc.informix.sqli.InformixSQLIRequest.processReply(Unknown
  22. Source)
  23.         at weblogic.jdbc.informix.sqli.InformixSQLICursorRequest.openPreparedCur
  24. sor(Unknown Source)
复制代码
很明显的,第一个get方法执行成功,到第二个是就报错了。
我详细查了informix的错误说明,解释说:

  1. The current statement (EXECUTE or OPEN) refers to a prepared SQL
  2. statement or a cursor that does not exist. Possibly the statement id is invalid, or possibly the statement was prepared and then released with the FREE statement. Review the program logic to make sure that the statement or cursor that is named in this statement is valid, has been properly prepared or declared, and has not been freed prior to this point.

  3. If the program executes a prepared DATABASE statement successfully, the database server automatically frees the prepared statement. As a
  4. result, if you free a prepared DATABASE statement, you will receive
  5. this error on the FREE statement. You can ignore it in this case.
复制代码

难道执行了第一个get方法之后就将prepare 语句释放了吗?


我试一试access数据库再说吧。

论坛徽章:
0
7 [报告]
发表于 2004-06-30 10:42 |只看该作者

一ejb客户端运行时出现问题,请指点迷津[已结]

终于解决了。
但是可惜的是,没有从根本上解决此问题,我只是将weblogic8.1卸载了,
重新安装了weblogic7.0。
不过,在建立新的JDBC连接池的时候颇费周折。

但总算是解决了,生活可以继续了。

论坛徽章:
0
8 [报告]
发表于 2004-06-30 15:52 |只看该作者

一ejb客户端运行时出现问题,请指点迷津[已结]

虽然解决了,老觉得不爽。
反复思考,看前后的变化。
想起了JDBC驱动程序......

weblogic8.1 配置服务器时的JDBC Connection的驱动程序是从列表中选取的
weblogic.jdbcx.informix.InformixDataSource。配置时测试是成功的。
weblogic7.0配置服务器时的JDBC Connection的驱动程序是要自己手写的,我想用原来那个,可惜路径里找不到,只好到informix公司网站上下了一个,不支持事务。

所以我想不是weblogic的问题,而是JDBC驱动程序的问题!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP