Hi,

Create the factory instance at the starting of the method similar to below

public void listtest(){
MyFactory fact = GWT.*create*(MyFactory.*class*);
...

}

Use the below code

*points.add(fact.point(o).as());*
* *

*points.add(fact.point(n).as());*

instead of

*points.add(o);*
*points.add(n);*

Thanks
*Govindan*

On Wed, Apr 11, 2012 at 7:40 PM, italobb <[email protected]> wrote:

> I'm experiencing the same problem. Have you solved it? How?
>
>
>
> On Monday, October 17, 2011 4:38:53 PM UTC-2, Aidan OK wrote:
>>
>> Is anyone using AutoBean in a JRE environment successfully? When trying a
>> very simple test I get a NPE when I try to use AutoBeanCodex.encode(**
>> myAutoBean)
>>
>> My Bean interfaces look like this:
>>
>>  public static interface Point {
>> Long getX();
>> Long getY();
>>  void setX(Long x);
>> void setY(Long y);
>> }
>>  public static interface PointList  {
>> String getName();
>>  void setName(String name);
>> List<Point> getPoints();
>> void setPoints(List<Point> points);
>>  }
>>
>> I'll omit the implementations for brevity but they are just standard
>> objects with some getters/setters.
>>
>> My bean factory:
>>
>> public static interface MyFactory extends AutoBeanFactory {
>> AutoBean<Point> point();
>>  AutoBean<Point> point(Point instance);
>> AutoBean<PointList> pointList();
>>  AutoBean<PointList> pointList(PointList instance);
>> }
>>
>> I can create the AutoBean<Point> , AutoBean<PointList> ok from my
>> factory.
>> I can use AutoBeanCodex to encode a Point, and it emits the correct Json.
>>
>> If I try an encode a PointList object however, AutoBeanCodex.encode()
>> throws a NPE. Its certainly the List<Point> which is causing it, as if I
>> remove it, it works ok. And If I make PointList contain a few direct
>> references to Point beans, that also works (so if PointList has  'Point
>> getPointA()', 'Point getPointB()', it does encode everything correctly.)
>>
>> Am I missing something obvious? The code to test is below.
>>
>> public void listtest() {
>> Point o = new PointImpl();
>>  Point n = new PointImpl();
>> PointList plist = new PointListImpl();
>> List<Point> points = new ArrayList<Point>();
>>  o.setX(20L); o.setY(30L);
>> n.setY(60L); n.setX(80L);
>> points.add(o);
>>  points.add(n);
>> plist.setName("OH");
>> plist.setPoints(points);
>>  MyFactory fact = AutoBeanFactorySource.create(**MyFactory.class);
>> AutoBean<PointList> alist = fact.pointList(plist);
>>  System.out.println("Splittable Payload:" + AutoBeanCodex.encode(alist).*
>> *getPayload());
>> }
>>
>>
>> java.lang.NullPointerException
>> at com.google.web.bindery.**autobean.shared.impl.**
>> AutoBeanCodexImpl.doEncode(**AutoBeanCodexImpl.java:558)
>>  at com.google.web.bindery.**autobean.shared.impl.**
>> AutoBeanCodexImpl$ObjectCoder.**encode(AutoBeanCodexImpl.java:**321)
>> at com.google.web.bindery.**autobean.shared.impl.**AutoBeanCodexImpl$**
>> CollectionCoder.encode(**AutoBeanCodexImpl.java:163)
>>  at com.google.web.bindery.**autobean.shared.impl.**AutoBeanCodexImpl$**
>> PropertyGetter.encodeProperty(**AutoBeanCodexImpl.java:413)
>> at com.google.web.bindery.**autobean.shared.impl.**AutoBeanCodexImpl$**
>> PropertyGetter.**visitReferenceProperty(**AutoBeanCodexImpl.java:389)
>>  at com.google.web.bindery.**autobean.shared.**AutoBeanVisitor.**
>> visitCollectionProperty(**AutoBeanVisitor.java:229)
>> at com.google.web.bindery.**autobean.vm.impl.**ProxyAutoBean.**
>> traverseProperties(**ProxyAutoBean.java:300)
>>  at com.google.web.bindery.**autobean.shared.impl.**
>> AbstractAutoBean.traverse(**AbstractAutoBean.java:166)
>> at com.google.web.bindery.**autobean.shared.impl.**
>> AbstractAutoBean.accept(**AbstractAutoBean.java:101)
>>  at com.google.web.bindery.**autobean.shared.impl.**
>> AutoBeanCodexImpl.doEncode(**AutoBeanCodexImpl.java:558)
>> at com.google.web.bindery.**autobean.shared.AutoBeanCodex.**
>> encode(AutoBeanCodex.java:83)
>>  at temp.AutoBeanListTest.**listtest(AutoBeanListTest.**java:111)
>> at sun.reflect.**NativeMethodAccessorImpl.**invoke0(Native Method)
>>  at sun.reflect.**NativeMethodAccessorImpl.**invoke(Unknown Source)
>> at sun.reflect.**DelegatingMethodAccessorImpl.**invoke(Unknown Source)
>>  at java.lang.reflect.Method.**invoke(Unknown Source)
>> at org.junit.runners.model.**FrameworkMethod$1.**runReflectiveCall(**
>> FrameworkMethod.java:44)
>>  at org.junit.internal.runners.**model.ReflectiveCallable.run(**
>> ReflectiveCallable.java:15)
>> at org.junit.runners.model.**FrameworkMethod.**invokeExplosively(**
>> FrameworkMethod.java:41)
>>  at org.junit.internal.runners.**statements.InvokeMethod.**
>> evaluate(InvokeMethod.java:20)
>> at org.junit.runners.**ParentRunner.runLeaf(**ParentRunner.java:263)
>>  at org.junit.runners.**BlockJUnit4ClassRunner.**runChild(**
>> BlockJUnit4ClassRunner.java:**69)
>> at org.junit.runners.**BlockJUnit4ClassRunner.**runChild(**
>> BlockJUnit4ClassRunner.java:**48)
>>  at org.junit.runners.**ParentRunner$3.run(**ParentRunner.java:231)
>> at org.junit.runners.**ParentRunner$1.schedule(**ParentRunner.java:60)
>>  at org.junit.runners.**ParentRunner.runChildren(**ParentRunner.java:229)
>> at org.junit.runners.**ParentRunner.access$000(**ParentRunner.java:50)
>>  at org.junit.runners.**ParentRunner$2.evaluate(**ParentRunner.java:222)
>> at org.junit.runners.**ParentRunner.run(ParentRunner.**java:292)
>>  at org.eclipse.jdt.internal.**junit4.runner.**JUnit4TestReference.run(**
>> JUnit4TestReference.java:50)
>> at org.eclipse.jdt.internal.**junit.runner.TestExecution.**
>> run(TestExecution.java:38)
>>  at org.eclipse.jdt.internal.**junit.runner.RemoteTestRunner.**
>> runTests(RemoteTestRunner.**java:467)
>> at org.eclipse.jdt.internal.**junit.runner.RemoteTestRunner.**
>> runTests(RemoteTestRunner.**java:683)
>>  at org.eclipse.jdt.internal.**junit.runner.RemoteTestRunner.**
>> run(RemoteTestRunner.java:390)
>> at org.eclipse.jdt.internal.**junit.runner.RemoteTestRunner.**
>> main(RemoteTestRunner.java:**197)
>>
>>
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/YcbECPWd-v4J.
>
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to