Disclaimer: I'm new to Java EE and have never worked with EJBs until recently so forgive me if I use some terms or expressions wrongly.
I'm working on a simple application using Java EE and EJB. I need to access an EJB while the application is running. If I have understood correctly you declare beans like this:
@EJB
private ProgressBeanRemote progressBean;
However if I try to access the bean inside the application like this:
System.out.println(progressBean.getSomeValue());
I get the following error message:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at project.name.TestClass.java:10
Now to me it seems the JVM sees the progressBean as a field with no instance and therefore throws a nullpointerexception. However it is not possible (and wouldn't make sense) to create a new object of the bean since it's a really a remote. Other than this I have not much to go on. So my question is: How can I access beans from inside a running JavaFX application?
NOTE: I have tested my app as a regular Java program (no GUI) and then it works. Also I use JDK 1.8 and Java EE 7.
EDIT: I am aware of what a NullPointerException is, I just don't understand why the remote is not recognized when I try to access it from JavaFX specifically.