【问题标题】:org.omg.CORBA.MARSHAL: Server-side Exception: nullorg.omg.CORBA.MARSHAL:服务器端异常:null
【发布时间】:2013-08-14 20:24:05
【问题描述】:

我正在尝试注册 CORBA CosNotification 服务。在我尝试连接的服务的文档中,它说我必须使用CosNotifyComm::SequencePushConsumer 对象,并将其附加到通知服务。我已经包含了我的代码,并且我正在返回错误。

AlarmClient.java

import NotificationIRPSystem.*;
import org.omg.CosNotification.*;
import org.omg.CosNotifyComm.*;
import org.omg.CosNotifyChannelAdmin.*;
import org.omg.CosNotifyFilter.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.PortableServer.*;


public class AlarmClient
{
  static _NotificationIRPOperations notiOp;
  public static void main (String args [])
  {
    try{
      org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, null);
      org.omg.CORBA.Object objRef =
        orb.resolve_initial_references ("NameService");
      System.out.println("IOR===> " + objRef);
      NamingContextExt nc = NamingContextExtHelper.narrow(objRef);
      String name = "com/ericsson/nms/cif/service/NMSNAConsumer";
      String portal = "com/ericsson/nms/cif/service/NMSNAPortal";
      org.omg.CORBA.Object notiObj = nc.resolve_str(name);
      System.out.println(nc.resolve_str(portal));
      System.out.println("noti---->" + notiObj);
      _NotificationIRPOperations tt = _NotificationIRPOperationsHelper.narrow(notiObj);

      IRPManager irpMan = new IRPManager();
      POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
      poa.the_POAManager().activate();
      org.omg.CORBA.Object objNotiServer = poa.servant_to_reference(irpMan);

      String manager_reference = orb.object_to_string(objNotiServer);
      System.out.println("MANAGER REF: " + manager_reference);
      System.out.println("OBJ NOTI SERVER: " + objNotiServer);
      int time_tick = 15;
      String filter = "";
      String[] asd = {};
      NotificationIRPConstDefs.EventTypesSetHolder e_list = new NotificationIRPConstDefs.EventTypesSetHolder();
      NotificationIRPConstDefs.ExtendedEventTypesSetHolder ex_list = new NotificationIRPConstDefs.ExtendedEventTypesSet\
Holder();
      String cats[] = tt.get_notification_categories(e_list, ex_list);
            String res = tt.attach_push(manager_reference, time_tick, asd , filter);
      //      System.out.println("SUCCESS--->" + res);
      //                  String[] ids = tt.get_subscription_ids(manager_reference);
      System.out.println("ALARMIRPOPERATIONS_----> " + tt);

     } catch (Exception e){
      System.out.println ("ERROR: " + e);
      e.printStackTrace (System.out);
    }
  }
}

IRPManager.java

import NotificationIRPSystem.*;
import org.omg.CosNotification.*;
import org.omg.CosNotifyComm.*;
import org.omg.CosNotifyChannelAdmin.*;
import org.omg.CosNotifyFilter.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.PortableServer.*;


public class IRPManager
    extends SequencePushConsumerPOA
{

    public void disconnect_sequence_push_consumer()
    {
        System.out.println("Disconnected!");
    }

    public void push_structured_events(org.omg.CosNotification.StructuredEvent[] notifications) throws org.omg.CosEvent\
Comm.Disconnected
    {
        System.out.println("Received Event");
    }

    public void offer_change(org.omg.CosNotification.EventType[] added, org.omg.CosNotification.EventType[] removed) th\
rows org.omg.CosNotifyComm.InvalidEventType
    {
        System.out.println("Offer Change!");
    }
}

输出

14-Aug-2013 3:54:02 PM org.jacorb.orb.ORBSingleton <init>
INFO: created ORBSingleton
IOR===> IOR:000000000000001D49444C3A6F6D672E6F72672F434F5242412F4F626A6563743A312E3000000000000000010000000000000040000102000000000F3137322E33302E3132302E3135380000C06600000000000B4E616D655365727669636500000000010000000000000008000000004A414300
14-Aug-2013 3:54:03 PM org.jacorb.orb.giop.ClientConnectionManager getConnection
INFO: ClientConnectionManager: created new ClientGIOPConnection to 172.30.120.158:49254 (7bea5671)

14-Aug-2013 3:54:03 PM org.jacorb.orb.iiop.ClientIIOPConnection connect
INFO: Connected to 172.30.120.158:49254 from local port 57080
14-Aug-2013 3:54:03 PM org.jacorb.orb.iiop.ClientIIOPConnection close
INFO: Client-side TCP transport to 172.30.120.158:49254 closed.
14-Aug-2013 3:54:03 PM org.jacorb.orb.giop.ClientConnectionManager getConnection
INFO: ClientConnectionManager: created new ClientGIOPConnection to 10.20.0.4:49254 (58a17083)
14-Aug-2013 3:54:03 PM org.jacorb.orb.iiop.ClientIIOPConnection connect
INFO: Connected to 10.20.0.4:49254 from local port 52574
IOR:000000000000001849444C3A506F7274616C2F53657276696365733A312E300000000001000000000000007C000102000000000A31302E32302E302E3800C27B0000002000504D43000000040000000C2F466163746F7279504F4100000000040000000000000003564953030000000500070801FF000000000000000000000800000000564953000000000100000018000000000001000100000001050100010001010900000000
noti---->IOR:000000000000004449444C3A336770707361352E6F72672F4E6F74696669636174696F6E49525053797374656D2F4E6F74696669636174696F6E4952504F7065726174696F6E733A312E3000000000010000000000000088000102000000000A31302E32302E302E3800C27B0000002C00504D43000000040000000C2F466163746F7279504F4100000000104E4D534E41436F6E73756D6572322E3300000003564953030000000500070801FF000000000000000000000800000000564953000000000100000018000000000001000100000001050100010001010900000000
14-Aug-2013 3:54:03 PM org.jacorb.poa.AOM add
INFO: oid: 00 40 46 20 4B 4D 29 05 2A 07 10 06 30 46 38 14 14 1B 48 4C .@F KM).*...0F8...HL1B                                                          .object is activated
14-Aug-2013 3:54:03 PM org.jacorb.poa.POA getImplName
INFO: Using server ID (8624227886) for transient POA
MANAGER REF: IOR:000000000000003349444C3A6F6D672E6F72672F436F734E6F74696679436F6D6D2F53657175656E636550757368436F6E73756D65723A312E300000000000010000000000000050000102000000000E3137322E31362E32342E31353200B91900000020383632343232373838362F004046204B4D29052A07100630463814141B484C1B000000010000000000000008000000004A414300
OBJ NOTI SERVER: IOR:000000000000003349444C3A6F6D672E6F72672F436F734E6F74696679436F6D6D2F53657175656E636550757368436F6E73756D65723A312E300000000000010000000000000050000102000000000E3137322E31362E32342E31353200B91900000020383632343232373838362F004046204B4D29052A07100630463814141B484C1B000000010000000000000008000000004A414300
14-Aug-2013 3:54:03 PM org.jacorb.orb.giop.ClientConnectionManager getConnection
INFO: ClientConnectionManager: created new ClientGIOPConnection to 10.20.0.8:49787 (68e6ff0d)
14-Aug-2013 3:54:03 PM org.jacorb.orb.iiop.ClientIIOPConnection connect
INFO: Connected to 10.20.0.8:49787 from local port 35910
**************************************************************************org.jacorb.orb.giop.RequestOutputStream@1be1a408
14-Aug-2013 3:54:04 PM org.jacorb.orb.iiop.ClientIIOPConnection close
INFO: Client-side TCP transport to 10.20.0.8:49787 closed.
org.omg.CORBA.MARSHAL: Server-side Exception: null
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at org.jacorb.orb.SystemExceptionHelper.read(SystemExceptionHelper.java:222)
    at org.jacorb.orb.ReplyReceiver.getReply(ReplyReceiver.java:456)
    at org.jacorb.orb.Delegate._invoke_internal(Delegate.java:1418)
    at org.jacorb.orb.Delegate.invoke_internal(Delegate.java:1187)
    at org.jacorb.orb.Delegate.invoke(Delegate.java:1175)
    at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:80)
    at NotificationIRPSystem.__NotificationIRPOperationsStub.attach_push(__NotificationIRPOperationsStub.java:288)
    at AlarmClient.main(AlarmClient.java:43)

我不太确定发生了什么。我想也许我试图编组的对象与服务器期望的不同?我希望有人可以提供帮助,如果您需要更多信息或我遗漏了什么,请告诉我。

更新 这是包含 attach_push 的 _NotificationIRPOperationsStub 代码

public java.lang.String attach_push(java.lang.String manager_reference, int time_tick, java.lang.String[] notification_category_set, java.lang.String filter) throws NotificationIRPSystem.AlreadySubscribed,NotificationIRPSystem.Attach,NotificationIRPSystem.AtLeast\
OneNotificationCategoryNotSupported,NotificationIRPSystem.ParameterNotSupported,NotificationIRPSystem.InvalidParameter
        {
                while(true)
                {
                        if(! this._is_local())
            {
                                org.omg.CORBA.portable.InputStream _is = null;
                                org.omg.CORBA.portable.OutputStream _os = null;
                                try
                                {
                                        _os = _request( "attach_push", true);
                                        java.lang.String tmpResult10 = manager_reference;
_os.write_string( tmpResult10 );
                                        _os.write_ulong(time_tick);
                                        NotificationIRPConstDefs.NotificationCategorySetHelper.write(_os,notification_category_set);
                                        java.lang.String tmpResult11 = filter;
_os.write_string( tmpResult11 );
System.out.println("**************************************************************************" + _os.toString());
                                        _is = _invoke(_os);
                                        java.lang.String _result = _is.read_string();
                                        return _result;
                                }
                                catch( org.omg.CORBA.MARSHAL m){
                                    m.printStackTrace();
                                    return m.getStackTrace().getClassName();
                                }
                                catch( org.omg.CORBA.portable.RemarshalException _rx )
                                        {
                                                continue;
                                        }
                                catch( org.omg.CORBA.portable.ApplicationException _ax )
                                {
                                        String _id = _ax.getId();
                                        try
                                        {
                                                if( _id.equals("IDL:3gppsa5.org/NotificationIRPSystem/AlreadySubscribed:1.0"))
                                                {
                                                        throw NotificationIRPSystem.AlreadySubscribedHelper.read(_ax.getInputStream());
                                                }
                                                else
                                                if( _id.equals("IDL:3gppsa5.org/NotificationIRPSystem/Attach:1.0"))
                                                {
                                                        throw NotificationIRPSystem.AttachHelper.read(_ax.getInputStream());
                                                }
                                                else
if( _id.equals("IDL:3gppsa5.org/NotificationIRPSystem/AtLeastOneNotificationCategoryNotSupported:1.0"))
                                                {
                                                        throw NotificationIRPSystem.AtLeastOneNotificationCategoryNotSupportedHelper.read(_ax.getInputStream());
                                                }
                                                else
                                                if( _id.equals("IDL:3gppsa5.org/NotificationIRPSystem/ParameterNotSupported:1.0"))
                                                {
                                                        throw NotificationIRPSystem.ParameterNotSupportedHelper.read(_ax.getInputStream());
                                                }
                                                else
                                                if( _id.equals("IDL:3gppsa5.org/NotificationIRPSystem/InvalidParameter:1.0"))
                                                {
                                                        throw NotificationIRPSystem.InvalidParameterHelper.read(_ax.getInputStream());
                                                }
                                                else{
                                                        throw new RuntimeException("Unexpected exception " + _id );
                                                }
                                        }
                                        finally
                                        {
                                                try
                                                {
                                                        _ax.getInputStream().close();
                                                }
                                                catch (java.io.IOException e)
                                                {
                                                        throw new RuntimeException("Unexpected exception " + e.toString() );
                                                }
                                        }
}
                        finally
                        {
                                if (_os != null)
                                {
                                        try
                                        {
                                                _os.close();
                                        }
                                        catch (java.io.IOException e)
                                        {
                                                throw new RuntimeException("Unexpected exception " + e.toString() );
                                        }
                                }
                                this._releaseReply(_is);
                    }
}
                else
                {
                        org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke( "attach_push", _opsClass );
                        if( _so == null )
                                continue;
                        _NotificationIRPOperationsOperations _localServant = (_NotificationIRPOperationsOperations)_so.servant;
                        java.lang.String _result;
                        try
                        {
                                _result = _localServant.attach_push(manager_reference,time_tick,notification_category_set,filter);
                                if ( _so instanceof org.omg.CORBA.portable.ServantObjectExt)
                                        ((org.omg.CORBA.portable.ServantObjectExt)_so).normalCompletion();
                                return _result;
                        }
                    catch (NotificationIRPSystem.AlreadySubscribed ex)
 {
                                if ( _so instanceof org.omg.CORBA.portable.ServantObjectExt)
                                        ((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion(ex);
                                throw ex;
                        }
                        catch (NotificationIRPSystem.Attach ex)
                        {
                                if ( _so instanceof org.omg.CORBA.portable.ServantObjectExt)
                                        ((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion(ex);
                                throw ex;
                        }
                        catch (NotificationIRPSystem.AtLeastOneNotificationCategoryNotSupported ex)
                        {
                                if ( _so instanceof org.omg.CORBA.portable.ServantObjectExt)
                                        ((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion(ex);
                                throw ex;
}
                        catch (NotificationIRPSystem.ParameterNotSupported ex)
                        {
                                if ( _so instanceof org.omg.CORBA.portable.ServantObjectExt)
                                        ((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion(ex);
                                throw ex;
                        }
                        catch (NotificationIRPSystem.InvalidParameter ex)
                        {
                                if ( _so instanceof org.omg.CORBA.portable.ServantObjectExt)
                                        ((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion(ex);
                                throw ex;
                        }
                        catch (RuntimeException re)
                        {
                                if ( _so instanceof org.omg.CORBA.portable.ServantObjectExt)
                ((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion(re);
                                throw re;
                        }
                        catch (java.lang.Error err)
                        {
                                if ( _so instanceof org.omg.CORBA.portable.ServantObjectExt)
                                        ((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion(err);
                                throw err;
                        }
                        finally
                        {
                                _servant_postinvoke(_so);
                        }
                }

                }
}

谢谢。

更新 #2

感谢 Brian 发布该版本的文档。我从那里拿了 IDL,稍作调整,我就可以用我的objNotiServer 呼叫attach_push。我的下一个问题是如何设置我的AlarmClient 以接收这些通知。我的假设是我可以打电话给orb.run(),然后当通知进来时,我会在我的 IRPManager 对象中收到它们,对吗?

【问题讨论】:

  • 你有服务器的日志文件吗?
  • 您的(通知集成参考点)IRPManager 是什么类型的?
  • @tuergeist SequencePushConsumer,这是接口文档中要求的。
  • Server.log 可用吗?会好的。否则:您能否提供有关服务器进程的任何信息?
  • _NotificationIRPOperations 我不清楚它的类型

标签: web-services marshalling corba jacorb


【解决方案1】:

CORBA::MARSHAL 异常通常由于以下原因之一发生:

  1. 客户端和服务器之间的 IDL 不匹配(导致意外的负载差异)
  2. 蹩脚的 ORB 产品不知道如何正确解组复杂但有效的负载

原因 #2 现在不太可能,因为 ORB 已经足够成熟,这种情况很少发生。只要您在本世纪构建的客户端和服务器端都使用 ORB 产品,那么您可能没问题。剩下的原因 #1。

您正在调用的方法的 IDL(我相信)来自 this document,如下所示:

interface NotificationIRPOperations {
  NotificationIRPConstDefs::SubscriptionId attach_push (
    in Object manager_reference,
    in long time_tick,
    in NotificationCategorySet notification_category_set,
    in string filter
  )
  raises (Attach, ParameterNotSupported, InvalidParameter, AlreadySubscribed,
          AtLeastOneNotificationCategoryNotSupported);

注意第一个参数,它的类型是Object。但是,在您的代码中,您传递的是一个字符串。然而,IDL 类型 Object 在 Java 中映射到 org.omg.CORBA.Object,而不是 String。我本来希望看到您将 objNotiServer 传递给此参数。

因此,要么您的 IDL 与您的服务器所期望的不匹配(很可能),要么您的 IDL 编译器没有遵循基本的 IDL 到 Java 映射规则(不太可能)。

不管怎样,那里有什么难闻的气味。我不相信 ORB 会为您隐式调用ORB.string_to_object(),因此当服务器实际上期望字符串化对象引用时,这将导致在网络上发送常规字符串。差异是微妙的,但这可能是服务器向您抛出MARSHAL 的原因。

因此,您的第一个调用端口应该是检查您用于构建客户端的 IDL 文件。确保你有你试图调用的服务器的准确和正确的 IDL。如果有任何不匹配,那么MARSHAL 异常将会发生,并且会发生很多。

【讨论】:

  • 感谢您的反馈,我会继续努力获取这些 IDL,并会及时通知你们。
  • 是的,在 ORB 上调用 run() 将阻止等待传入调用,这些调用应该被分派到您的服务对象 irpMan。你试过了吗?
  • 是的,它现在正在运行,但没有任何消息进入,但我认为这只是因为没有发出警报...我可以对当前警报进行同步调用,但还没有警报过一会儿。
  • 因此,要么在服务器上发出警报,要么编写一个简单的 CORBA 客户端,直接在 IRPManager 对象的字符串化 IOR 上使用 string_to_object() 调用您的应用程序。两者都将验证一切正常。
  • 所以服务器上出现了一些警报,但我在 IRPMananger 中没有任何反应。我认为一切都设置正确,因为我从服务器获取了订阅 ID。
【解决方案2】:

服务器端有问题,因此您收到服务器端异常。

您的 IDL 在导致此错误的服务器/客户端上不同。

您必须查看服务器的日志文件。如果您无权访问服务器,请实现自己的虚拟服务器并查看它是否有效。

关于manager_reference,通过narrow 和对_non_existent() 的调用在您自己的代码中对其进行测试。即

org.omg.CORBA.Object managerObj = orb.string_to_object(manager_reference);
IRPManager managerImpl = IRPManagerHelper.narrow(managerObj);
managerImpl._non_existent()

如果这有效,那么您的 IRPManager 仆人就有效。

顺便说一句,你有很多未使用的导入,应该重构它们。您的 IDE 会为您提供帮助。

对于Update2

Yout Alarmclient 必须实现 StructuredPushConsumer(请参阅 Initializing Corba notification service in java successfully but cannot get any events in linux but it's done in windows)并订阅通知。

但我建议提出一个新问题

【讨论】:

    【解决方案3】:

    您的代码看起来很可疑,您从未在 POA 中激活 irpMan,但您确实使用了servant_to_reference。试试下面的代码,把它当作伪代码处理,我没有测试过,我一般是用C++编程的。

       IRPManager irpMan = new IRPManager();
       POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
       poa.the_POAManager().activate();
       ObjectId id = poa.activate_object (irpMan);
       org.omg.CORBA.Object objNotiServer = poa.id_to_reference(id);
       String manager_reference = orb.object_to_string(objNotiServer);
       System.out.println("MANAGER REF: " + manager_reference);
       System.out.println("OBJ NOTI SERVER: " + objNotiServer);
       int time_tick = 15;
       String filter = "";
       String[] asd = {};
       NotificationIRPConstDefs.EventTypesSetHolder e_list = new NotificationIRPConstDefs.EventTypesSetHolder();
          NotificationIRPConstDefs.ExtendedEventTypesSetHolder ex_list = new NotificationIRPConstDefs.ExtendedEventTypesSet\
    Holder();
       String cats[] = tt.get_notification_categories(e_list, ex_list);
       String res = tt.attach_push(objNotiServer, time_tick, asd , filter);
    

    【讨论】:

    • IRPManager 被隐式​​激活。
    • 我认为@tuergeist 是对的。我尝试进行这些更改,但我得到了完全相同的错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-21
    • 1970-01-01
    • 1970-01-01
    • 2020-02-14
    • 2020-10-12
    相关资源
    最近更新 更多