You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Sam Su <su...@gmail.com> on 2007/01/19 04:57:31 UTC

java.lang.IllegalArgumentException when use DataFactory.create(Class interfaceClass)

Hello, is there anyone encounter following exception which occur when
I use DataFactoy to create a DataObject:


/*************to create a DataObject**************/
User user=(User)DataFactory.INSTANCE.create(User.class);
		user.setUserId("sdo3");
		user.setPassword("sdo3");
		user.setName("sdo3");
		user.setAvailable("1");


/*************User DataObject**************/
public interface User {
	
	public String getUserId();
	public void setUserId(String userId);
	public String getPassword();
	public void setPassword(String password);
	public String getName();
	public void setName(String name);
	public String getAvailable();
	public void setAvailable(String available);

}

/************the exception thrown*****************/
java.lang.IllegalArgumentException
	at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(DataFactoryImpl.java:63)
	at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(DataFactoryImpl.java:53)
	at example.junit.UserTest.testAddUser(UserTest.java:67)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Appreciate your help in advance.

Best Regards,
Sam

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: java.lang.IllegalArgumentException when use DataFactory.create(Class interfaceClass)

Posted by kelvin goodson <ke...@gmail.com>.
Hi Sam,

have you registered your static classes to make them available to the
DataFactory?

If you are using our M2 download version of SDO then the way to do this is
to call

SDOUtil.registerStaticTypes(XXXFactory.class);

where XXXFactory is the generated class that knows how to create one of your
User data objects.

If however you are building SDO yourself from the source code in the SVN
repository,  and have generated your classes from your own build of SDO then
that way is deprecated,  and the new way to do it is ...

      HelperContext scope = HelperProvider.getDefaultContext();
      XXXFactory.INSTANCE.register(scope);

Note that you don't have to use the default helper context,  but doing so
will make your code work, becuase you are using the default DataFactory (i.e.
DataFactory.INSTANCE)

The notion of a HelperContext is a collection of helpers (XSDHelper,
XMLHelper etc) all associated with an instance of a TypeHelper,  and
therefore provides an instrument of scoping types.

Regards, Kelvin.


On 19/01/07, Sam Su <su...@gmail.com> wrote:
>
> Hello, is there anyone encounter following exception which occur when
> I use DataFactoy to create a DataObject:
>
>
> /*************to create a DataObject**************/
> User user=(User)DataFactory.INSTANCE.create(User.class);
>                 user.setUserId("sdo3");
>                 user.setPassword("sdo3");
>                 user.setName("sdo3");
>                 user.setAvailable("1");
>
>
> /*************User DataObject**************/
> public interface User {
>
>         public String getUserId();
>         public void setUserId(String userId);
>         public String getPassword();
>         public void setPassword(String password);
>         public String getName();
>         public void setName(String name);
>         public String getAvailable();
>         public void setAvailable(String available);
>
> }
>
> /************the exception thrown*****************/
> java.lang.IllegalArgumentException
>         at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(
> DataFactoryImpl.java:63)
>         at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(
> DataFactoryImpl.java:53)
>         at example.junit.UserTest.testAddUser(UserTest.java:67)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:324)
>         at junit.framework.TestCase.runTest(TestCase.java:154)
>         at junit.framework.TestCase.runBare(TestCase.java:127)
>         at junit.framework.TestResult$1.protect(TestResult.java:106)
>         at junit.framework.TestResult.runProtected(TestResult.java:124)
>         at junit.framework.TestResult.run(TestResult.java:109)
>         at junit.framework.TestCase.run(TestCase.java:118)
>         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
> (RemoteTestRunner.java:478)
>         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
> RemoteTestRunner.java:344)
>         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> RemoteTestRunner.java:196)
>
> Appreciate your help in advance.
>
> Best Regards,
> Sam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>

Re: java.lang.IllegalArgumentException when use DataFactory.create(Class interfaceClass)

Posted by kelvin goodson <ke...@gmail.com>.
Hi Sam,

have you registered your static classes to make them available to the
DataFactory?

If you are using our M2 download version of SDO then the way to do this is
to call

SDOUtil.registerStaticTypes(XXXFactory.class);

where XXXFactory is the generated class that knows how to create one of your
User data objects.

If however you are building SDO yourself from the source code in the SVN
repository,  and have generated your classes from your own build of SDO then
that way is deprecated,  and the new way to do it is ...

      HelperContext scope = HelperProvider.getDefaultContext();
      XXXFactory.INSTANCE.register(scope);

Note that you don't have to use the default helper context,  but doing so
will make your code work, becuase you are using the default DataFactory (i.e.
DataFactory.INSTANCE)

The notion of a HelperContext is a collection of helpers (XSDHelper,
XMLHelper etc) all associated with an instance of a TypeHelper,  and
therefore provides an instrument of scoping types.

Regards, Kelvin.


On 19/01/07, Sam Su <su...@gmail.com> wrote:
>
> Hello, is there anyone encounter following exception which occur when
> I use DataFactoy to create a DataObject:
>
>
> /*************to create a DataObject**************/
> User user=(User)DataFactory.INSTANCE.create(User.class);
>                 user.setUserId("sdo3");
>                 user.setPassword("sdo3");
>                 user.setName("sdo3");
>                 user.setAvailable("1");
>
>
> /*************User DataObject**************/
> public interface User {
>
>         public String getUserId();
>         public void setUserId(String userId);
>         public String getPassword();
>         public void setPassword(String password);
>         public String getName();
>         public void setName(String name);
>         public String getAvailable();
>         public void setAvailable(String available);
>
> }
>
> /************the exception thrown*****************/
> java.lang.IllegalArgumentException
>         at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(
> DataFactoryImpl.java:63)
>         at org.apache.tuscany.sdo.helper.DataFactoryImpl.create(
> DataFactoryImpl.java:53)
>         at example.junit.UserTest.testAddUser(UserTest.java:67)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:324)
>         at junit.framework.TestCase.runTest(TestCase.java:154)
>         at junit.framework.TestCase.runBare(TestCase.java:127)
>         at junit.framework.TestResult$1.protect(TestResult.java:106)
>         at junit.framework.TestResult.runProtected(TestResult.java:124)
>         at junit.framework.TestResult.run(TestResult.java:109)
>         at junit.framework.TestCase.run(TestCase.java:118)
>         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
> (RemoteTestRunner.java:478)
>         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
> RemoteTestRunner.java:344)
>         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> RemoteTestRunner.java:196)
>
> Appreciate your help in advance.
>
> Best Regards,
> Sam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>