Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Exception on Startup #1206

Closed
John-Holt-Tessella opened this issue May 17, 2016 · 4 comments
Closed

Remove Exception on Startup #1206

John-Holt-Tessella opened this issue May 17, 2016 · 4 comments

Comments

@John-Holt-Tessella
Copy link
Contributor

John-Holt-Tessella commented May 17, 2016

On startup the following exception is thrown:

java.lang.NullPointerException
    at org.csstudio.security.ui.internal.SecurityVariables.<init>(SecurityVariables.java:43)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.ui.internal.services.WorkbenchServiceRegistry.getSourceProviders(WorkbenchServiceRegistry.java:174)
    at org.eclipse.ui.internal.services.SourceProviderService.readRegistry(SourceProviderService.java:105)
    at org.eclipse.ui.internal.Workbench$61.run(Workbench.java:2400)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.Workbench.startSourceProviders(Workbench.java:2397)
    at org.eclipse.ui.internal.Workbench.access$18(Workbench.java:2382)
    at org.eclipse.ui.internal.Workbench$30.runWithException(Workbench.java:1567)
    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:4144)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2609)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at uk.ac.stfc.isis.ibex.product.Application.start(Application.java:39)
    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:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    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:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

It is thrown by org.csstudio.security.ui.internal.SecurityVariables (C:\eclipse-ibex-v3.1\workspace\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins). During the call on line 43 because SecuritySupport.getAuthorizations() is null. I suspect there is something wrong in the setup. The authentication (set in product plugin_customisation.ini) is meant to be file at org.csstudio.platform.jaasAuthentication/authorization_file_name=platform:/plugin/org.csstudio.security/authorization.conf but there is no file there Adding this does not change the issue; although I am unsure what the file should contain.

@John-Holt-Tessella John-Holt-Tessella changed the title Exception on Startup Remove Exception on Startup May 17, 2016
@kjwoodsISIS kjwoodsISIS added this to the SPRINT_2016_05_19 milestone May 19, 2016
@IsabellaRey IsabellaRey self-assigned this May 23, 2016
@IsabellaRey IsabellaRey removed their assignment May 23, 2016
@AdrianPotter AdrianPotter self-assigned this May 24, 2016
@AdrianPotter
Copy link

Summary: Not fixed. This is a bug in our version of CSStudio. We need to upgrade at least to the latest version of 3.3 (currently 3.3.11) for it to work as expected

Long version:
The error happens during the initialization of SecurityVariables() as might be expected from the stack trace. This, and all subsequently referenced code is contained in the packages org.csstudio.security and org.csstudio.security.ui. The initialization code for SecurityVariables is as follows:

    /** Initialize */
    public SecurityVariables()
    {
        final Boolean authenticated = SecuritySupport.getSubject() != null;
        variables.put(AUTHENTICATED, authenticated);
        variables.put(CURRENT_USER, SecuritySupport.isCurrentUser());        
        variables.put(CURRENT_AUTHORIZATION, SecuritySupport.getAuthorizations().getAuthorizations());
        SecuritySupport.addListener(this);
    }

The first call to getAuthorizations() returns null and so the 2nd call fails. Easy enough. The deeper question is why that's the case. The authorizations come from the class SecurityContext. It has an authorizationProvider that is successfully set up and should provide the relevant objects. However, the authorizations themselves are set up during the authentication step when SecurityContext.setSubject(...) is called.

Looking at the source for these packages, SetSubject(...) is only called from LoginJob which is itself only called from the security UI dialogs. This means that the authentication is not set at startup and so initializing SecurityVariables will inevitably throw this exception.

The SecurityVariables code is located at:

https://github.com/ControlSystemStudio/cs-studio/blob/master/core/utility/utility-plugins/org.csstudio.security.ui/src/org/csstudio/security/ui/internal/SecurityVariables.java

As you can see, the null condition is now checked for during the initialization which should solve the problem. I don't think it can be seen from the file history in Github owing to a file move but @nickbattam has confirmed the fix was committed in October 2014. The fix should therefore appear in version 3.3.11 released in December 2014:

http://controlsystemstudio.org/controlsystemstudio/current.html

To fix the issue, we would therefore need to update to at least this version.

I will mark this ticket as impeded so that it can be reviewed when a decision is made about upgrading our version of CSS. Before that I will:

  • Add some documentation to the wiki about the debugging steps followed during examination of this problem.
  • I will submit a ticket for discussing the upgrade of CSS on IBEX

@AdrianPotter
Copy link

I've added a description of some of the information I found useful for debugging here:

https://github.com/ISISComputingGroup/ibex_developers_manual/wiki/Debugging-CSS

@kjwoodsISIS
Copy link
Contributor

Do after release to instruments. Do at end of sprint. Upgrade to CSS v3.x

@kjwoodsISIS kjwoodsISIS removed this from the SPRINT_2016_11_03 milestone Nov 3, 2016
@kjwoodsISIS kjwoodsISIS removed the ready label Nov 3, 2016
@AdrianPotter AdrianPotter removed their assignment Nov 24, 2016
@Tom-Willemsen
Copy link
Contributor

Fixed by #1229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants