Archived

This forum has been archived. Please start a new discussion on GitHub.

UnmarshalOutOfBoundsException in eclipse plugin

Hi.

I developed some ice modules.

In a common (to many others) Eclipse RCP plugin (com.egicon.ats.grid.common) I defined

GridException.ice where is defined an exception
#ifndef GRID_EXCEPTION_ICE
#define GRID_EXCEPTION_ICE
 
module com  
{ 
	module egicon 
	{ 
		module ats 
		{
			module grid
			{
				module common 
				{
					exception GridException 
					{
						string description;
						string file;
						long   line;
					};
				};
			};  
		};
	};
};

#endif 

While in another plugin (com.egicon.ats.grid.devices.plcbeckhoff) I defined some other types over a derived exception. The Ice file AtsPlcBeckhoff.ice
#ifndef ATS_PLC_BECKHOFF_ICE
#define ATS_PLC_BECKHOFF_ICE

#include <GridException.ice>

module com
{
	module egicon
	{
		module ats
		{	
			module grid 
			{
				module devices
				{
					module plcbeckhoff
					{
						exception PlcBeckhoffException extends ::com::egicon::ats::grid::common::GridException  
						{
							long plcErrorCode;
						};
						
.......			 

The client and the server share the same *.ice file.
I tried every setting (saw on this forum and read in the documentation) in my config file, but unfortunatelly I'm still getting the same UnmarshalOutOfBoundsException.
-- 10/01/12 19:21:18:882 Slicing: unknown exception type `::com::egicon::ats::grid::devices::plcbeckhoff::PlcBeckhoffException'
-- 10/01/12 19:21:18:886 Slicing: unknown exception type `::com::egicon::ats::grid::common::GridException'
Ice.UnmarshalOutOfBoundsException
    reason = "unknown exception type `::com::egicon::ats::grid::devices::plcbeckhoff::PlcBeckhoffException'"

After a day of trials I don't know what to do else. Could you please help me?

My config file is:
#
# The IceGrid locator proxy.
#
Ice.Default.Locator=AtsGrid/Locator:default -p 4061

#
# This property is used by the clients to connect to IceStorm.
#
IceStorm.TopicManager.Proxy=IceStorm/TopicManager

PlcBeckhoff.Subscriber.Endpoints=tcp

#Ice.Package.common=com.egicon.ats.grid
Ice.Default.Package=com.egicon.ats.grid.devices.common

Ice.Trace.Slicing=1


Thank you a lot in advance.

Enrico

Comments

  • mes
    mes California
    Hi Enrico,

    To unmarshal an exception, the Ice run time translates a Slice type ID (such as ::com::egicon::ats::grid::devices::plcbeckhoff::PlcBeckhoffException) into an equivalent Java class name and then attempts to dynamically load that class. If the run time states that an exception type is unknown, it means that Ice was unsuccessful in performing these steps.

    Such a situation could occur if the class is missing from your CLASSPATH. However, this is unlikely if your program contains static references to these classes, such as a catch statement like this:
    catch(com.egicon.ats.grid.devices.plcbeckhoff.PlcBeckhoffException ex)
    

    Clearly, this code could only compile and run if the generated exception classes were already present in your CLASSPATH. If your code does not contain any static references to the generated exception classes, I suggest that you carefully check the contents of your CLASSPATH to verify that these classes are present.

    Another possibility is a class loader issue. If I understand your situation correctly, you are using Ice from within an Eclipse plug-in. If that's the case, it's possible that the Ice run time is not using the correct class loader when attempting to locate the generated exception classes. You may need to supply a different class loader when initializing your communicator.

    Regards,
    Mark
  • Thank you Mess for your answer.
    If I understand your situation correctly, you are using Ice from within an Eclipse plug-in

    Yes it is correct.

    I'm tring to solve the problem but it's very diffucult.

    Building a sample (simplified respect to the original) but with the same modules relations, I stated that the problem seems to be the eclipse integration. Better, it seems to be in relation to the fact that OSGI uses differents class loaders for each plugin.

    In fact if I launch my code as JUnit (by JUnit runner) everything works fine; while if I integrate the plugin inside an eclipse application everyting stops to work.

    I don't know exactly how to work with class loader and I'm looking at this article:

    EclipseZone - Eclipse - a tale of two VMs (and many classloaders)

    I hope it will help me.

    Could you give me any more ideas ? I tried to put in classpath the generated the bin folder of all plugin that defines an Exception class, but the proble still be there.

    Thank you a lot again
  • xdm
    xdm La Coruña, Spain
    Hi,

    have you try to add the common plug-in to "Manifest > Dependencies > Required Plug-ins"
  • Hi Xdm.

    Yes I tried.

    Below is reported the "common plugin" Manifest.mf where the base exception GridException is defined
    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: Common
    Bundle-SymbolicName: com.egicon.ats.grid.common
    Bundle-Version: 1.0.0.qualifier
    Bundle-Activator: com.egicon.ats.grid.common.Activator
    Bundle-Vendor: EGICON
    Require-Bundle: org.eclipse.ui,
     org.eclipse.core.runtime,
     com.zeroc.ice;bundle-version="3.4.1"
    Bundle-RequiredExecutionEnvironment: JavaSE-1.6
    Export-Package: com.egicon.ats.grid.common
    Bundle-ClassPath: .
    

    Export-Package row, shows that the package where resides GridException generated code is exported

    The simplified plugin I've done is represented from this slice file
    #include <GridException.ice>
    module com {
    	module egicon {
    		module ats {
    			module dummymodule
    			{
    			//	exception PlcBeckhoffException extends ::com::egicon::ats::grid::common::GridException  
    			//	{
    			//		long plcErrorCode;
    			//	};
    
    				exception DummyException  extends ::com::egicon::ats::grid::common::GridException
    				{
    					long plcErrorCode;
    				};
    				
    				interface DummyInterface 
    				{ 
    					void dummyOperation()throws DummyException;
    				};
    
    			}; 
    		};
    	};
    }; 
    

    dummyOperation simply throws DummyException (that is derived from GridException)

    The dummy plugin Manifest.mf is
    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: Dummy
    Bundle-SymbolicName: com.egicon.ats.grid.devices.dummy
    Bundle-Version: 1.0.0.qualifier
    Bundle-Activator: com.egicon.ats.grid.devices.dummy.Activator
    Bundle-Vendor: EGICON
    Require-Bundle: org.eclipse.ui,
     org.eclipse.core.runtime,
     com.zeroc.ice;bundle-version="3.4.1",
     com.egicon.ats.grid.serviceconnection;bundle-version="1.0.0",
     com.egicon.ats.grid.common;bundle-version="1.0.0"
    Bundle-RequiredExecutionEnvironment: JavaSE-1.6
    Bundle-ActivationPolicy: lazy
    Export-Package: com.egicon.ats.dummymodule,
     com.egicon.ats.grid.devices.dummy
    Bundle-ClassPath: .
    

    In the Required-Bundle section com.egicon.ats.grid.common is specified.

    I'm becoming crazy
  • xdm
    xdm La Coruña, Spain
    Can you upload a small sample that reproduce your problem, it will be easy for us to look at it.
  • My last trial was a drammatically semplification of my slice file: none nested module, none derived exception but only a simple exception, none dependency from a common plugin
    			module dummymodule
    			{
    				exception DummyException 
    				{
    					string description;
    					string file;
    					long   line;
    					long plcErrorCode;
    				};
    				
    				interface DummyInterface 
    				{ 
    					void dummyOperation()throws DummyException;
    				};
    
    			};
    

    Unfortunately also this has gone bad.:(

    The sympton is ever the same: launching my test as a simple test works fine. Launch the same sample code as eclipse plugin works bad
    -- 12/01/12 03:33:40:312 Slicing: unknown exception type `::dummymodule::DummyException'
    

    Hope my last trial will help you .... to help me.

    Thank you a lot again
  • xdm wrote: »
    Can you upload a small sample that reproduce your problem, it will be easy for us to look at it.

    Ok I will prepare it. It is not immediate due to the fact that now everyting is working in an ice grid infrastructure.
  • Hi,

    I've uploaded a sample project that reproduce the problem.

    I've modified the hello example provided with Ice.
    • The server Attachment not found. is in C++ and has been modified to make sayHallo operation throw DummyException
    • Attachment not found. is the main plugin for the client. Everything happens inside the Activator.java. You can launch the plugin using hello.launch (debug as eclipse application)
    • The other plugins Attachment not found. and Attachment not found. to satisfy all dependencies
    • com.zeroc.ice.* is a plugin (splitted on more rar file to met upload dimensions requirement) that wrap all Ice jars

    Running this plugin will end throwing OutOfBundleException.

    P.S I add com.zeroc.ice.* plugin in the next post due to the limit of five files
  • Eureka!!! Problem solved

    As I exaplined we are in Eclipse-RCP plugin scenario and we have two plugin; the first wrap zeroc Ice jars, the other use it.

    To allow Ice throwing a user defined Excpetion with a correct runtime cast (avoiding UnmarshallOutOfBoundException) we used BuddyPolicy in both plugin.

    So both Manifest.MF of our plugins report the line:

    Eclipse-BuddyPolicy: registered

    I hope this help some one in the future!

    bye