今天发了一篇求助帖子,没人理啊,还是拿过来几年一下吧。举杯消愁愁更愁~~~(weblogic saf )

时间:2023-02-19 17:14:32
最近用weblogic jms功能重新实现了公司 消息与新闻。现在大部分功能已经完成并测试通过,只不过在使用存储转发来 解决 跨weblogic发消息时遇到了问题。首先我有一个测试类和测试方法,在类实现存储转发功能,没有问题,当我在自己的web工程里面调用该方法时就会出问题,当工程跑在 Tomcat ,会报找不到类:
  1. Usage: java examples.jms.queue.SAFQueueSend
  2. <Fri Mar 07 14:04:01 CST 2014> <Info> <Store> <WL-280008> <Opening the persistent file store "SAFSTORE0V" for recovery: directory=D:\SAFCONFIG\stores\default requestedWritePolicy="Direct-Write" fileLockingEnabled=true driver="NIO".> 
  3. <Fri Mar 07 14:04:02 CST 2014> <Info> <Store> <WL-280009> <The persistent file store "SAFSTORE0V" (ed7f4264-19e9-4c39-94e9-e45e0870c1df) has been opened: blockSize=512 actualWritePolicy="Direct-Write(single-handle-buffered)" explicitIOEnforced=false records=12.> 
  4. <Fri Mar 07 14:04:02 CST 2014> <Info> <Messaging> <WL-282003> <The messaging kernel ClientSAFAgent0 will use up to 22,216,704 bytes of memory before paging begins> 
  5. <Fri Mar 07 14:04:02 CST 2014> <Info> <Messaging> <WL-282001> <The messaging kernel ClientSAFAgent0 is beginning recovery of its persistent state> 
  6. <Fri Mar 07 14:04:02 CST 2014> <Info> <Messaging> <WL-282002> <The messaging kernel ClientSAFAgent0 has recovered 1 persistent messages> 
  7. <Fri Mar 07 14:04:02 CST 2014> <Info> <Messaging> <WL-282003> <The messaging kernel ClientSAFAgent0 will use up to 22,216,704 bytes of memory before paging begins> 
  8. sun.misc.Launcher$AppClassLoader@45a877
  9. java.lang.AssertionError: java.lang.ClassNotFoundException: weblogic.messaging.dispatcher.IIOPClientCrossDomainUtil
  10.         at weblogic.messaging.dispatcher.CrossDomainManager.ensureInitialized(CrossDomainManager.java:39)
  11.         at weblogic.messaging.dispatcher.CrossDomainManager.<clinit>(CrossDomainManager.java:17)
  12.         at weblogic.messaging.dispatcher.DispatcherManager.isLocal(DispatcherManager.java:123)
  13.         at weblogic.messaging.dispatcher.DispatcherManager.dispatcherAdd(DispatcherManager.java:219)
  14.         at weblogic.messaging.dispatcher.DispatcherManager.dispatcherCreate(DispatcherManager.java:212)
  15.         at weblogic.messaging.dispatcher.DispatcherManager.dispatcherFindOrCreate(DispatcherManager.java:68)
  16.         at weblogic.jms.dispatcher.JMSDispatcherManager.dispatcherFindOrCreate(JMSDispatcherManager.java:208)
  17.         at weblogic.jms.common.CDSLocalProxy.getRemoteDispatcher(CDSLocalProxy.java:277)
  18.         at weblogic.jms.common.CDSLocalProxy.access$100(CDSLocalProxy.java:32)
  19.         at weblogic.jms.common.CDSLocalProxy$2.run(CDSLocalProxy.java:158)
  20.         at weblogic.security.subject.SubjectProxy.doAs(SubjectProxy.java:89)
复制代码



看了weblogic报错地方的源码 ,将报错地方用到的类加载器和得到的类打印出来,发现类加载器是同一个,但是在tomcat跑起来是就提示找不到类,相当无语。。
下面是单独 运行 程序 时的结果:
Usage: java examples.jms.queue.SAFQueueSend
<Fri Mar 07 14:11:39 CST 2014> <Info> <Store> <WL-280008> <Opening the persistent file store "SAFSTORE0V" for recovery: directory=D:\SAFCONFIG\stores\default requestedWritePolicy="Direct-Write" fileLockingEnabled=true driver="NIO".> 
<Fri Mar 07 14:11:39 CST 2014> <Info> <Store> <WL-280009> <The persistent file store "SAFSTORE0V" (ed7f4264-19e9-4c39-94e9-e45e0870c1df) has been opened: blockSize=512 actualWritePolicy="Direct-Write(single-handle-buffered)" explicitIOEnforced=false records=12.> 
<Fri Mar 07 14:11:39 CST 2014> <Info> <Messaging> <WL-282003> <The messaging kernel ClientSAFAgent0 will use up to 22,216,704 bytes of memory before paging begins> 
<Fri Mar 07 14:11:39 CST 2014> <Info> <Messaging> <WL-282001> <The messaging kernel ClientSAFAgent0 is beginning recovery of its persistent state> 
<Fri Mar 07 14:11:39 CST 2014> <Info> <Messaging> <WL-282002> <The messaging kernel ClientSAFAgent0 has recovered 1 persistent messages> 
<Fri Mar 07 14:11:39 CST 2014> <Info> <Messaging> <WL-282003> <The messaging kernel ClientSAFAgent0 will use up to 22,216,704 bytes of memory before paging begins> 
sun.misc.Launcher$AppClassLoader@1372a1a
class weblogic.messaging.dispatcher.IIOPClientCrossDomainUtil

成功加载到该类,并成功与远程端点取得连接。


当考虑这个问题出在tomcat上,该用weblogic发布程序时,出现了另一个错误:
  1. Usage: java examples.jms.queue.SAFQueueSend
  2. javax.naming.NamingException: An attempt was made to create a SAF client on a WLS server [Root exception is javax.jms.JMSException: An attempt was made to create a SAF client on a WLS server]
  3.         at weblogic.jms.safclient.jndi.InitialContextFactoryImpl.getNamingException(InitialContextFactoryImpl.java:31)
  4.         at weblogic.jms.safclient.jndi.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:126)
  5.         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
复制代码


他说我试图在 服务器 上创建SAF客户端,看了一下报错的源码,有下面一段:
  1. public static ClientSAF getClientSAF(File paramFile, InputStream paramInputStream)
  2.     throws ClientSAFDuplicateException, javax.jms.JMSException
  3.   {
  4.     if (KernelStatus.isServer()) {
  5.       throw new javax.jms.JMSException("An attempt was made to create a SAF client on a WLS server");
  6.     }

  7.     if (paramInputStream == null) {
  8.       throw new javax.jms.JMSException("Must have an input stream");
  9.     }

  10.     ClientSAFImpl localClientSAFImpl = new ClientSAFImpl(paramFile, paramInputStream);

  11.     return localClientSAFImpl;
  12.   }
  13. }
复制代码


是在我得到一个SAFClient时,判断当前是不是server,是的话直接扔一个异常出去。也是相当无语。。。。。。。。。。。。



求高人用过这个功能的指点迷津,另外关于这个客户端的理解我现在也有点搞不懂了。。需要特殊的配置么?网上讲的我直接看不大懂。。下面贴一段:

服务器端组件的部署方式比较常见。客户端存根控件可以在部署时或运行时生成。要在部署时生成存根控件,请运行带有 -iiop 和 -basicClientJar 选项的 appc 以生成适合瘦客户端使用的客户端 jar。否则,WebLogicServer 将在运行时按需要生成存根控件,然后将它们提供给客户端。从客户端下载存根控件需要安装合适的安全管理器。瘦客户端提供了默认的轻型安全管理器。为了满足严格的安全要求,可以用命令行选项 -Djava.security.manager -Djava.security.policy==policyfile 安装其他安全管理器。Applet 使用不同的安全管理器,它已经允许下载存根控件。


各种名词不懂。