NullPointerException when trying to run openfire

I am using Eclipse, and I mostly followed this guide Openfire SVN + Eclipse 3.3 + Subversive Installation Guide , to get my stuff running.

For reference , I am telling you what I did:

  1. Extracted the openfire_src to Desktop (my Eclipse workspace directory is F:\Users\Harsh\git\Reminder )

  2. Clicked on file->new project-> java project. This is what my settings dialog looks like :

  3. After clicking on finish, I followed these steps:

Build Openfire

  • Click Window::Show View::Ant menu.
  • Right-click the Ant screen and choose Add Buildfiles…
  • Expand the openfire::build folder and select build.xml, then click OK.
  • On the Ant screen, expand the Openfire XMPP Server and double-click on openfire ant task. The build may fail because you’re checking out the daily updates of Openfire sources, which may contain bugs. If so, wait for another day and hope that the developers discover and fix the bug; or you might dare to fix it yourself. During this first time setup, a successful build is necessary before you can proceed with the remaining tasks below.

Create Project Builder

  • Click Run::Open Run Dialog… or Run::Open Debug Dialog… menu. A Run window shows.
  • Select Java Application and click on the New button.
  • On the Main tab of the Run window, change the New_configuration name to Openfire or anything you like.
  • Click on Project::Browse button and select openfire and click OK.
  • Click on Main class::Search button and select ServerStarter - org.jivesoftware.openfire.starter and click OK.
  • I’d suggest that you select Stop in main check box so that you could later verify that debugging works.
  • Click on the Arguments tab.
  • Enter -DopenfireHome="${workspace_loc:openfire}/target/openfire" in the VM arguments box.
  • Click on Classpath tab.
  • Select User Entries so that the Advanced… button will be enabled.
  • Click on the Advanced… button.
  • On the Advanced Options window select Add Folders and click OK.
  • On the Folder Selection window select openfire::src::i18n folder and click OK.
  • Click on the Advanced… and Add Folders buttons once again to include openfire::src::resources::jar folder.
  • Click on the Advanced… and Add Folders buttons once again to include openfire::build::lib::dist folder.
  • Click on Common tab.
  • Select the Debug and Run check box.
  • Click on Apply button.
  • Click on Close button.

Now, when I try to run my project, It shows :

Openfire 3.10.0 [May 17, 2015 9:27:17 PM]

Admin console listening at http://harsh-pc:9090

But when I access the address ( or localhost:9090) , I get this error:

java.lang.NullPointerException

at org.jivesoftware.admin.AdminConsole.getAppName(AdminConsole.java:137)

at org.jivesoftware.openfire.admin.decorators.setup_jsp._jspService(setup_jsp.java :177)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)

at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)

at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595)

at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:22 3)

at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:11 27)

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)

at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185 )

at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:106 1)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)

at org.eclipse.jetty.server.Dispatcher.include(Dispatcher.java:115)

at com.opensymphony.module.sitemesh.filter.PageFilter.applyDecorator(PageFilter.ja va:156)

at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:59)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.ja va:1652)

at org.jivesoftware.util.LocaleFilter.doFilter(LocaleFilter.java:74)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.ja va:1652)

at org.jivesoftware.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingF ilter.java:50)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.ja va:1652)

at org.jivesoftware.admin.PluginFilter.doFilter(PluginFilter.java:78)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.ja va:1652)

at org.jivesoftware.admin.AuthCheckFilter.doFilter(AuthCheckFilter.java:159)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.ja va:1652)

at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)

at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)

at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:22 3)

at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:11 27)

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)

at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185 )

at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:106 1)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)

at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandler Collection.java:215)

at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.jav a:110)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)

at org.eclipse.jetty.server.Server.handle(Server.java:497)

at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)

at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)

at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635 )

at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)

at java.lang.Thread.run(Unknown Source)

How do I solve this problem ?

My main objective is to be able to write plugins for openfire

Thank you

Just run it with a bat file build process produce. It is much easier than playing with Run command and its arguments. Here’s my notes to setup Eclipse with Git support, pull Openfire source and build and run it:

Eclipse setup:

Launch and select default workspace, select checkbox to remember this selection

Help > Install New Software > Work with: EGit - http://download.eclipse.org/egit/updates > select both modules and Finish

Setup Project in Eclipse with Git support:

File > Import > Git > Project from Git > Next

Clone URI > Next https://github.com/igniterealtime/Openfire.git (Authentication not needed at this point) > Next

Select only “master” > Next

Select directory K:\Git\Openfire > Next

wait until cloned

Import as a general project > Next > Finish

Right-click imported project and Delete (do not select deleting files on disk)

File > New > Java Project

Project name: Openfire

Uncheck “use default location” and set directory to K:\Git\Openfire > Finish

Build project:

Press Ant icon on the right

Add buildfiles > select Openfire> build > build.xml

Press Run Target button to build a project

run to launch - /target/build/bin/startup.bat

1 Like

Will I be able to debug if I start just run the .bat file ? I would like to, maybe, print some things to the console to see whats going wrong. Will it be possible from the bat file ?

Ah, debugging. No, i don’t think it will work with the bat.

So how do you reckon I setup debugging ?

I’m not a developer myself, i don’t know. I only use Eclipse to apply a patch and build binaries for testing. But i don’t debug the code.

You can enable remote debugging in the command line and then use Eclipse to attach to the process. This works not only on processes running locally but also those that are running on remote servers.

A guide is at Debug Java applications remotely with Eclipse

I tried to attach it to port 8000, but for some reason, the console is still totally empty. Where do I see the error logs/console prints etc from eclipse ?

Remote debugging doesn’t change anything else so they will go where ever the process tells them to go. For Openfire on the Mac the usual place for stdout (console/System.out) is /usr/local/openfire/logs/launchd.stdout. The logs go to /logs/* for me.

To add logging to Openfire you should add this to your class:

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

…

private static final Logger Log = LoggerFactory.getLogger(“MyCategoryName”);

and then log messages like this:

Log.error(“I will end up in the error.log file”);