java.lang.ClassNotFoundException: com.google.gwt.core.shared.GWTBridge

Hi everyone.
I am a begginer with Vaadin and I’m traying to do a sample project with a client-server RPC, and I’m using this wiki
https://vaadin.com/wiki/-/wiki/Main/Creating+a+simple+component
and when i execute my app it shows this exception in the UI.
Here is what i have.
UI

[code]
package com.example.documentmanager.client;

import com.vaadin.annotations.Theme;
import com.vaadin.navigator.Navigator;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.UI;

@SuppressWarnings(“serial”)
@Theme(“documentmanager”)
public class DocUI extends UI {

private static Navigator navigator;
public static final String PPAL_VIEW = "";
public static final String FILE_VIEW = "fileView";

@Override
protected void init(VaadinRequest request) {
    navigator = new Navigator(this, this);
    
    navigator.addView(PPAL_VIEW, new PrincipalView());
    navigator.addView(FILE_VIEW, new FileView());        
}

public static Navigator getAppNavigator(){
    return navigator;
}

}
[/code]Widget

[code]
package com.example.documentmanager.client;

import java.io.File;
import java.util.Locale;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.data.fieldgroup.FieldGroup;
import com.vaadin.data.util.FilesystemContainer;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.ThemeResource;
import com.vaadin.ui.Button;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings(“serial”)
public class PrincipalView extends Widget implements View {

private FilesystemContainer docs;
private Table documentList;    
private Button viewInfoButton;
private FieldGroup fileInfo;
private FormLayout fileFields;

private String[] columns = new String[]

{“Name”, “Icon”, “Size”, “Last Modified”};

public PrincipalView() {
    buildComponents();
}

private void buildComponents() {
    VerticalLayout ppalLayout = new VerticalLayout();
    docs = new FilesystemContainer(new File("C:/TEMP/javadoc/"));
    documentList = new Table();    
    viewInfoButton = new Button("File Info");
    fileFields = new FormLayout();
    fileFields.setMargin(true);
    createFileInfo();
    documentList.setContainerDataSource(docs);
    HorizontalSplitPanel split =  new HorizontalSplitPanel();
    ppalLayout.addComponent(split);
    ppalLayout.setSizeFull();
    VerticalLayout vl = new VerticalLayout();
    vl.addComponent(documentList);
    vl.addComponent(viewInfoButton);
    vl.setExpandRatio(documentList, 1);
    vl.setSizeFull();        
    
    split.addComponent(vl);
    split.addComponent(fileFields);
   
    documentList.setImmediate(true);
    documentList.setSelectable(true);
    documentList.setSizeFull();
}

private void createFileInfo(){
    fileInfo = new FieldGroup();
    for (String fieldName : columns) {
        TextField field = new TextField(fieldName);
        if (fieldName.equals("Icon")) {
            field.setConverter(new Converter<String, ThemeResource>(){
                @Override
                public ThemeResource convertToModel(String value,
                        Class<? extends ThemeResource> targetType,
                        Locale locale)
                        throws com.vaadin.data.util.converter.Converter.ConversionException {
                    return (value != null && value.length() > 0 ? new ThemeResource(value) : null);
                }
                @Override
                public String convertToPresentation(ThemeResource value,
                        Class<? extends String> targetType, Locale locale)
                        throws com.vaadin.data.util.converter.Converter.ConversionException {
                    return (value != null ? value.getResourceId() : "");
                }
                @Override
                public Class<ThemeResource> getModelType() {
                    return ThemeResource.class;
                }
                @Override
                public Class<String> getPresentationType() {
                    return String.class;
                }
            });
        }
        field.setWidth("100%");
        fileFields.addComponent(field);
        fileInfo.bind(field, fieldName);
    }
    fileInfo.setBuffered(false);
}

@Override
public void enter(ViewChangeEvent event) {
}

public Button getViewInfoButton() {
    return viewInfoButton;
}

public Table getDocumentList() {
    return documentList;
}

public FieldGroup getFileInfo() {
    return fileInfo;
}

}
[/code]ServerRpc and ServerRpcImpl

[code]
package com.example.documentmanager.shared.servicerpc;

import java.io.File;
import com.vaadin.shared.communication.ServerRpc;

public interface DocumentManagerServerRpc extends ServerRpc {
public void setFileSelectedInSession(File file);
}

package com.example.documentmanager.shared.servicerpc;

import java.io.File;

public class DocumentManagerServerRpcImpl implements DocumentManagerServerRpc {
private static final long serialVersionUID = -2746786739091368385L;

@Override
public void setFileSelectedInSession(File file) {
    System.out.println("El archivo es: " + file.getName());
}

}
[/code]Component

[code]
package com.example.documentmanager.server;

import com.example.documentmanager.shared.servicerpc.DocumentManagerServerRpc;
import com.example.documentmanager.shared.servicerpc.DocumentManagerServerRpcImpl;
import com.vaadin.ui.AbstractComponent;

public class PrincipalViewComponent extends AbstractComponent {

private static final long serialVersionUID = 2867497095079533979L;

DocumentManagerServerRpc rpc = new DocumentManagerServerRpcImpl();

public PrincipalViewComponent() {
    registerRpc(rpc);
}

}
[/code]Connector

[code]
package com.example.documentmanager.client;

import java.io.File;

import com.example.documentmanager.server.PrincipalViewComponent;
import com.example.documentmanager.shared.servicerpc.DocumentManagerServerRpc;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.shared.ui.Connect;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

@SuppressWarnings(“serial”)
@Connect(PrincipalViewComponent.class)
public class PrincipalViewConnector extends AbstractComponentConnector {

private DocumentManagerServerRpc rpc = RpcProxy.create(DocumentManagerServerRpc.class, this);

public PrincipalViewConnector() {
    bindEvents();
}

private void bindEvents() {
    getWidget().getViewInfoButton().addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            DocUI.getAppNavigator().navigateTo(DocUI.FILE_VIEW);
        }
    });
    
    getWidget().getDocumentList().addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            rpc.setFileSelectedInSession((File) event.getProperty().getValue());
        }
    });
}

@Override
public PrincipalView getWidget() {
    return (PrincipalView) super.getWidget();
}

@Override
protected Widget createWidget() {
    return GWT.create(PrincipalView.class);
}

}
[/code]Widgetset.gwt.xml

[code]

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Uncomment the following to compile the widgetset for one browser only.
  
 Multiple browsers can be specified as a comma separated list. The
 supported user agents at the moment of writing were:
 ie8,ie9,gecko1_8,safari,opera
 
 The value gecko1_8 is used for Firefox and safari is used for webkit
 based browsers including Google Chrome.
-->
<!-- <set-property name="user.agent" value="safari"/> -->

<!--
 To enable SuperDevMode, uncomment this line.
 
 See https://vaadin.com/wiki/-/wiki/Main/Using%20SuperDevMode for more
 information and instructions.
-->
<!-- <set-configuration-property name="devModeRedirectEnabled" value="true" /> -->
[/code]web.xml [code] <?xml version="1.0" encoding="UTF-8"?> DocumentManager Vaadin production mode productionMode false Document Manager com.vaadin.server.VaadinServlet Vaadin UI class to use UI com.example.documentmanager.client.DocUI Legacy mode to return the value of the property as a string from AbstractProperty.toString() legacyPropertyToString false Application widgetset widgetset com.example.documentmanager.client.DocumentManagerWidgetset Document Manager /* index.html index.htm index.jsp default.html default.htm default.jsp [/code]When I execute this i have this: [code] java.lang.ClassNotFoundException: com.google.gwt.core.shared.GWTBridge org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) org.apache.tomee.catalina.LazyStopWebappClassLoader.loadClass(LazyStopWebappClassLoader.java:109) com.google.gwt.user.client.ui.UIObject.(UIObject.java:195) com.example.documentmanager.client.DocUI.init(DocUI.java:21) com.vaadin.ui.UI.doInit(UI.java:641) com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:222) com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74) com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41) com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408) com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237) javax.servlet.http.HttpServlet.service(HttpServlet.java:728) [/code]And another question: At the wiki i said before there are a lot of comments about compiling and, as i'm using the eclipse plugin, i can not see the option to compile the application. Where is it or How can i compile with eclipse??

Thank you very much with these two questions

You seem have made quite a few mistakes when creating your widget. The main one being that you’re using Server-side vaadin classes in your client-side GWT component. If i look at it at least 90% of the class you’re using in PrincipalView are server side classes and as a result can’t be used in the widget class.
Are you sure you need a client side widget and not e.g. just a composite using CustomComponent? (Information:
https://vaadin.com/book/-/page/components.customcomponent.html
)

Thank your for your answer.
1- Wich ones are the classes form the server side?? and
2- Yes, I had a Vertical Layout but i changed it to a Widget because i couldn’t use it in my Connector (the getWidget method). So, if i change it to a VerticalLayout (or CustomComponent), how can i use it in my Connector??

Bye.

1:
All of those for example:
com.vaadin.data.fieldgroup.FieldGroup;
com.vaadin.data.util.FilesystemContainer;
com.vaadin.data.util.converter.Converter;
com.vaadin.navigator.View;
com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
com.vaadin.server.ThemeResource;
com.vaadin.ui.Button;
com.vaadin.ui.FormLayout;
com.vaadin.ui.HorizontalSplitPanel;
com.vaadin.ui.Table;
com.vaadin.ui.TextField;
com.vaadin.ui.VerticalLayout;

2:
You can’t use a VerticalLayout in a connector.
You have to understand that the standard Vaadin components like VerticalLayout, Button, Textfield, CustomComponent, … already consist out of a serverside which is the one you add to layouts (e.g. com.vaadin.ui.Button) a connector (don’t know the name exactly) and a client side (com.vaadin.client.ui.VButton i think).Why exactly do you want/need to use a connector? When you use standard Vaadin components the data is already one the server side…

Hi,
Thank you Marius for taking your time to help me. I really appreciate it.
All I wan to do is, when i click in some component in my UI (Table, Button, etc.), I want to execute a method in my server-side using AJAX or RPC calls (I guess is the same thing??).
I followed the example of the Wiki
https://vaadin.com/wiki/-/wiki/Main/Creating+a+simple+component
but it is a really simple example with a Label as a Widget (That’s why i create a Widget).
I cannot find an example using a verticalLayout or a CustomComponent.

The thing is that when using Table, Button, … and you add a Listener to them you are already on the server side.
So if you want for example execute a statement to a Database when a button is clicked you can directly do that inside the buttonclick method of the ClickListener without the use of RPC/Ajax.
The standard components already have the RPC or State handling inside them so that you don’t necessarily have to bother with it.
If you actually want/need to use RPC for…i don’t know what reason…you can create a widget but only use gwt classes.
Like using the
http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/Button.html
Button instead of the com.vaadin.ui.Button.
If you look at the tutorial on the wiki you can see that the label used in there is not a com.vaadin.ui server side Label but instead a GWT client side label.
Does this clear it up a bit?

That’s awsome.
Yes, this clear it up a lot (I guess).
I’m going to try it.
Thank you very much Marius.