How to properly access fields from GenericEntity

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to properly access fields from GenericEntity

John Martin
I'm trying to integrate another system with ofBiz using a few RMI
calls.  Not being familiar with the ofBiz objects, I've gotten a
little stuck.

I'm calling the userLogin service and get back in the Map, a
[GenericEntity:UserLogin].  I cast the object back into a
GenericEntity and attempt to get various fields out but the system
bombs. Here's my code:

...
RemoteDispatcher rd.Naming.lookup(RMI_URL);
...
Map context = new HashMap();
context.put("login.username", username);
context.put("login.password", password);
Map result = rd.runSync("userLogin", context);
GenericEntity ge = (GenericEntity) result.get("userLogin");
// The object looks good in the debugger at this point, I can see the
key/value pairs

String userId =  ge.getString("userLoginId");
// This is where I try and access a field but it blows up.

What is the proper way to access the values from the GenericEntity?

Thanks,

John
Reply | Threaded
Open this post in threaded view
|

Re: How to properly access fields from GenericEntity

Jacopo Cappellato
Hi John,

John Martin wrote:

> I'm trying to integrate another system with ofBiz using a few RMI
> calls.  Not being familiar with the ofBiz objects, I've gotten a
> little stuck.
>
> I'm calling the userLogin service and get back in the Map, a
> [GenericEntity:UserLogin].  I cast the object back into a
> GenericEntity and attempt to get various fields out but the system
> bombs. Here's my code:
>
> ...
> RemoteDispatcher rd.Naming.lookup(RMI_URL);
> ...
> Map context = new HashMap();
> context.put("login.username", username);
> context.put("login.password", password);
> Map result = rd.runSync("userLogin", context);
> GenericEntity ge = (GenericEntity) result.get("userLogin");
> // The object looks good in the debugger at this point, I can see the
> key/value pairs
>

The above line should be:

GenericValue ge = (GenericValue) result.get("userLogin");

The GenericEntity class models the entity definitions, while the
GenericValue class models the records in the entity.

Jacopo

> String userId =  ge.getString("userLoginId");
> // This is where I try and access a field but it blows up.
>
> What is the proper way to access the values from the GenericEntity?
>
> Thanks,
>
> John

Reply | Threaded
Open this post in threaded view
|

RE: How to properly access fields from GenericEntity

Raj-18
U CAN CONVERT INTo MAP USING getallfields() method and then u can use.i need
some help on how to see GenericEntity in eclipse debug mode .i can't able to
do.i think ,I miss some classpath in eclipse

-----Original Message-----
From: Jacopo Cappellato [mailto:[hidden email]]
Sent: Wednesday, August 09, 2006 10:18 AM
To: [hidden email]
Subject: Re: How to properly access fields from GenericEntity

Hi John,

John Martin wrote:

> I'm trying to integrate another system with ofBiz using a few RMI
> calls.  Not being familiar with the ofBiz objects, I've gotten a
> little stuck.
>
> I'm calling the userLogin service and get back in the Map, a
> [GenericEntity:UserLogin].  I cast the object back into a
> GenericEntity and attempt to get various fields out but the system
> bombs. Here's my code:
>
> ...
> RemoteDispatcher rd.Naming.lookup(RMI_URL);
> ...
> Map context = new HashMap();
> context.put("login.username", username);
> context.put("login.password", password);
> Map result = rd.runSync("userLogin", context);
> GenericEntity ge = (GenericEntity) result.get("userLogin");
> // The object looks good in the debugger at this point, I can see the
> key/value pairs
>

The above line should be:

GenericValue ge = (GenericValue) result.get("userLogin");

The GenericEntity class models the entity definitions, while the
GenericValue class models the records in the entity.

Jacopo

> String userId =  ge.getString("userLoginId");
> // This is where I try and access a field but it blows up.
>
> What is the proper way to access the values from the GenericEntity?
>
> Thanks,
>
> John


Reply | Threaded
Open this post in threaded view
|

Re: How to properly access fields from GenericEntity

John Martin
In reply to this post by Jacopo Cappellato
Hi Jacopo,

I ended up adding the entity source to my client app so I could walk
through and see the problem.  I've narrowed it down to the
GenericEntity is attempting to access a delegator (default) from the
pool but the pool is empty.

try {
                        delegator = new GenericDelegator(delegatorName);
                    } catch (GenericEntityException e) {
                        Debug.logError(e, "Error creating delegator", module);
                    }
Reply | Threaded
Open this post in threaded view
|

Re: How to properly access fields from GenericEntity

John Martin
On 8/9/06, John Martin <[hidden email]> wrote:

> Hi Jacopo,
>
> I ended up adding the entity source to my client app so I could walk
> through and see the problem.  I've narrowed it down to the
> GenericEntity is attempting to access a delegator (default) from the
> pool but the pool is empty.
>
> try {
>                         delegator = new GenericDelegator(delegatorName);
>                     } catch (GenericEntityException e) {
>                         Debug.logError(e, "Error creating delegator", module);
>                     }
>
sorry - Gmail can send emails before you want...

Being that this is a remote client attempting to access an object
passed over the wire, my thought is that something in the entity
classes was not properly initialized.  Any thoughts?

Thanks,

John
Reply | Threaded
Open this post in threaded view
|

Re: How to properly access fields from GenericEntity

John Martin
In reply to this post by Raj-18
Hey Raj,

Thanks for the getAllFields() call, that worked.  It would be nice to
figure out what the delegator initialization issue was though.

John

On 8/8/06, Raj <[hidden email]> wrote:

> U CAN CONVERT INTo MAP USING getallfields() method and then u can use.i need
> some help on how to see GenericEntity in eclipse debug mode .i can't able to
> do.i think ,I miss some classpath in eclipse
>
> -----Original Message-----
> From: Jacopo Cappellato [mailto:[hidden email]]
> Sent: Wednesday, August 09, 2006 10:18 AM
> To: [hidden email]
> Subject: Re: How to properly access fields from GenericEntity
>
> Hi John,
>
> John Martin wrote:
> > I'm trying to integrate another system with ofBiz using a few RMI
> > calls.  Not being familiar with the ofBiz objects, I've gotten a
> > little stuck.
> >
> > I'm calling the userLogin service and get back in the Map, a
> > [GenericEntity:UserLogin].  I cast the object back into a
> > GenericEntity and attempt to get various fields out but the system
> > bombs. Here's my code:
> >
> > ...
> > RemoteDispatcher rd.Naming.lookup(RMI_URL);
> > ...
> > Map context = new HashMap();
> > context.put("login.username", username);
> > context.put("login.password", password);
> > Map result = rd.runSync("userLogin", context);
> > GenericEntity ge = (GenericEntity) result.get("userLogin");
> > // The object looks good in the debugger at this point, I can see the
> > key/value pairs
> >
>
> The above line should be:
>
> GenericValue ge = (GenericValue) result.get("userLogin");
>
> The GenericEntity class models the entity definitions, while the
> GenericValue class models the records in the entity.
>
> Jacopo
>
> > String userId =  ge.getString("userLoginId");
> > // This is where I try and access a field but it blows up.
> >
> > What is the proper way to access the values from the GenericEntity?
> >
> > Thanks,
> >
> > John
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to properly access fields from GenericEntity

cjhowe
The delegatorName variable is assigned in the web.xml
file for each webapp.  Out of the box all of the
delegatorName variables = "default" which is calling
the definition from
/framework/entity/config/entityengine.xml <deleagotor
name="default" ...>

So in short, call the same method but set String
delegatorName = (String) "default";

--- John Martin <[hidden email]> wrote:

> Hey Raj,
>
> Thanks for the getAllFields() call, that worked.  It
> would be nice to
> figure out what the delegator initialization issue
> was though.
>
> John
>
> On 8/8/06, Raj <[hidden email]>
> wrote:
> > U CAN CONVERT INTo MAP USING getallfields() method
> and then u can use.i need
> > some help on how to see GenericEntity in eclipse
> debug mode .i can't able to
> > do.i think ,I miss some classpath in eclipse
> >
> > -----Original Message-----
> > From: Jacopo Cappellato [mailto:[hidden email]]
> > Sent: Wednesday, August 09, 2006 10:18 AM
> > To: [hidden email]
> > Subject: Re: How to properly access fields from
> GenericEntity
> >
> > Hi John,
> >
> > John Martin wrote:
> > > I'm trying to integrate another system with
> ofBiz using a few RMI
> > > calls.  Not being familiar with the ofBiz
> objects, I've gotten a
> > > little stuck.
> > >
> > > I'm calling the userLogin service and get back
> in the Map, a
> > > [GenericEntity:UserLogin].  I cast the object
> back into a
> > > GenericEntity and attempt to get various fields
> out but the system
> > > bombs. Here's my code:
> > >
> > > ...
> > > RemoteDispatcher rd.Naming.lookup(RMI_URL);
> > > ...
> > > Map context = new HashMap();
> > > context.put("login.username", username);
> > > context.put("login.password", password);
> > > Map result = rd.runSync("userLogin", context);
> > > GenericEntity ge = (GenericEntity)
> result.get("userLogin");
> > > // The object looks good in the debugger at this
> point, I can see the
> > > key/value pairs
> > >
> >
> > The above line should be:
> >
> > GenericValue ge = (GenericValue)
> result.get("userLogin");
> >
> > The GenericEntity class models the entity
> definitions, while the
> > GenericValue class models the records in the
> entity.
> >
> > Jacopo
> >
> > > String userId =  ge.getString("userLoginId");
> > > // This is where I try and access a field but it
> blows up.
> > >
> > > What is the proper way to access the values from
> the GenericEntity?
> > >
> > > Thanks,
> > >
> > > John
> >
> >
> >
>