2

I deployed an Wildfly 8.1 java application using Tyrus to manage a websocket server, nothing too complicated, it just receives the message and respond the message reversed, well, it should work, everything is according to OpenShift tutorial, but on deploy, I get this message on the rhc tail:

2015-01-02 21:16:19,314 ERROR [io.undertow.websockets.jsr] (MSC service thread 1
-2) UT026002: Unable to instantiate server configuration class org.glassfish.tyr
us.server.TyrusServerConfiguration: java.lang.InstantiationException: org.glassf
ish.tyrus.server.TyrusServerConfiguration
        at java.lang.Class.newInstance(Class.java:418) [rt.jar:1.8.0_05]
        at org.wildfly.extension.undertow.deployment.UndertowJSRWebSocketDeploym
entProcessor.doDeployment(UndertowJSRWebSocketDeploymentProcessor.java:213)
        at org.wildfly.extension.undertow.deployment.UndertowJSRWebSocketDeploym
entProcessor.deploy(UndertowJSRWebSocketDeploymentProcessor.java:165)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(Deplo
ymentUnitPhaseService.java:159)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(Se
rviceControllerImpl.java:1948)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceCont
rollerImpl.java:1881)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142) [rt.jar:1.8.0_05]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617) [rt.jar:1.8.0_05]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_05]
Caused by: java.lang.NoSuchMethodException: org.glassfish.tyrus.server.TyrusServ
erConfiguration.<init>()
        at java.lang.Class.getConstructor0(Class.java:2971) [rt.jar:1.8.0_05]
        at java.lang.Class.newInstance(Class.java:403) [rt.jar:1.8.0_05]
        ... 8 more

And when I try to connect to the socket, I can connect, but it work as a previous version of it(that didnt reverse).

Here is the Websocket server source:

@ServerEndpoint(value = "/socket")
public class WebSocket {

    private Logger logger = Logger.getLogger(this.getClass().getName());
    private Reconhecedor reconhecedor = new Reconhecedor();

    @OnOpen
    public void onOpen(Session session) {
        logger.info("Connected Recognizer ... " + session.getId());
    }

    @OnMessage
    public String onMessage(String message, Session session) {
        logger.info("String message arrived");

        return new StringBuilder(message).reverse().toString();
    }

    @OnMessage
    public String onMessage(ByteBuffer message, Session session) {
        logger.info("byte message arrived");
        String result = "";
        ByteArrayInputStream baiut = new ByteArrayInputStream(message.array());
        AudioInputStream ais;
        try {
            ais = AudioSystem.getAudioInputStream(baiut);
            result = reconhecedor.Recognize(ais);
            logger.info("returning: " + result);
            //session.close(new CloseReason(CloseCodes.NORMAL_CLOSURE, "Game ended"));
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

    @OnClose
    public void onClose(Session session, CloseReason closeReason) {
        logger.info(String.format("Session %s closed because of %s", session.getId(), closeReason));
    }
}

And also, my server source:

public class Programa {

    public static void main(String[] args) {
        runServer();
    }

    public static void runServer() {

        String ip = System.getenv("OPENSHIFT_WILDFLY_IP");
        int port = 8000; 

        Server server = new Server(ip, port, "", WebSocket.class);

        try {
            server.start();
            System.out.print("Please press a key to stop the server.");
            System.in.read();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            server.stop();
        }
    }
}

I'm kinda lost, dont know what else to do, seems like javascript websocket is so much simple and works well, but I need it java because I'm going to use that socket for Sphinx CMU.

Any help is appreciated, thanks in advance!

H_DANILO
  • 321
  • 1
  • 9
  • Just a guess. Is your port variable set correctly? Try 8080? Is there an openshift env var for the port? – fat fantasma Jan 03 '15 at 18:48
  • Unfortunely there isnt, and I think they instantiate the websocket by themselves, putting always to listen on port 8000, I also tried 8080 which is what some people recommend, but, nothing changes – H_DANILO Jan 03 '15 at 20:29
  • Did you end up finding a solution ? I have the same problem – wsalame Jun 27 '16 at 20:27
  • Looked like the tyrus and all dependencies were using too much resource. Had to cut it out and use raw socket communication, it worked. – H_DANILO Jun 28 '16 at 22:31
  • @H_DANILO Consider turning your comment into an answer and then accepting it. It makes it clearer for other what actually happened in the end. – Stewart Oct 05 '17 at 09:18

1 Answers1

0

Openshift has resources limitation, my stack was resource intensive because I was using speech recognizion that were taking too much resource, so, instead of using the Tyrus and Wildfly, I went raw Java + pure socket communication and that solved the problem!

H_DANILO
  • 321
  • 1
  • 9