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.
Related
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:
util.zip.ZipException: zip END header not found
exception when try to load javafx fxml view in java-9.
Details
My Application is a Javafx(uses fxml view) which is built and compiled using java-8(jdk-8 64-bit) and accessed as a WebStart with jre-9(64-bit).
Webpages(xhtml) are loaded and rendered in this javafx application.
Also note that
There are already two similar bugs reported (ie. JDK-8170276, JDK-8172872) and
these two bugs mentioned that the issue is not reproducible with latest java-9
but reproducible only with earlier java-9 ea build version.
But in my case, im using latest java-9(9.0.4 version) and
its always reproducible.
Problem
When i try to load fxml popup after login, get below exceptions.
java.util.zip.ZipException: zip END header not found
at java.base/java.util.zip.ZipFile$Source.zerror(Unknown Source)
at java.base/java.util.zip.ZipFile$Source.findEND(Unknown Source)
at java.base/java.util.zip.ZipFile$Source.initCEN(Unknown Source)
at java.base/java.util.zip.ZipFile$Source.<init>(Unknown Source)
at java.base/java.util.zip.ZipFile$Source.get(Unknown Source)
at java.base/java.util.zip.ZipFile.<init>(Unknown Source)
at java.base/java.util.zip.ZipFile.<init>(Unknown Source)
at java.base/java.util.jar.JarFile.<init>(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile.<init>(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile$1.run(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile$1.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source)
at java.base/sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at java.base/sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at java.base/sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at jdk.deploy#9.0.1/com.sun.deploy.net.protocol.jar.DeployURLConnection.connect(Unknown Source)
at jdk.deploy#9.0.1/com.sun.deploy.net.protocol.jar.DeployURLConnection.getInputStream(Unknown Source)
at java.base/java.net.URL.openStream(Unknown Source)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml/javafx.fxml.FXMLLoader.load(Unknown Source)
at client.FxmlWrapper.initialize(FxmlWrapper.java:57)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Suppressed: java.nio.file.NoSuchFileException: C:\Users\user\AppData\Local\Temp\jar_cache8046747560626483610.tmp
at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
at java.base/sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
at java.base/java.nio.file.Files.delete(Unknown Source)
... 22 common frames omitted
Request if anyone could help on this issue,would be grateful.
Many Thanks.
Although this is not the full code, but this is the code for showing fxml popup which throws "java.util.zip.ZipException: zip END header not found" exceptions in java-9, but in java-8 works fine.
PopupAction.java
public class PopupAction
{
public PopupAction()
{
super();
}
public void showPopup()
{
CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(
new PopupHandler(latch, "testMsg", "testTitle", "testButtonText"));
try
{
latch.await();
}
catch(InterruptedException localInterruptedException)
{
Thread.currentThread().interrupt();
}
}
}
PopupHandler.java
public class PopupHandler implements Runnable
{
private CountDownLatch latch;
private String message;
private String title;
private String buttonText;
public PopupHandler(CountDownLatch latch,
String message, String title, String buttonText)
{
this.latch = latch;
this.message = message;
this.title = title;
this.buttonText = buttonText;
}
#Override
public void run()
{
try
{
Stage stage = new Stage(StageStyle.UTILITY);
Parent root;
stage.initModality(Modality.APPLICATION_MODAL);
stage.setResizable(false);
FXMLViewLoader fXMLViewLoader = new FXMLViewLoader("/fxmlView/warningPopup.fxml");
root = fXMLViewLoader.getView();
Scene scene = new Scene(root, 400, 110);
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
stage.setResizable(false);
stage.setTitle(this.title);
stage.initOwner(Application.getOwnerWindow());
this.localAtomicBoolean.set(true);
stage.setAlwaysOnTop(true);
stage.showAndWait();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
this.latch.countDown();
}
}
}
FXMLViewLoader.java
public final class FXMLViewLoader
{
private FXMLLoader loader;
public FXMLViewLoader(String fxmlName)
{
super();
initialize(fxmlName);
}
private void initialize(String fxmlName)
{
final URL resource = getResourceURL(fxmlName);
this.loader = new FXMLLoader(resource);
try
{
this.loader.load();
}
catch(Exception e)
{
e.printStackTrace();
}
}
protected URL getResourceURL(String fxmlName)
{
return this.getClass().getResource(fxmlName);
}
public Parent getView()
{
return this.loader.getRoot();
}
}
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am quite new to Java and JUnit testing and am very confused with an error I am getting. The error, Null Pointer exception as the code below I am guessing is because something is equal to null but i am unsure why.
java.lang.NullPointerException
at com.nsa.y1.trafficlights.FourWayJunctionTest.PhaseOneInitiation(FourWayJunctionTest.java:47)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
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.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
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.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) com.nsa.y1.trafficlights.FourWayJunctionTest > PhaseOneInitiation FAILED
java.lang.NullPointerException at FourWayJunctionTest.java:47
Here is the test file:
package com.nsa.y1.trafficlights;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by c167 on 12/03/2017.
*/
public class FourWayJunctionTest {
private Light greenLight, amberLight, redLight, greenRightArrow, greenLeftArrow;
private FourLightTrafficLight turnRightTrafficLight;
boolean lightStateRed;
boolean lightStateAmber;
boolean lightStateGreen;
private TrafficLight northLeftStraight;
private FourLightTrafficLight northLeftArrow;
private FourLightTrafficLight northRightArrow;
private TrafficLight eastLeftStraight;
private TrafficLight westStraightRight;
private FourWayJunction junction = new FourWayJunction();
#Before
public void createLights() throws Exception {
greenLight = (new Light(Shape.CIRCLE, Colour.GREEN));
amberLight = (new Light(Shape.CIRCLE, Colour.AMBER));
redLight = (new Light(Shape.CIRCLE, Colour.RED));
northRightArrow = new FourLightTrafficLight();
northLeftArrow = new FourLightTrafficLight();
northLeftStraight = new TrafficLight();
eastLeftStraight = new TrafficLight();
westStraightRight = new TrafficLight();
}
#Test
public void PhaseOneInitiation() throws Exception {
createLights();
//Greenleftarrow should be on, northleft on, and eat left on. All others off.
junction.initiatePhaseOne();
assertEquals(greenLeftArrow.isOn(), true);
}
}
This is the code containing the methods:
package com.nsa.y1.trafficlights;
/**
* Created by on 13/03/2017.
*/
public class FourWayJunction extends FourLightTrafficLight{
// Evans junction recreation in cardiff
private Light greenLight, amberLight, redLight, greenRightArrow, greenLeftArrow;
private TrafficLight oppositeTrafficLight;
private FourLightTrafficLight turnRightTrafficLight;
boolean lightStateRed;
boolean lightStateAmber;
boolean lightStateGreen;
private TrafficLight northLeftStraight;
private FourLightTrafficLight northLeftArrow;
private FourLightTrafficLight northRightArrow;
private TrafficLight eastLeftStraight;
private TrafficLight westStraightRight;
public FourWayJunction() {
greenLight = (new Light(Shape.CIRCLE, Colour.GREEN));
amberLight = (new Light(Shape.CIRCLE, Colour.AMBER));
redLight = (new Light(Shape.CIRCLE, Colour.RED));
northRightArrow = new FourLightTrafficLight();
northLeftArrow = new FourLightTrafficLight();
northLeftStraight = new TrafficLight();
eastLeftStraight = new TrafficLight();
westStraightRight = new TrafficLight();
}
public void initiatePhaseOne() {
// Left arrow for buses and taxis on, north green light for left on but no right arrow.
// Also green light on for the East Traffic light.
// All others off.
westStraightRight.getRedLight().turnOn();
northRightArrow.getGreenLight().turnOff();
if (westStraightRight.getRedLight().isOn() && !northRightArrow.getGreenLight().isOn()){
northLeftArrow.getGreenLight().turnOn();
northLeftStraight.setTrafficLightOn(northLeftStraight);
eastLeftStraight.setTrafficLightOn(eastLeftStraight);
}
else {
System.out.println("Problems, traffic wil collide");
westStraightRight.setTrafficLightOff(westStraightRight);
northRightArrow.getGreenLight().turnOff();
}
}
public void initiatePhaseTwo() {
// North left straight, left arrow, and right arrow are on.
// West straight right light off.
// East Left Straight light is off.
if (!eastLeftStraight.getRedLight().isOn()) {
eastLeftStraight.setTrafficLightOff(eastLeftStraight);
northRightArrow.getGreenLight().turnOn();
}
else {
northRightArrow.getGreenLight().turnOn();
}
}
public void initiatePhaseThree() {
// All lights are off except for the EastStraightRight light.
if (northRightArrow.getGreenLight().isOn() && !northLeftStraight.getRedLight().isOn() &&
northLeftArrow.getGreenLight().isOn()) {
northRightArrow.getGreenLight().turnOff();
northLeftArrow.getGreenLight().turnOff();
northLeftStraight.setTrafficLightOff(northLeftStraight);
}
else {
eastLeftStraight.setTrafficLightOn(eastLeftStraight);
}
}
public FourLightTrafficLight getTrafficLight(FourLightTrafficLight light) {
return light;
}
}
public void setTrafficLightOn(TrafficLight trafficLight) {
trafficLight.getRedLight().turnOff();
LightPause();
trafficLight.getAmberLight().turnOn();
LightPause();
trafficLight.getGreenLight().turnOn();
}
public void setTrafficLightOff(TrafficLight trafficLight) {
trafficLight.getGreenLight().turnOff();
LightPause();
trafficLight.getGreenLight().turnOff();
trafficLight.getAmberLight().turnOn();
LightPause();
trafficLight.getRedLight().turnOn();
}
Thanks for your help :)
greenLeftArrow is not initialized to a value (it's automatically initialized to null) so calling greenLeftArrow.isOn() in the PhaseOneInitialization method will throw a NullPointerException.
You should initialize greenLeftArrow object first like you did for example greenLight. You cannot call methods on not initialized objects.
You can also use assertTrue or assertFalse to simplify your code.
When the multiple trees in the view expanded (Expand the selected tree), the following error is thrown.
I couldnot find out what exactly throws this error. this is the stack trace i got after exception,
org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:4109)
at org.eclipse.swt.SWT.error(SWT.java:3998)
at org.eclipse.swt.SWT.error(SWT.java:3969)
at org.eclipse.swt.widgets.Display.internal_new_GC(Display.java:2589)
at org.eclipse.swt.graphics.Image.getImageData(Image.java:1371)
at org.eclipse.swt.internal.ImageList.set(ImageList.java:401)
at org.eclipse.swt.internal.ImageList.add(ImageList.java:66)
at org.eclipse.swt.widgets.Tree.imageIndex(Tree.java:3636)
at org.eclipse.swt.widgets.TreeItem.setImage(TreeItem.java:1686)
at org.eclipse.jface.viewers.TreeViewerRow.setImage(TreeViewerRow.java:166)
at org.eclipse.jface.viewers.ViewerCell.setImage(ViewerCell.java:169)
at org.eclipse.jface.viewers.WrappedViewerLabelProvider.update(WrappedViewerLabelProvider.java:166)
at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:152)
at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:934)
at org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeRunnable.run(AbstractTreeViewer.java:102)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:1014)
at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:481)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:2141)
at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:829)
at org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractTreeViewer.java:804)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:778)
at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:644)
at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1714)
at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1724)
at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1724)
at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1724)
at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1724)
at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1056)
at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1037)
at org.eclipse.jface.viewers.AbstractTreeViewer.expandAll(AbstractTreeViewer.java:1026)
at com.rockwellcollins.rccase.tarbuilder.actions.ExpandAllAction.run(ExpandAllAction.java:44)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.rockwellcollins.rccase.Application.start(Application.java:74)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
//Label Provider for that tree
public class ViewTreeLabelProvider extends LabelProvider implements
IColorProvider, IBaseLabelProvider,IFontProvider{
#Override
public Image getImage(Object element) {
if (element instanceof EObject) {
return aa.getImages(element);
}
return super.getImage(element);
}
}
// for loading image
public class aa {
public static Image getImages(Object element) {
if (element instanceof ClassA) {
return ClassA.getimage();
} else if (element instanceof ClassB) {
return ClassB.getimage();
} else if (element instanceof ClassC) {
return ClassC.getimage();
} else if (element instanceof ClassD) {
return ClassD.getimage();
}
return null;
}
}
My project code base is vast, i could not share it completely. So, i wrote the snippet in the simple way to convey the problem.
Actually, the images are placed in the icons folder and are fetched by AbstractUIPlugin.imageDescriptorFromPlugin(plugin, path), which inturn stores the images in the Image registry.
I also noticed that, this may be due to the limit in the GDI Objects in the Windows registry.
After the 10000 GDI objects limit is reached the exception is thrown.
By default for Windows 7, GDIProcessHandleQuota value is 10,000. When I googled , I found that, the value can be set to maximum of 65,536.
I have tried to by increasing the GDIProcessHandleQuota from 10,000 to 65,000. Still the same exception is thrown, but after reaching 19,932 GDIObjects.
I anticipate that, the problem may be due to improper disposal of GDIObjects and the exception is thrown in the Image.class.
Suggestions please!!
In your ClassA.getimage(), ClassB.getimage() ... make sure to not create an image each time ".getimage()" is called, cache it.
private Image image;
public Image getImage() {
if ( image == null) {
image = new Image(Display.getDefault(), "");
}
return image;
}
Since it seems that you are in an Eclipse environment, better even use "org.eclipse.jface.resource.ImageRegistry".
Where "UIPlugin" is your plugin extending "org.eclipse.ui.plugin.AbstractUIPlugin".
If you don't have one, create one and add it to your MANIFEST.MF (Bundle-Activator: YOURCLASS).
public Image getImage() {
String key = getClass().getName();
ImageRegistry imageRegistry = UIPlugin.getDefault().getImageRegistry();
Image image = imageRegistry.get(key);
if (image == null) {
image = new Image(Display.getDefault(), "");
imageRegistry.put(key, image);
}
return image;
}
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