Skip to Main Content

Java User Groups

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.NullPointerException LazyStackRenderer.showElementRecursive when changing perspectives

a941a926-7d43-48e9-af4e-212630b4d88aMar 12 2018 — edited Mar 12 2018

I'll apologize in advance if this is not the appropriate location for this question (if so, please let me know where I should post this issue).

We have the ability to choose perspectives in our application similar to in eclipse (when in eclipse you can add the git, java, debug, etc. perspective).

We're trying to move from Eclipse Kepler / Java 7 to Eclipse Oxygen / Java 8 and we see the exception below when doing the following:

- open our application, a default perspective is selected [perspective #1], select non default perspective [perspective #2]

- close the application

- re-open the application (default perspective is now selected [perspective #1])

- select the non-default perspective [perspective #2] -> exception thrown as outlined below and the application remains on perspective #1

*note: The exception will not be thrown if perspective #1 is selected prior to closing the application.

We can run the application with the -clearPersistedState argument and then the workbench.xmi is deleted on start-up and we won't see the exception.

Has anyone else run into this problem or know how to solve it (exception from the console below)?  Could we be creating/using perspectives in an inappropriate way?

!ENTRY org.eclipse.ui 4 0 2017-11-06 11:08:29.138 !MESSAGE Unhandled event loop exception !STACK 0java.lang.NullPointerException at

org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:228) at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:271) at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:276) at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:276) at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:276) at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showTab(LazyStackRenderer.java:154) at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.showTab(PerspectiveStackRenderer.java:85) 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.advanced.impl.PerspectiveStackImpl.setSelectedElement(PerspectiveStackImpl.java:135) at org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveStackImpl.setSelectedElement(PerspectiveStackImpl.java:1) at org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher$4.widgetSelected(PerspectiveSwitcher.java:543) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4238) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3817) 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 com.ipunwired.core.ui.application.Application.start(Application.java:23) 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(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: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)

Comments

odie_63
PS: I don't want to use an hardcoding
Why?

Do you have such a scenario that you don't know the procedure name you're trying to compile?

Edited by: odie_63 on 11 janv. 2013 10:45
padders
Simple answer is you can't - without generating some additional metadata for the package.

One way to generate the metadata would appear to be PL/Scope in 11g but I haven't actually tried that to see how it pans out.
odie_63
There's $$PLSQL_UNIT compiler directive but it doesn't reference subprograms in a package, only the package itself :
SQL> create or replace package mypck is
  2    procedure myprc;
  3  end;
  4  /
 
Package created
 
SQL> 
SQL> create or replace package body mypck is
  2    procedure myprc is
  3    begin
  4      dbms_output.put_line('I''m in '||$$PLSQL_UNIT);
  5    end;
  6  end;
  7  /
 
Package body created
 
SQL> exec mypck.myprc;
 
I'm in MYPCK
 
PL/SQL procedure successfully completed
 
bencol
This might help you understand the problem:
http://tkyte.blogspot.co.uk/2009/10/httpasktomoraclecomtkytewhocalledme.html

Buit I usually hardcode the proc name into a variable and use that for logging.
unknown-7404
You've posted enough to know that you need to provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
>
is it possible to obtain a called procedure/function name within package?

For a measuring and tracing purpose, I would like to store an info at the beginning of each procedure/function in package with timestamp + additional details if needed.
>
I usually use this method

1. Create a SQL type for logging information
2. Put the package name into a constant in the package spec
3. Add a line to each procedure/function for the name.

Sample package spec
	/******************************************************************************
	 * Constants and package variables
	 ******************************************************************************/
		gc_pk_name			CONSTANT VARCHAR2(30) := 'PK_TEST';
Sample procedure code in package
	 PROCEDURE P_TEST_INIT
	 IS
	   c_proc_name CONSTANT VARCHAR2(80)  := 'P_TEST_INIT';
	   v_log_info  TYPE_LOG_INFO := TYPE_LOG_INFO(gc_pk_name, c_proc_name); -- create the log type instance

	 BEGIN
		NULL; -- code goes here
	 EXCEPTION
	 WHEN ??? THEN
		v_log_info.log_code := SQLCODE;  -- add info to the log type
		v_log_info.log_message := SQLERRM;
		v_log_info.log_time    := SYSDATE;
		pk_log.p_log_error(v_log_info);
                                raise;
	 END P_PK_TEST_INIT;
Sample SQL type
DROP TYPE TYPE_LOG_INFO;

CREATE OR REPLACE TYPE TYPE_LOG_INFO AUTHID DEFINER AS OBJECT (
/* *****************************************************************************
 *  NAME:      TYPE_LOG_INFO
 *  PURPOSE:   Holds info used by PK_LOG package to log errors.
 *
 *             Using a TYPE instance keeps the procedures and functions
 *             independent of the logging mechanism.
 *
 *             If new logging features are needed a SUB TYPE can be derived
 *             from this base type to add the new functionality without
 *             breaking any existing code.
 *
 *  REVISIONS:
 *  Ver        Date        Author           Description
 *
 *   1.00      mm/dd/yyyy  me               Initial Version.
 ******************************************************************************/
    PACKAGE_NAME  VARCHAR2(80),
    PROC_NAME     VARCHAR2(80),
    STEP_NUMBER   NUMBER,
    LOG_LEVEL   VARCHAR2(10),
    LOG_CODE    NUMBER,
    LOG_MESSAGE VARCHAR2(1024),
    LOG_TIME    TIMESTAMP,
    CONSTRUCTOR FUNCTION type_log_info (p_package_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                        p_proc_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                        p_step_number IN NUMBER DEFAULT 1,
                                        p_LOG_level IN VARCHAR2 DEFAULT 'Uninit',
                                        p_LOG_code IN NUMBER DEFAULT -1,
                                        p_LOG_message IN VARCHAR2 DEFAULT 'Uninitialized',
                                        p_LOG_time IN DATE DEFAULT SYSDATE)
                RETURN SELF AS RESULT
  ) NOT FINAL;
/

DROP TYPE BODY TYPE_LOG_INFO;

CREATE OR REPLACE TYPE BODY TYPE_LOG_INFO IS
    CONSTRUCTOR FUNCTION type_log_info (p_package_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                        p_proc_name IN VARCHAR2 DEFAULT 'Uninitialized',
                                        p_step_number IN NUMBER DEFAULT 1,
                                        p_LOG_level IN VARCHAR2 DEFAULT 'Uninit',
                                        p_LOG_code IN NUMBER DEFAULT -1,
                                        p_LOG_message IN VARCHAR2 DEFAULT 'Uninitialized',
                                        p_LOG_time IN DATE DEFAULT SYSDATE)
     RETURN SELF AS RESULT IS
    BEGIN
      self.package_name  := p_package_name;
      self.proc_name     := p_proc_name;
      self.step_number   := p_step_number;
      self.LOG_level   := p_LOG_level;
      self.LOG_code    := p_LOG_code;
      self.LOG_message := p_LOG_message;
      self.LOG_time    := p_LOG_time;
      RETURN;
    END;
END;
/
SHO ERR
Edited by: rp0428 on Jan 11, 2013 10:35 AM after 1st cup of coffee ;)
odie_63
rp0428 wrote:
You would want the $$PLSQL_UNIT directive.
And as shown in my post, this doesn't apply to subprograms in a package, which seems to be precisely what OP is after.
unknown-7404
Thanks - brain f*** - didn't even see your post somehow. I update my post with the old method.
1 - 7

Post Details

Added on Mar 12 2018
1 comment
254 views