Vaadin with Grails Database error - java

I am using vaadin7 with grails i have created model and service and trying to access it when click on login button to check login details.
I search a lot but no relevant result, i am new to grails framework.
i am getting below error when trying to access service class:-
java.lang.NullPointerException
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.codehaus.groovy.grails.orm.support.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:85)
at com.xfuel.web.services.PeopleService.checkLogin(PeopleService.groovy)
at com.xfuel.web.services.PeopleService$checkLogin.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at test.Test$2.buttonClick(Test.groovy:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:984)
at com.vaadin.ui.Button.fireClick(Button.java:393)
at com.vaadin.ui.Button$1.click(Button.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
My Vaadincode is below :-
class Test extends UI {
public Test() {
// TODO Auto-generated constructor stub
}
#Override
protected void init(VaadinRequest request) {
HorizontalLayout fields = new HorizontalLayout();
fields.setSpacing(true);
fields.setMargin(true);
fields.addStyleName("fields");
final TextField username = new TextField("Username");
username.focus();
fields.addComponent(username);
final PasswordField password = new PasswordField("Password");
fields.addComponent(password);
final Button signin = new Button("Sign In");
signin.addStyleName("default");
fields.addComponent(signin);
fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);
final ShortcutListener enter = new ShortcutListener("Sign In",
KeyCode.ENTER, null) {
#Override
public void handleAction(Object sender, Object target) {
signin.click();
}
};
signin.addClickListener(new ClickListener() {
#Override
public void buttonClick(ClickEvent event) {
if (username.getValue() != null
&& username.getValue().equals("")
&& password.getValue() != null
&& password.getValue().equals("")) {
signin.removeShortcutListener(enter);
PeopleService p1 = new PeopleService();
p1.checkLogin("", "");
// iPeopleService.checkLogin(username.getValue(), password.getValue());
buildMainView();
} else {
}
}
});
signin.addShortcutListener(enter);
setContent(fields);
}
}
And domain class :-
class People {
String name;
String apppassword;
static constraints = {
}
}
and Grails services code :-
#Transactional
class PeopleService {
def serviceMethod() {
}
public People checkLogin(String username, String password) {
def query = People.where{
peopleID == username &&
apppassword == password &&
visible == true
}
return people = query.find()
}
i below is the datasource :-
development {
dataSource {
driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://localhost/sample"
username = "root"
password = "root"
loggingSql = true
}
}
i did not understand the reason of this error. Can someone please help me?
Thanks

Related

Failed to create the part's controls: StructuredTextEditor

I am trying to get hold of XML editor for my RCP application. My simple aim is to show SCXML files with source and design. I tried few ways and nothing seems working.
Right now I am trying to run below approach
https://github.com/Pontesegger/codeandme/blob/master/Code%20%26%20Me%20Blog/form_editor_with_xml_source_view.zip
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.IFormPage;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
public class SampleEditor extends FormEditor {
private StructuredTextEditor fSourceEditor;
private int fSourceEditorIndex;
/** Keeps track of dirty code from source editor. */
private boolean fSourceDirty = false;
#Override
public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
super.init(site, input);
// TODO: load your model here
}
#Override
protected void addPages() {
fSourceEditor = new StructuredTextEditor();
fSourceEditor.setEditorPart(this);
try {
// add form pages
addPage(new FirstForm(this, "firstID", "First Page"));
// add source page
fSourceEditorIndex = addPage(fSourceEditor, getEditorInput());
setPageText(fSourceEditorIndex, "Source");
} catch (final PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// add listener for changes of the document source
getDocument().addDocumentListener(new IDocumentListener() {
#Override
public void documentAboutToBeChanged(final DocumentEvent event) {
// nothing to do
}
#Override
public void documentChanged(final DocumentEvent event) {
fSourceDirty = true;
}
});
}
#Override
public void doSaveAs() {
// not allowed
}
#Override
public boolean isSaveAsAllowed() {
return false;
}
#Override
public void doSave(final IProgressMonitor monitor) {
if (getActivePage() != fSourceEditorIndex)
updateSourceFromModel();
fSourceEditor.doSave(monitor);
}
#Override
protected void pageChange(final int newPageIndex) {
// check for update from the source code
if ((getActivePage() == fSourceEditorIndex) && (fSourceDirty))
updateModelFromSource();
// check for updates to be propagated to the source code
if (newPageIndex == fSourceEditorIndex)
updateSourceFromModel();
// switch page
super.pageChange(newPageIndex);
// update page if needed
final IFormPage page = getActivePageInstance();
if (page != null) {
// TODO update form page with new model data
page.setFocus();
}
}
private void updateModelFromSource() {
// TODO update source code for source viewer using new model data
fSourceDirty = false;
}
private void updateSourceFromModel() {
// TODO update source page from model
// getDocument().set("new source code");
fSourceDirty = false;
}
private IDocument getDocument() {
final IDocumentProvider provider = fSourceEditor.getDocumentProvider();
return provider.getDocument(getEditorInput());
}
private IFile getFile() {
final IEditorInput input = getEditorInput();
if (input instanceof FileEditorInput)
return ((FileEditorInput) input).getFile();
return null;
}
private String getContent() {
return getDocument().get();
}
}
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
public class FirstForm extends FormPage {
/**
* Create the form page.
*
* #param id
* #param title
*/
public FirstForm(final String id, final String title) {
super(id, title);
}
/**
* Create the form page.
*
* #param editor
* #param id
* #param title
* #wbp.parser.constructor
* #wbp.eval.method.parameter id "Some id"
* #wbp.eval.method.parameter title "Some title"
*/
public FirstForm(final FormEditor editor, final String id, final String title) {
super(editor, id, title);
}
/**
* Create contents of the form.
*
* #param managedForm
*/
#Override
protected void createFormContent(final IManagedForm managedForm) {
final FormToolkit toolkit = managedForm.getToolkit();
final ScrolledForm form = managedForm.getForm();
form.setText("First Editor Page");
final Composite body = form.getBody();
toolkit.decorateFormHeading(form.getForm());
toolkit.paintBordersFor(body);
}
}
Plugin.xml
<editor
class="generic.layer.editor.v2.SampleEditor"
default="false"
id="generic.layer.editor.v2.editor1"
name="name">
<contentTypeBinding
contentTypeId="generic.layer.editor.v2.content-type1">
</contentTypeBinding>
</editor>
</extension>
<extension
point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"
file-extensions="scxml"
id="generic.layer.editor.v2.content-type1"
name="name"
priority="normal">
</content-type>
And call to the editor from my view
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IStorage storage = new StringStorage((String)o);
IStorageEditorInput input = new StringInput(storage);
try {
page.openEditor(input, "generic.layer.editor.v2.editor1");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
This is the error I am getting right now
!ENTRY org.eclipse.e4.ui.workbench 4 0 2019-09-27 15:56:32.129
!MESSAGE
!STACK 0
java.lang.NullPointerException
at org.eclipse.wst.sse.ui.StructuredTextEditor.createCombinedPreferenceStore(StructuredTextEditor.java:1521)
at org.eclipse.wst.sse.ui.StructuredTextEditor.initializeEditor(StructuredTextEditor.java:2768)
at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.<init>(AbstractDecoratedTextEditor.java:344)
at org.eclipse.ui.editors.text.TextEditor.<init>(TextEditor.java:59)
at org.eclipse.wst.sse.ui.StructuredTextEditor.<init>(StructuredTextEditor.java:1151)
at generic.layer.editor.v2.SampleEditor.addPages(SampleEditor.java:34)
at org.eclipse.ui.forms.editor.FormEditor.createPages(FormEditor.java:140)
at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:348)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:151)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:99)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:355)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:990)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:955)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:124)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:399)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:318)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:105)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:74)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:56)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:992)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:661)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:767)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:738)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:732)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:716)
at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1293)
at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.lambda$0(LazyStackRenderer.java:68)
at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:233)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:144)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4889)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:212)
at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:36)
at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:201)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:52)
at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:60)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:173)
at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:620)
at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:584)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:769)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:401)
at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1188)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3261)
at org.eclipse.ui.internal.WorkbenchPage.access$25(WorkbenchPage.java:3176)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:3158)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3153)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3117)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3098)
at generic.layer.editor.v2.SCXMLView$1$1.run(SCXMLView.java:118)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4213)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3820)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:680)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at generic.layer.editor.v2.Application.start(Application.java:21)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
at org.eclipse.equinox.launcher.Main.main(Main.java:1472)
Sep 27, 2019 3:56:32 PM generic.layer.editor.v2.PropertyView$2$1 run
INFO: Receiving event for transformation propoerties:

java.lang.reflect.InvocationTargetException JavaFX TableView

I've encountered this problem while trying to use cellData -> cellData.getValue() to add an attribute from an object, the attribute is a StringProperty and i have a method to return it, and i'm using it in the cellData -> cellData.getValue().methodtoreturnproperty, but it's still giving me java.lang.reflect.InvocationTargetException, does anyone know what i'm doing wrong?
Here's the code:
package projeto.resources;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import projeto.Filmes;
import projeto.MainApp;
import projeto.Sala;
public class FilmeOverviewController {
#FXML
private TableView<Filmes> filmeTable;
#FXML
private TableColumn<Filmes, String> nomeColumn;
#FXML
private TableColumn<Filmes, String> categoriaColumn;
#FXML
private TableColumn<Filmes, String> salaColumn;
#FXML
private Label nomeLabel;
#FXML
private Label salaLabel;
#FXML
private Label categoriaLabel;
#FXML
private Label diretorLabel;
#FXML
private Label duracaoLabel;
#FXML
private Label protagonistaLabel;
#FXML
private Label classificacaoLabel;
// Reference to the main application.
private MainApp mainApp;
public FilmeOverviewController() {
}
#FXML
private void initialize() {
//Inicia a tableview com tres colunas.
nomeColumn.setCellValueFactory(cellData -> cellData.getValue().nomeProperty());
categoriaColumn.setCellValueFactory(cellData -> cellData.getValue().categoriaProperty());
salaColumn.setCellValueFactory(cellData -> cellData.getValue().numeroProperty());
// limpando os detalhes
showFilmeDetails(null);
// adicionando funcao
filmeTable.getSelectionModel().selectedItemProperty()
.addListener((observable, oldValue, newValue) -> showFilmeDetails(newValue));
}
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
//adiciona uma observable list
filmeTable.setItems(mainApp.getfilmeDados());
}
private void showFilmeDetails(Filmes filme) {
if (filme != null) {
nomeLabel.setText(filme.getNome());
categoriaLabel.setText(filme.getCategoria());
duracaoLabel.setText(filme.getDuracao());
protagonistaLabel.setText(filme.getProtagonista());
classificacaoLabel.setText(filme.getClassificacao());
diretorLabel.setText(filme.getDiretor());
salaLabel.setText(filme.getSalaN());
} else {
nomeLabel.setText("");
categoriaLabel.setText("");
duracaoLabel.setText("");
protagonistaLabel.setText("");
classificacaoLabel.setText("");
diretorLabel.setText("");
salaLabel.setText("");
}
}
#FXML
private void handleDeletarFilme() {
int selectedIndex = filmeTable.getSelectionModel().getSelectedIndex();
if (selectedIndex >= 0) {
filmeTable.getItems().remove(selectedIndex);
} else {
Alert alerta = new Alert(AlertType.WARNING);
alerta.setTitle("Nenhum filme selecionado");
alerta.setHeaderText("Nenhuma Selecao");
alerta.setContentText("Por favor selecione um filme para deletar");
alerta.showAndWait();
}
}
#FXML
private void handleNovoFilme() {
Filmes tempFilme = new Filmes("Nome","Categoria");
boolean clicado = mainApp.showEditarFilmeDialog(tempFilme);
if (clicado) {
mainApp.getfilmeDados().add(tempFilme);
}
}
#FXML
private void handleEditarFilme() {
Filmes filmeSelecionado = filmeTable.getSelectionModel().getSelectedItem();
if(filmeSelecionado != null) {
boolean clicado = mainApp.showEditarFilmeDialog(filmeSelecionado);
if(clicado) {
showFilmeDetails(filmeSelecionado);
}
}else {
//se nada for selecionado
Alert alerta = new Alert(AlertType.WARNING);
alerta.initOwner(mainApp.getPrimaryStage());
alerta.setTitle("Nenhuma selecao");
alerta.setHeaderText("Nenhum filme selecionado");
alerta.setContentText("Por favor selecione algum filme.");
alerta.showAndWait();
}
}
}
There's a class called Sala, that's being imported into this controller, i could make it work with another class called Filmes, i don't know exactly why it's not working with the class Sala, here's the code in the class:
package projeto;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class Sala {
private boolean e3d;
private int assentosMax;
private int assentosDisp;
private final StringProperty numeroProperty = new SimpleStringProperty();
public Sala(boolean e3d, int assentosMax, int assentosDisp, String numero) {
setNumero(numero);
e3d = this.e3d;
assentosMax = this.assentosMax;
assentosDisp = this.assentosDisp;
}
public boolean isE3d() {
return e3d;
}
public void setE3d(boolean e3d) {
this.e3d = e3d;
}
public int getAssentosMax() {
return assentosMax;
}
public void setAssentosMax(int assentosMax) {
this.assentosMax = assentosMax;
}
public int getAssentosDisp() {
return assentosDisp;
}
public void setAssentosDisp(int assentosDisp) {
this.assentosDisp = assentosDisp;
}
public StringProperty numeroProperty() {
return numeroProperty;
}
public final String getNumero() {
return numeroProperty.get();
}
public final void setNumero(String numero) {
numeroProperty().set(numero);
}
}
Edit: Here's the error:
jun 07, 2018 3:18:37 PM javafx.fxml.FXMLLoader$ValueElement processValue
WARNING: Loading FXML document with JavaFX API of version 9.0.1 by JavaFX runtime of version 8.0.171
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.Error: Unresolved compilation problem:
The method numeroProperty() is undefined for the type Filmes
at projeto.resources.FilmeOverviewController.<init>(FilmeOverviewController.java:50)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at sun.reflect.misc.ReflectUtil.newInstance(ReflectUtil.java:51)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:927)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at projeto.MainApp.showFilmeOverview(MainApp.java:59)
at projeto.MainApp.start(MainApp.java:50)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Exception running application projeto.MainApp
Thanks in advance!
This looks like you are expecting one type of object in the table but providing another.
You define your table like this:
#FXML
private TableColumn<Filmes, String> salaColumn;
Your cell value factory is trying to get the following:
salaColumn.setCellValueFactory(cellData -> cellData.getValue().numeroProperty());
The numeroProperty is on the Sala object, not the Filmes Object.
Try the following (Though I am not 100% sure, since your definition of Filmes is not in the question):
salaColumn.setCellValueFactory(cellData -> cellData.getValue().getSala().numeroProperty());
Also - if there is a chance that the Sala object could be null, you'll want to check for that before trying to access the numeroProperty().

Spring Integration | DSL

I am trying to send a file to Remote SFTP server. I have created a factory and an outboundFlow for the same.
UploaderSftpConnectionFactoryBuilder
#Configuration
public class UploaderSftpConnectionFactoryBuilder {
#Value("${report-uploader.sftp-factory.host}")
private String host = null;
#Value("${report-uploader.sftp-factory.port}")
private Integer port = null;
#Value("classpath:${report-uploader.sftp-factory.privateKey}")
private Resource privateKey = null;
#Value("${report-uploader.sftp-factory.privateKeyPassphrase}")
private String privateKeyPassphrase = null;
#Value("${report-uploader.sftp-factory.maxConnections}")
private String maxConnections = null;
#Value("${report-uploader.sftp-factory.user}")
private String user = null;
#Value("${report-uploader.sftp-factory.poolSize}")
private Integer poolSize = null;
#Value("${report-uploader.sftp-factory.sessionWaitTimeout}")
private Long sessionWaitTimeout = null;
//#Bean(name = "cachedSftpSessionFactory")
public DefaultSftpSessionFactory getSftpSessionFactory() {
DefaultSftpSessionFactory defaultSftpSessionFactory = new DefaultSftpSessionFactory();
Optional.ofNullable(this.getHost()).ifPresent(value -> defaultSftpSessionFactory.setHost(value));
Optional.ofNullable(this.getPort()).ifPresent(value -> defaultSftpSessionFactory.setPort(port));
Optional.ofNullable(this.getPrivateKey()).ifPresent(
value -> defaultSftpSessionFactory.setPrivateKey(privateKey));
Optional.ofNullable(this.getPrivateKeyPassphrase()).ifPresent(
value -> defaultSftpSessionFactory.setPrivateKeyPassphrase(value));
Optional.ofNullable(this.getUser()).ifPresent(value -> defaultSftpSessionFactory.setUser(value));
return defaultSftpSessionFactory;
}
#Bean(name = "cachedSftpSessionFactory")
public CachingSessionFactory<LsEntry> getCachedSftpSessionFactory() {
CachingSessionFactory<LsEntry> cachedFtpSessionFactory = new CachingSessionFactory<LsEntry>(
getSftpSessionFactory());
cachedFtpSessionFactory.setPoolSize(poolSize);
cachedFtpSessionFactory.setSessionWaitTimeout(sessionWaitTimeout);
return cachedFtpSessionFactory;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public Resource getPrivateKey() {
return privateKey;
}
public void setPrivateKey(Resource privateKey) {
this.privateKey = privateKey;
}
public String getPrivateKeyPassphrase() {
return privateKeyPassphrase;
}
public void setPrivateKeyPassphrase(String privateKeyPassphrase) {
this.privateKeyPassphrase = privateKeyPassphrase;
}
public String getMaxConnections() {
return maxConnections;
}
public void setMaxConnections(String maxConnections) {
this.maxConnections = maxConnections;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
}
Now i want to test the outbound flow using an integration test. For that i have created below testContext:
TestContextConfiguration
#Configuration
public class TestContextConfiguration {
#Configuration
#Import({ FakeSftpServer.class, JmxAutoConfiguration.class, IntegrationAutoConfiguration.class,
UploaderSftpConnectionFactoryBuilder.class })
#IntegrationComponentScan
public static class ContextConfiguration {
#Value("${report-uploader.reportingServer.fileEncoding}")
private String fileEncoding;
#Autowired
private FakeSftpServer fakeSftpServer;
#Autowired
#Qualifier("cachedSftpSessionFactory")
//CachingSessionFactory<LsEntry> cachedSftpSessionFactory;
DefaultSftpSessionFactory cachedSftpSessionFactory;
#Bean
public IntegrationFlow sftpOutboundFlow() {
return IntegrationFlows
.from("toSftpChannel")
.handle(Sftp.outboundAdapter(this.cachedSftpSessionFactory, FileExistsMode.REPLACE)
.charset(Charset.forName(fileEncoding)).remoteFileSeparator("\\")
.remoteDirectory(this.fakeSftpServer.getTargetSftpDirectory().getPath())
.fileNameExpression("payload.getName()").autoCreateDirectory(true)
.useTemporaryFileName(true).temporaryFileSuffix(".tranferring")
).get();
}
#Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
I have also created a fake sftp server as suggested # https://github.com/spring-projects/spring-integration-java-dsl/blob/master/src/test/java/org/springframework/integration/dsl/test/sftp/TestSftpServer.java
Below is my fake server:
FakeSftpServer
#Configuration("fakeSftpServer")
public class FakeSftpServer implements InitializingBean, DisposableBean {
private final SshServer server = SshServer.setUpDefaultServer();
private final int port = SocketUtils.findAvailableTcpPort();
private final TemporaryFolder sftpFolder;
private final TemporaryFolder localFolder;
private volatile File sftpRootFolder;
private volatile File sourceSftpDirectory;
private volatile File targetSftpDirectory;
private volatile File sourceLocalDirectory;
private volatile File targetLocalDirectory;
public FakeSftpServer() {
this.sftpFolder = new TemporaryFolder() {
#Override
public void create() throws IOException {
super.create();
sftpRootFolder = this.newFolder("sftpTest");
targetSftpDirectory = new File(sftpRootFolder, "sftpTarget");
targetSftpDirectory.mkdir();
}
};
this.localFolder = new TemporaryFolder() {
#Override
public void create() throws IOException {
super.create();
File rootFolder = this.newFolder("sftpTest");
sourceLocalDirectory = new File(rootFolder, "localSource");
sourceLocalDirectory.mkdirs();
File file = new File(sourceLocalDirectory, "localSource1.txt");
file.createNewFile();
file = new File(sourceLocalDirectory, "localSource2.txt");
file.createNewFile();
File subSourceLocalDirectory = new File(sourceLocalDirectory, "subLocalSource");
subSourceLocalDirectory.mkdir();
file = new File(subSourceLocalDirectory, "subLocalSource1.txt");
file.createNewFile();
}
};
}
#Override
public void afterPropertiesSet() throws Exception {
this.sftpFolder.create();
this.localFolder.create();
this.server.setPasswordAuthenticator((username, password, session) -> true);
this.server.setPort(this.port);
this.server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("src/test/resources/hostkey.ser")));
this.server.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystemFactory()));
this.server.setFileSystemFactory(new VirtualFileSystemFactory(sftpRootFolder.toPath()));
this.server.start();
}
#Override
public void destroy() throws Exception {
this.server.stop();
this.sftpFolder.delete();
this.localFolder.delete();
}
public File getSourceLocalDirectory() {
return this.sourceLocalDirectory;
}
public File getTargetLocalDirectory() {
return this.targetLocalDirectory;
}
public String getTargetLocalDirectoryName() {
return this.targetLocalDirectory.getAbsolutePath() + File.separator;
}
public File getTargetSftpDirectory() {
return this.targetSftpDirectory;
}
public void recursiveDelete(File file) {
File[] files = file.listFiles();
if (files != null) {
for (File each : files) {
recursiveDelete(each);
}
}
if (!(file.equals(this.targetSftpDirectory) || file.equals(this.targetLocalDirectory))) {
file.delete();
}
}
}
Finally below is my test class
TestConnectionFactory
#ContextConfiguration(classes = { TestContextConfiguration.class }, initializers = {ConfigFileApplicationContextInitializer.class})
#RunWith(SpringJUnit4ClassRunner.class)
#DirtiesContext
public class TestConnectionFactory {
#Autowired
#Qualifier("cachedSftpSessionFactory")
CachingSessionFactory<LsEntry> cachedSftpSessionFactory;
//DefaultSftpSessionFactory cachedSftpSessionFactory;
#Autowired
FakeSftpServer fakeSftpServer;
#Autowired
#Qualifier("toSftpChannel")
private MessageChannel toSftpChannel;
#After
public void setupRemoteFileServers() {
this.fakeSftpServer.recursiveDelete(this.fakeSftpServer.getSourceLocalDirectory());
this.fakeSftpServer.recursiveDelete(this.fakeSftpServer.getTargetSftpDirectory());
}
#Test
public void testSftpOutboundFlow() {
boolean status = this.toSftpChannel.send(MessageBuilder.withPayload(new File(this.fakeSftpServer.getSourceLocalDirectory() + "\\" + "localSource1.txt")).build());
RemoteFileTemplate<ChannelSftp.LsEntry> template = new RemoteFileTemplate<>(this.cachedSftpSessionFactory);
ChannelSftp.LsEntry[] files = template.execute(session ->
session.list(this.fakeSftpServer.getTargetSftpDirectory() + "\\" + "localSource1.txt"));
assertEquals(1, files.length);
//assertEquals(3, files[0].getAttrs().getSize());
}
}
Now when i am running this test, I am getting the below exception:
org.springframework.messaging.MessagingException: ; nested exception is org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is java.lang.IllegalStateException: failed to create SFTP Session
at org.springframework.integration.dispatcher.AbstractDispatcher.wrapExceptionIfNecessary(AbstractDispatcher.java:133)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:120)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:286)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:245)
at com.sapient.lufthansa.reportuploader.config.TestConnectionFactory.testSftpOutboundFlow(TestConnectionFactory.java:66)
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:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
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:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is java.lang.IllegalStateException: failed to create SFTP Session
at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:345)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:211)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:201)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:193)
at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:110)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
... 36 more
Caused by: java.lang.IllegalStateException: failed to create SFTP Session
at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:355)
at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:49)
at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:334)
... 42 more
Caused by: java.lang.IllegalStateException: failed to connect
at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:272)
at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:350)
... 44 more
Caused by: com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused: connect
at com.jcraft.jsch.Util.createSocket(Util.java:349)
at com.jcraft.jsch.Session.connect(Session.java:215)
at com.jcraft.jsch.Session.connect(Session.java:183)
at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:263)
... 45 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.jcraft.jsch.Util.createSocket(Util.java:343)
... 48 more
which i am not able to resolve it and stuck on it for quite a time now. I am a beginner with spring-integration-dsl and any help woul be really appreciated.
Caused by: java.net.ConnectException: Connection refused: connect
You are connecting to the wrong port.
The test connection factory listens on a random port - you need to use the same port.

Perspective not loading in RCP when tried more than one

I am creating a RCP application. I have a view class NewView.
public class NewView extends ViewPart {
private DataBindingContext m_bindingContext;
public static final String ID = "com.app.Editor.newView";
SaveNewFileBean bean = new SaveNewFileBean();
private StyledText text;
public NewView() {
}
#Override
public void createPartControl(Composite parent) {
text = new StyledText(parent, SWT.BORDER);
m_bindingContext = initDataBindings();
}
public String returnText(){
String textData = bean.getText();
return textData;
}
#Override
public void setFocus() {
}
protected DataBindingContext initDataBindings() {
DataBindingContext bindingContext = new DataBindingContext();
//
IObservableValue observeTextTextObserveWidget = WidgetProperties.text(SWT.Modify).observe(text);
IObservableValue textBeanObserveValue = PojoProperties.value("text").observe(bean);
bindingContext.bindValue(observeTextTextObserveWidget, textBeanObserveValue, null, null);
//
return bindingContext;
}
}
When I am running the application first time, I click on New Menu and everything everything is working fine. But, When I am trying to load it again by clicking on New again, it doesn't give any error. But, it doesn't load the perspective also.
Is there some issue with my code?
Thanks!
edit: New is command. New calls a handler NewFileHandler which in turn calls NewView.java using the below code.
public class NewFileHandler extends AbstractHandler {
#Override
public Object execute(ExecutionEvent event) throws ExecutionException {
SwitchPerspectiveAction action = new SwitchPerspectiveAction();
action.run(NewFilePerspective.ID);
return null;
}
}
SwitchPerspectiveASction Class
public class SwitchPerspectiveAction extends Action {
public void run(String newPerspectiveID) {
if (PlatformUI.getWorkbench() != null) {
try {
PlatformUI.getWorkbench().showPerspective(newPerspectiveID,
PlatformUI.getWorkbench().getActiveWorkbenchWindow());
} catch (WorkbenchException e) {
e.printStackTrace();
}
}
}
}
edit:
I tried with this code.
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.showView(OpenFilePerspective.ID, "1" , IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
GIves error.
org.eclipse.ui.PartInitException: Could not create view: com.app.Editor.openFileperspective:1
at org.eclipse.ui.internal.WorkbenchPage.busyShowView(WorkbenchPage.java:1275)
at org.eclipse.ui.internal.WorkbenchPage$14.run(WorkbenchPage.java:4208)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:4204)
at com.app.editor.handlers.OpenHandler.execute(OpenHandler.java:66)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
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.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:149)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:825)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:701)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$6(HandledContributionItem.java:685)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:613)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at com.app.editor.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
showPerspective doesn't do anything if the perspective is already open. You can't use this to open multiple copies of the same view.
If you just want to open a view use:
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart viewPart = page.showView("the view id");
Note that this will only show one instance of the view at a time.
To close a view use:
page.hideView(viewPart);
You can show multiple copies of a view by using a secondary id for the view:
page.showView("view id", "secondary id", IWorkbenchPage.VIEW_ACTIVATE);
The secondary id does not have to be defined anywhere. It just needs to be unique for each view you want to show.

Unable to find root cause of error (GWT-Umbrella Exception)

I'm building a login application.I'm getting Umbrella Exception everytime, after clicking the Button....unable to find the root cause. Im providing the code and the error list. Please provide me with the fix. Using GWT-RPC
CLIENT SIDE
1. VinLog.java
package com.login.vinayak.client;
import com.google.gwt.core.client.EntryPoint;
public class VinLog implements EntryPoint {
private GreetingServiceAsync GreetingService = (GreetingServiceAsync) GWT.create(GreetingService.class);
public void onModuleLoad() {
GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
public void onUncaughtException(Throwable e) {
Window.alert("uncaught: " +e.getMessage());
Window.alert("uncaught: " + e.getMessage());
String s = buildStackTrace(e, "RuntimeExceotion:\n");
Window.alert(s);
e.printStackTrace();
System.out.println(e.getCause());
}
});
RootPanel rootPanel = RootPanel.get();
SimplePanel simplePanel = new SimplePanel();
rootPanel.add(simplePanel, 0, 0);
simplePanel.setSize("450px", "19px");
Label lblLoginForm = new Label("LOGIN");
lblLoginForm.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
simplePanel.setWidget(lblLoginForm);
lblLoginForm.setSize("544px", "41px");
Label lblUserName = new Label("User Name");
rootPanel.add(lblUserName, 10, 124);
Label lblPassword = new Label("Password");
rootPanel.add(lblPassword, 10, 183);
final TextBox textBox = new TextBox();
textBox.setAlignment(TextAlignment.CENTER);
rootPanel.add(textBox, 112, 114);
textBox.setSize("139px", "18px");
final PasswordTextBox passwordTextBox = new PasswordTextBox();
rootPanel.add(passwordTextBox, 112, 173);
passwordTextBox.setSize("139px", "18px");
Button btnClickToEnter = new Button("Click to Enter");
btnClickToEnter.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String j=textBox.getText();
String k=passwordTextBox.getText();
GreetingService.loginuser(j, k, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
Window.alert("welcome");
}
public void onSuccess(String result) {
Window.alert("try again");
}
});
}
});
rootPanel.add(btnClickToEnter, 10, 229);
final ListBox comboBox = new ListBox();
comboBox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
Object ob=comboBox.getElement();
if(ob=="Guest") {
Window.alert("Username and Passowrd is: Guest007");
}
}
});
comboBox.addItem("User");
comboBox.addItem("Admin");
comboBox.addItem("Guest");
rootPanel.add(comboBox, 10, 51);
comboBox.setSize("85px", "22px");
Image image = new Image("home.gif");
rootPanel.add(image, 310, 98);
image.setSize("182px", "155px");
}
protected String buildStackTrace(Throwable t, String log) {
if (t != null) {
log += t.getClass().toString();
log += t.getMessage();
StackTraceElement[] stackTrace = t.getStackTrace();
if (stackTrace != null) {
StringBuffer trace = new StringBuffer();
for (int i = 0; i < stackTrace.length; i++) {
trace.append(stackTrace[i].getClassName() + "." + stackTrace[i].getMethodName() + "("
+ stackTrace[i].getFileName() + ":" + stackTrace[i].getLineNumber());
}
log += trace.toString();
}
Throwable cause = t.getCause();
if (cause != null && cause != t) {
log += buildStackTrace(cause, "CausedBy:\n");
}
}
return log;
}
}
2.GreetingService.java
package com.login.vinayak.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
#SuppressWarnings("unused")
public interface GreetingService extends RemoteService {
public String loginuser(String username, String password);
}
3.GreetinServiceAsync.java
package com.login.vinayak.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface GreetingServiceAsync {
public void loginuser(String username, String password, AsyncCallback<String> callback);
}
SERVER SIDE ==> GreetingServiceImpl.java
package com.login.vinayak.server;
import com.login.vinayak.client.GreetingService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.sql.DriverManager;
import java.sql.ResultSet;
import com.google.gwt.dev.generator.ast.Statement;
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService{
private static final long serialVersionUID = 1L;
public String loginuser(String username,String password) {
try {
java.sql.Connection con = null;
Class.forName("org.hsqldb.jdbcDriver");
con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/", "SA", "");
Statement st=(Statement) con.createStatement();
ResultSet rs=((java.sql.Statement) st).executeQuery("select username,password from lgfrm");
String user=rs.getString(1);
String pass=rs.getString(2);
boolean b1=username.equals(user);
boolean b2= password.equals(pass);
if(b1==b2==true) {
return "success";
}
}
catch (Exception ae) {}
return "Success";
}
}
web.xml
> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC
> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd">
>
> <web-app> <servlet>
> <servlet-name>GreetingServiceImpl</servlet-name>
> <servlet-class>com.login.vinayak.server.GreetingServiceImpl</servlet-class>
> </servlet> <servlet-mapping>
> <servlet-name>GreetingServiceImpl</servlet-name>
> <url-pattern>/Login</url-pattern> </servlet-mapping> <!-- Default page to serve --> <welcome-file-list>
> <welcome-file>VinLog.html</welcome-file> </welcome-file-list>
>
> </web-app>
ERROR LIST
com.google.gwt.event.shared.UmbrellaException: One or more exceptions
caught, see full set in UmbrellaException#getCauses at
com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
at
com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
at
com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307) at
sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at
com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213) at
sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
**********ADDITIONAL ERROR-CAUSE LIST**********
Caused by:
com.google.gwt.user.client.rpc.ServiceDefTarget$NoServiceEntryPointSpecifiedException:
Service implementation URL not specified at
com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doPrepareRequestBuilderImpl(RemoteServiceProxy.java:430)
at
com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doInvoke(RemoteServiceProxy.java:368)
at
com.google.gwt.user.client.rpc.impl.RemoteServiceProxy$ServiceHelper.finish(RemoteServiceProxy.java:74)
at
com.login.vinayak.client.GreetingService_Proxy.loginuser(GreetingService_Proxy.java:34)
at com.login.vinayak.client.VinLog$2.onClick(VinLog.java:82) at
com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54)
at
com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1) at
com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
at
com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
at
com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
at
com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
KINDLY PROVIDE ME WITH THE FIX...TY
...And there you have it: Service implementation URL not specified...
You need to somehow tell GWT where on the backend the RPC call should go. You may do that with the annotation #RemoteServiceRelativePath on the service interface or programmatically on the ServiceDefTarget instance (which is effectively your async service instance).
Cheers,

Categories