when i am using this code it gives error [duplicate]
Possible Duplicate:
when i am using this code it gives error
public class SharedContactServiceImpl extends RemoteServiceServlet implements
SharedContactService {
/**
*
*/
private static final long serialVersionUID = 1L;
public ContactEntry createContact()throws IllegalArgumentException {
// Create the entry to insert
ContactsService myService = new ContactsService("exampleCo-exampleApp-1");
try {
myService.setUserCredentials("abc@in.gappsdemo.in", "xyz@123");
} catch (AuthenticationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String name = "nehaContact";
String notes = "this is some notes from gdata API client";
ContactEntry contact = new ContactEntry();
contact.setTitle(new PlainTextConstruct(name));
contact.setContent(new PlainTextConstruct(notes));
Email primaryMail = new Email();
primaryMail.setAddress("demo@in.gappsdemo.in");
primaryMail.setRel("http://schemas.google.com/g/2005#home");
primaryMail.setPrimary(true);
contact.addEmailAddress(primaryMail);
Email secondaryMail = new Email();
secondaryMail.setAddress("demo@in.gappsdemo.in");
secondaryMail.setRel("http://schemas.google.com/g/2005#work");
secondaryMail.setPrimary(false);
contact.addEmailAddress(secondaryMail);
ExtendedProperty favouriteFlower = new ExtendedProperty();
favouriteFlower.setName("favourite flower");
favouriteFlower.setValue("daisy");
contact.addExtendedProperty(favouriteFlower);
ExtendedProperty sportsProperty = new ExtendedProperty();
sportsPro开发者_如何学Pythonperty.setName("sports");
XmlBlob sportKinds = new XmlBlob();
sportKinds.setBlob(new String("<dance><salsa/><ballroom dancing/><dance/>"));
sportsProperty.setXmlBlob(sportKinds);
contact.addExtendedProperty(sportsProperty);
System.out.println(contact);
// Ask the service to insert the new entry
try{
System.out.println("Inside try Block:");
URL postUrl = new URL("https://www.google.com/m8/feeds/contacts/demo@in.gappsdemo.in/full");
System.out.println("Inside try Block1:");
return myService.insert(postUrl, contact);
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return contact;
}
}
I am using this code on server-side it gives error :
[ERROR] [simplerpc] - Line 9: No source code is available for type com.google.gdata.data.contacts.ContactEntry; did you forget to inherit a required module?
That error is occuring because you are using com.google.gdata.data.contacts.ContactEntry
in your client side code. (Its being returned to the client code from your service) Client side objects get compiled into Javascript by GWT. To fix it you need to tell GWT where to find all the source for objects that are converted to Javascript (all client side stuff).
To do that you need to add something like <source path='events'/>
in "YourProject.gwt.xml". Below is an example: (Using helloMVP)
1. Created new package 'events' in 'com.hellomvp' (com.hellomvp.events)
2. Added <source path='events'/>
to "HelloMVP.gwt.xml Now it looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="helloMVP">
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<inherits name="com.google.gwt.activity.Activity"/>
<inherits name="com.google.gwt.place.Place"/>
<entry-point class='com.hellomvp.client.HelloMVP'/>
<replace-with class="com.hellomvp.client.ClientFactoryImpl">
<when-type-is class="com.hellomvp.client.ClientFactory"/>
</replace-with>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
<source path='events'/>
</module>
Hope this helps.
精彩评论