Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » EventAdmin is null in EventBroker if run Junit test using maven in Luna(EventAdmin is null in EventBroker if run Junit test using maven in Luna)
EventAdmin is null in EventBroker if run Junit test using maven in Luna [message #1503276] Mon, 08 December 2014 10:07 Go to next message
Sumit Singh is currently offline Sumit SinghFriend
Messages: 141
Registered: October 2012
Location: Bangalore
Senior Member

HI*,

I have some Junit tests, one class uses EventBroker in one of its method. I'm running it using Tycho V0.22.0. Till eclipse 4.3 it was working fine.
After migrating to Luna I'm getting Following Exception:
java.lang.NullPointerException: null
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:78)


I'm creating Event Broker like:
            try {
                IEclipseContext eclipseCtx = getEclipseContext(IEventBroker.class); // I'm getting context in this function
                eclipseCtx.set(Logger.class, null);
                IEventBroker eventBroker = eclipseCtx.get(IEventBroker.class); // this is returning eventBroker
            } catch (Exception ex) {
                LoggerHandler.sendMessage(LoggerConstants.ERROR_MESSAGE, "Event Broker not initialized " + ex.getMessage());
                LoggerHandler.logStackTrace(LoggerConstants.DETAILED_MESSAGE, ex);
            }


And method is using it like:
eventBroker.send("SOME_ID", Object);


I know that its throwing NPE because eclipseCtx.set(Logger.class, null) but before Luna inside send method EventAdmin eventAdmin = Activator.getDefault().getEventAdmin();(); it was not null but now its null.

so why its failing? is there is any way to fix this?

[Updated on: Mon, 08 December 2014 10:09]

Report message to a moderator

Re: EventAdmin is null in EventBroker if run Junit test using maven in Luna [message #1503384 is a reply to message #1503276] Mon, 08 December 2014 12:14 Go to previous message
Sumit Singh is currently offline Sumit SinghFriend
Messages: 141
Registered: October 2012
Location: Bangalore
Senior Member

Found One workaround: Add following code in pom file. Now the question is, why its not working without it?

<build>	
    <plugins>
		<plugin>
			<groupId>org.eclipse.tycho</groupId>
			<artifactId>target-platform-configuration</artifactId>
			<version>${tycho-version}</version>
			<configuration>
				<dependency-resolution>
					<extraRequirements>
						<requirement>
							<type>eclipse-feature</type>
							<id>org.eclipse.rcp</id>
							<versionRange>0.0.0</versionRange>
						</requirement>
					</extraRequirements>
				</dependency-resolution>
			</configuration>
		</plugin>
	</plugins>
</build>
Previous Topic:Editor Shortcuts not working anymore in Luna
Next Topic:To create a context sub menu for which user enters the input value
Goto Forum:
  


Current Time: Thu Jan 28 14:29:58 GMT 2021

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

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

Back to the top