Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Load Image(Error: NullPointerException )
Load Image [message #778483] Thu, 12 January 2012 20:09 Go to next message
Simon Woelki is currently offline Simon WoelkiFriend
Messages: 2
Registered: January 2012
Junior Member
Hey guys,

When my application starts it opens a image upload.
This works fine. But as soon as it enters the application it throws an error:
java.lang.NullPointerException
	at uad.ViewPart4.createPartControl(ViewPart4.java:145)
	at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:375)
	at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:229)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
	at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:534)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:643)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:570)
	at org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:568)
	at org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:272)
	at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:981)
	at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2714)
	at org.eclipse.ui.internal.WorkbenchWindow$27.run(WorkbenchWindow.java:3023)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:3004)
	at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage(WorkbenchWindow.java:799)
	at org.eclipse.ui.internal.Workbench$23.runWithException(Workbench.java:1224)
	at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
	at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
	at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1595)
	at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at uad.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:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	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:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)


Here is the code:

final FileDialog FD = new FileDialog(Display.getCurrent().getActiveShell(), SWT.MULTI);
  		//FD.setFilterPath("C:\\Users\\Admin\\workspace\\");
  		String[] filterExt = {"*.jpg", "*.gif", "*.png",  "*.jpeg", "*.bmp", "*.*"};
  		FD.setFilterExtensions(filterExt);
  	
  	    String hans = FD.open(); 
  		if (hans != null)
  			{
  			String[] bilder = FD.getFileNames();
  			String pfad = FD.getFilterPath();
  			for (int i = 0; i < bilder.length; i++)
  				{
  				String Bild = pfad + "\\" + bilder[i];
  				ImageDescriptor imageDescriptor = Activator.getImageDescriptor(Bild);
				Image orginalImage = imageDescriptor.createImage();
					
					Label label = new Label(linkeSpalte, SWT.RESIZE);
					label.setImage(orginalImage);
  				}
  			}
  		if (hans == null)
  			{
  				Label label = new Label(linkeSpalte, SWT.RESIZE);
  				label.setText("Falsches Format oder keine Datei(en) ausgewählt.");
  			}


Image orginalImage = imageDescriptor.createImage(); is line 145 (NullPointerException)

Any ideas?

Best regards

Simon
Re: Load Image [message #778492 is a reply to message #778483] Thu, 12 January 2012 20:56 Go to previous message
David Wegener is currently offline David WegenerFriend
Messages: 1352
Registered: July 2009
Senior Member
Well, the obvious answer would be that Activator.getImageDescriptor(Bild) is returning null. Most likely the path you are building isn't correct.
Previous Topic:Keeping top displayed node the same during tree refreshing
Next Topic:MultiPageFormEditor switch Tab on Key Event
Goto Forum:
  


Current Time: Sun Dec 21 01:54:58 GMT 2014

Powered by FUDForum. Page generated in 0.01789 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software