I am trying to use GAE Blobstore with GWT. I have changed the sample
they have online:
http://code.google.com/appengine/docs/java/blobstore/overview.html
I replaced the jsp page with a GWT page (below). I replaced the call
to "<%= blobstoreService.createUploadUrl("/upload") %>" with a RPC
call which is initiated by "controller.getUploadURL("/index").
However I am getting the following error:

SEVERE: [1273002680440000] javax.servlet.ServletContext log:
Exception
while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method
'public abstract java.lang.String
net.compuroad.cerrado.client.data.DataAccessService.getUploadURL(java.lang.
String)'
threw an unexpected exception: java.lang.NoClassDefFoundError: com/
google/appengine/api/blobstore/BlobstoreServiceFactory
        at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:
360)
        at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
546)
        at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServi
ceServlet.java:
166)

I have installed GAE SDK 1.3.3.1. What I don't understand is why GWT
is looking for a  GAE class "BlobstoreServiceFactory" that is only
called in the server side via RPC. Any ideas will be appreciated.

Thanks,

Wilson

//GWT page to upload the images:
public class ImagePage2 extends Page {
        private String[] mediaList = {"Select
media","picture","video"};
        private FileUpload upload = null;
        private Controller controller = null;
        private static CerradoConstants constants = null;
        private  final FormPanel form = new FormPanel();
        private VerticalPanel panel = new VerticalPanel();
    private FlexTable table = new FlexTable();
    private Button btnAddImage = new Button("Add Image");
    private Button btnUpload = new Button("Upload");
    private TextBox txtPropertyID = new TextBox();
    private TextBox txtPropertyName = new TextBox();
    /**
         * Constructor
         */
        public ImagePage2(final Controller controller, final
CerradoConstants constants) {
                this.constants = constants;
                this.controller = controller;
                // Create a FormPanel and point it at a service.
                //form.setAction(GWT.getModuleBaseURL() +"Image");
            // Because we're going to add a FileUpload widget, we'll
need to set the
            // form to use the POST method, and multipart MIME
encoding.
            form.setEncoding(FormPanel.ENCODING_MULTIPART);
            form.setMethod(FormPanel.METHOD_POST);
            form.setWidget(panel);
            btnAddImage.addClickHandler( new ClickHandler(){
                        @Override
                        public void onClick(ClickEvent event) {
                                      upload = new FileUpload();
                                  upload.setName("uploadForm");
                                    upload.setSize("450px", "25px");
                                    panel.add(upload);
                        }
                });
            btnUpload.addClickHandler( new ClickHandler(){
                        @Override
                        public void onClick(ClickEvent event) {
                       /***This call initiates the RPC and generates
the error **/
                                 controller.getUploadURL("/index");
                        }
                });
           //the upload URL should come back from the RPC call
controller.getUploadURL("/index") using this listener
controller.getData().addPropertyChangeListener("uploadURL", new
PropertyChangeListener(){
                        @Override
                        public void
propertyChange(PropertyChangeEvent
event) {
                                        String path = null;
                                if (event.getNewValue()!= null){
                                        path = (String )
event.getNewValue();
                                        Window.alert("Upload URL:
"+path);
                                        form.setAction(path);
                                        form.submit();
                                }
                        }
            });
            panel.add(btnAddImage);
            panel.add(btnUpload);
            // Add an event handler to the form.
           form.addFormHandler(new FormHandler() {
              @Override
              public void onSubmit(FormSubmitEvent event) {
              }
              public void onSubmitComplete(SubmitCompleteEvent event)
{
                Window.alert(event.getResults());
              }
                @Override
                public void onSubmitComplete(FormSubmitCompleteEvent
event) {
                        // TODO Auto-generated method stub
                        Window.alert(event.getResults());
                }
            });
           // Add a 'submit' button.
            panel.add(new Button( "Submit", new ClickListener() {
              public void onClick(Widget sender) {
                form.submit();
              }
            }));
        }//end constructor
        @Override
        public void hide() {
                RootPanel.get("content").clear();
        }
        @Override
        public void propertyChange(PropertyChangeEvent event) {
                // TODO Auto-generated method stub
        }
        @Override
        public void show() {
                // TODO Auto-generated method stub
                //String text =
                String title = null;
                HTML htmlTitle = new HTML();
                if (controller.getData().getProperty() != null){
                        title = "<p class='accTitle'>Add Images to
the
Property</p>";
                        //set the value inside Name like "propertyID:
12345";
                        txtPropertyID.setName("propertyID");
                        txtPropertyName.setName("propertyName");
txtPropertyID.setText(controller.getData().getProperty().getId()+"");
txtPropertyName.setText(controller.getData().getProperty().getName());
                        txtPropertyID.setVisible(false);
                        txtPropertyName.setVisible(false);
                        panel.add(txtPropertyID);
                        panel.add(txtPropertyName);
                }
                htmlTitle.setHTML(title);
                RootPanel.get("content").clear();
                RootPanel.get("content").add(htmlTitle);
        //      RootPanel.get("content").add(description);
                RootPanel.get("content").add(form);
                Cerrado.getInstance().getTopLinks().show();
        }
        private String getUploadURL(){
                return null;
        }
}

//Client Controller class:
public class Controller {
        private CerradoData data = null;
        private  DataAccessServiceAsync service = null;
        private String source = null;
        public Controller (CerradoData data){
                this.data = data;
                this.service =  GWT.create(DataAccessService.class);
        }
//some omitted code ...
public void getUploadURL(String path) {
        AsyncCallback<String> callback = new AsyncCallback<String>()
{
             public void onFailure(Throwable caught) {
                  data.setMessage(caught.getMessage());
                 // data.firePropertyChange(null);
                 System.out.println(caught.getStackTrace());
             }
             public void onSuccess(String result) {
                  data.fireUploadURLChange(result);
                  System.out.println("upload path: "+ result);
             }
        };
    // Make the call to the  service.
    service.getUploadURL(path, callback);
}//end of getUploadURL

//RPC Server class:
public class DataAccessServiceImpl extends RemoteServiceServlet
implements DataAccessService{
        private PersistenceManager pm;
        private static DataAccessServiceImpl  instance;
        public DataAccessServiceImpl(){
                pm = PMF.get().getPersistenceManager();
                instance = this;
        }
        public static DataAccessServiceImpl getInstance(){
                if (instance == null){
                        instance = new DataAccessServiceImpl();
                }
                return instance;
        }
//some omitted code ...
 public String getUploadURL(String successPath){
            BlobstoreService service =
BlobstoreServiceFactory.getBlobstoreService();
           return  service.createUploadUrl(successPath);
}

-- 
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