Headless server on server without grafic system

I’m quite new to jmonkey. So I’m wondering:

Is it possible to run a headless server on a linux server without x11?

I tried my best but it keeps complaining that it can’t open a display…

Any ideas?

…documentation is your friend… https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:headless_server

well… that’s exactly what i’m doing!

creating a headless server. still it complains about not being able to open a display.

Maybe it tries to display the settings window? You can disable that too.

argh. thats probably it. thanks a lot. will test that tomorrow.

Just for people stumbling by. The right way to do this is in JME3:

[java]

public class IEGServer extends SimpleApplication {



public static void main(String[] args) {

IEGServer app = new IEGServer();

app.start(JmeContext.Type.Headless); // headless type for servers!

}



public IEGServer() {

super();

setShowSettings(false); // Don’t show settings dialog

}

[/java]



What caused my problem is totally unrelated to jMonkey. I was creating a static icon for some GUI-Element.

Took me some time to find the abstract ancestor where i did this… :confused:

Stuck again.

Is there supposed to be a font loader registered in headless mode?

If yes, why don’t i have one?

Why does it call loadFPSText() unconditionally? What about showFps=false?

Confused…



No loader registered for type “fnt”

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:248)

at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:374)

at com.jme3.app.SimpleApplication.loadFPSText(SimpleApplication.java:183)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:208)

at com.jme3.system.NullContext.initInThread(NullContext.java:85)

at com.jme3.system.NullContext.run(NullContext.java:128)

at java.lang.Thread.run(libgcj.so.11)

You sure you have all jars on the class path? This bit would be jME3-plugins.jar

I double checked: jME3-plugins.jar is in libs folder with all the others.

I even looked into the jar manifest. Just to be sure :slight_smile:

Any further ideas?

Which jME3-xxx.jar’s you have on the class path? Do you use the SDK? What libraries are set for the project?

I installed the SDK and created the project with it.

Since then I use my standard Netbeans installation. This has been working fine locally. As soon as I scp the dist to my vserver it starts complaining because the vserver does not have grafics.



Fresh from my jar manifest:

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.8.2

Created-By: 1.6.0_29-b11 (Sun Microsystems Inc.)

Class-Path: lib/Common.jar

lib/jME3-core.jar

lib/eventbus.jar

lib/nifty-default-controls.jar

lib/nifty.jar

lib/xmlpull-xpp3.jar

lib/jME3-niftygui.jar

lib/nifty-style-black.jar

lib/j-ogg-oggd.jar

lib/j-ogg-vorbisd.jar

lib/jbullet.jar

lib/jinput.jar

lib/lwjgl.jar

lib/stack-alloc.jar

lib/vecmath.jar

lib/jME3-lwjgl-natives.jar

lib/jME3-lwjgl.jar

lib/jME3-bullet-natives.jar

lib/jME3-bullet.jar

lib/jME3-desktop.jar

lib/jME3-jogg.jar

lib/jME3-plugins.jar

lib/jME3-jbullet.jar

lib/jME3-terrain.jar

lib/launch4j.jar

lib/xstream.jar

lib/jscience-4.3.jar

lib/IEGCommon.jar

lib/geoapi.jar

lib/javolution.jar

lib/commons-logging-1.1.1.jar

lib/assets.jar

Can you make a test case for this please?

I deleted all my stuff and tested what’s left.

I still get :



08.03.2012 12:57:00 com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[Headless Application Thread,5,main]

java.lang.IllegalStateException: No loader registered for type “fnt”

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:248)

at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:374)

at com.jme3.app.SimpleApplication.loadFPSText(SimpleApplication.java:183)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:208)

at com.jme3.system.NullContext.initInThread(NullContext.java:85)

at com.jme3.system.NullContext.run(NullContext.java:128)

at java.lang.Thread.run(libgcj.so.11)



[java]

package de.dertroglodyt.iegserver;



import com.jme3.app.SimpleApplication;

import com.jme3.bullet.BulletAppState;

import com.jme3.bullet.PhysicsSpace;

import com.jme3.bullet.PhysicsTickListener;

import com.jme3.light.AmbientLight;

import com.jme3.math.Vector3f;

import com.jme3.network.ConnectionListener;

import com.jme3.network.HostedConnection;

import com.jme3.network.Server;

import com.jme3.system.AppSettings;

import com.jme3.system.JmeContext;

import java.io.FileInputStream;

import java.io.IOException;

import java.net.URL;

import java.util.logging.Level;

import java.util.logging.LogManager;

import java.util.logging.Logger;



/**

  • test
  • @author dertroglodyt

    */

    public class IEGServer extends SimpleApplication implements ConnectionListener, PhysicsTickListener {



    private static final String LOG_CONFIG = "logging.properties";

    static {

    URL configFileResource = IEGServer.class.getResource(LOG_CONFIG);

    // PropertyConfigurator.configure(configFileResource);

    try {

    LogManager.getLogManager().readConfiguration(new FileInputStream(LOG_CONFIG));

    } catch (IOException ex) {

    Logger.getLogger(IEGServer.class.getName()).log(Level.SEVERE, null, ex);

    System.exit(-1);

    } catch (SecurityException ex) {

    Logger.getLogger(IEGServer.class.getName()).log(Level.SEVERE, null, ex);

    System.exit(-1);

    }

    }



    public static void main(String[] args) throws IOException {

    Log.info("Initializing server…");

    IEGServer app = new IEGServer();

    Log.info("Starting server…");

    app.start(JmeContext.Type.Headless); // headless type for servers!

    }



    public IEGServer() throws IOException {

    super();

    settings = new AppSettings(true);

    setShowSettings(false);

    // setDisplayFps(false);

    // setDisplayStatView(false);

    }



    @Override

    public void simpleInitApp() {

    flyCam.setEnabled(false); // Disable mouse catch in standard fly cam.

    bulletAppState = new BulletAppState();

    stateManager.attach(bulletAppState);

    bulletAppState.getPhysicsSpace().addTickListener(this);

    rootNode.addLight(new AmbientLight());

    getCamera().setLocation(new Vector3f(10f, 5e12f, 10f));

    getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);

    getCamera().setFrustumNear(1f);

    Log.info("Init done.");

    }



    @Override

    public synchronized void destroy() {

    Log.info("Server shutting down…");



    super.destroy();

    }



    /**
  • PhysicsEngine

    */

    private BulletAppState bulletAppState;

    private static Logger Log = Logger.getLogger(IEGServer.class.toString());



    @Override

    public void connectionAdded(Server server, HostedConnection conn) {

    throw new UnsupportedOperationException("Not supported yet.");

    }



    @Override

    public void connectionRemoved(Server server, HostedConnection conn) {

    throw new UnsupportedOperationException("Not supported yet.");

    }



    @Override

    public void prePhysicsTick(PhysicsSpace ps, float f) {

    // throw new UnsupportedOperationException("Not supported yet.");

    }



    @Override

    public void physicsTick(PhysicsSpace ps, float f) {

    // throw new UnsupportedOperationException("Not supported yet.");

    }



    }

    [/java]

I just clean/build/deployed it with the SDK. Same result.

You must be running against nightlies.



In recent nightly builds, SimpleApplication was modified to allow complete removal of things like stats, camera, etc… simply by not including their app states. I did my best to try to support backwards compatibility but It’s possible that setShowSettings() is not doing what it’s supposed to do.



Even more likely, that the font is grabbed regardless of whether the stats are displayed and that this has been broken longer than my changes.



…knowing what version you are running would help.

Product Version: jMonkeyEngine SDK 3.0beta

Java: 1.6.0_29; Java HotSpot™ 64-Bit Server VM 20.4-b02

System: Linux version 2.6.37.6-0.11-desktop running on amd64; UTF-8; de_DE (jmonkeyplatform)



jars in .jmonkeyplatform/3.0beta/libs have timestamp of 2012-02-20 07:36 if that helps.

Are you running just beta? Did you let it update to the latest stable?



Or, did you enable updating to nightlies? (I’m not saying that you should, just trying to understand if you did)

If you mean jdk plugins: I only use stable and user contributions. No nightlies enabled.

JME3 Libraries Version: 3.0.0.9083 Source: jMonkeyEngine SDK Stable

JKME3 External Libraries Version: 3.0.0.8928 Source: jMonkeyEngine SDK Stable

Thanks. That is helpful.



In the version you run, your only recourse is to override the loadFPSText() method to do nothing. I don’t know if simply doing nothing causes issues or if you have to at least create something.



In the most recent version, I actually kept this limitation up until a few minutes ago. When I made my recent refactorings of SimpleApplication, I actually made it slightly worse since I loaded the gui font right in init. I just checked in a version that allows overriding a createGuiFont() method to return null. With this, and proper removal of the default app states you can have a label free existence.



Though it occurs to me that a headless application may be the one case where SimpleApplication is not the right answer and maybe extending Application is better… though I don’t know what you are doing with your headless application. For a game server, I pretty much shun the idea altogether as Application and SimpleApplication provide nothing (or very little) that I would ever need in a game server.