Niki and Romain:

hmm... I can't do it!  :)  How can something this simple not work?  All
Maven dependencies are working fine.  The editor sees all the classes on
the classpath.....

I downloaded Tomee+ 1.6.0.1 I think it was Friday morning.

I copied the websocket.api.jar file from Tomee/lib into my client (it
contains both client and server classes).

executed startup.sh (with server side deployed).

ran my class, container is null;

Downloaded Tomcat 8.0.5.  The size of websocket-api.jar is different so
copied websocket-api.jar to both tomee/lib and my project classpath.

ran my class, container is null.  Compete class listing as follows:

package com.yakridge.client;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.websocket.ContainerProvider;
import javax.websocket.DeploymentException;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
import org.openide.util.Exceptions;


public class ClientConstants {
    private    static ClientConstants INSTANCE = null;
    private    Session session = null;
    private    JPackerEndpoint_Client    client;     // annotated
ClientEndpoint
    private static final WebSocketContainer container =
ContainerProvider.getWebSocketContainer();

    private    ClientConstants() { }

    public static ClientConstants getInstance() {
        // returns INSTANCE of this class -- code edited out
    }

    public void exerciseClientConstants() {
        client = new JPackerEndpoint_Client();
        try {
            try {

                if(client == null) {
                    System.out.println("JPackerEndpoint_Client is null");
//<-- this is not the null value since this line does not print
                }
                if(container == null) {
                    System.out.println("the container is null");     //<--
prints this line
                }
                session = container.connectToServer(client, new URI("ws://
192.168.3.98:8080/JPackerServer-web/mainpage"));   //<-- fails @ this line
            } catch (DeploymentException ex) {
                Exceptions.printStackTrace(ex);
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        } catch (URISyntaxException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}


Running class prints the line "the container is null" and throws null
pointer exception @ session = container.connectToServer().  It doesn't even
get as far as attempting to connect!  Fetching the container is pretty
straight forward but returning null with the Tomcat 8.0.5 version.

Any ideas what I am missing here?  This appears to be so simple.  I'm
exhausted and calling it a day for a few hours shut-eye and return home
tomorrow.  Don't see how you can have any ideas what could possibly go
wrong with something so simple.


On Sun, May 4, 2014 at 10:52 AM, Romain Manni-Bucau
<rmannibu...@gmail.com>wrote:

> hmm you can do the same with tomcat 7 importing same jars with version
> 7.0.53
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-05-04 18:18 GMT+02:00 Chuck Davis <cjgun...@gmail.com>:
> > Niki:
> >
> > That is exactly what is required and what I have been looking for!
>  Perhaps
> > the problem, then, is that Tomee is based on Tomcat 7 something.  When
> > Tomee adopts Tomcat 8 the problem should be fixed it sounds like.  That
> is
> > fabulous news!! Thanks for letting me know.  I shall be impatiently
> > awaiting the day!!  Perhaps I shall experiment with dropping the openejb
> > jar into Tomcat 8 to see if it will work.
> >
> > I'm running jdk8u5 at this time so that is not an issue.
> >
> > Again, much appreciated.
> >
> >
> > On Sun, May 4, 2014 at 9:03 AM, Niki Dokovski <nick...@gmail.com> wrote:
> >
> >> Hi
> >> here a small client side project [1]  I used before to put some load on
> >> the Web Socket implementation in Tomcat 8
> >> It uses https type of connection simply because I was interested in SSL
> >> handling at that point of time. Of course you can ignore it and take a
> look
> >> at ws.echo.client.run.ClientsRunner
> >>
> >> 1. The examples obtains reference to the container in static way
> >>  private static final WebSocketContainer container =
> >> ContainerProvider.getWebSocketContainer();
> >>
> >> 2. It uses programmatic approach for getting WebSocket Session
> >> container.connectToServer(ClientEndpoint.class,
> >> ClientEndpointConfig.Builder.create().build(),url)
> >>
> >> 3. adds a message handler
> >> session.addMessageHandler(new ClientEndpointMessageHandler(latch));
> >>
> >> 4. sends a text based web socket message
> >> session.getBasicRemote().sendText(message);
> >>
> >> 5. and closes the connection
> >> session.close(new
> CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE,"just
> >> close it"));
> >>
> >> As you can see the maven project uses web socket implementation from
> >> Tomcat to establish client connection using Java SE. Basically you need
> the
> >> jars from the maven dependencies for your client code to work.
> >>
> >> Your observation is correct, the Apache Tomcat implementation requires
> at
> >> least Java SE 7.
> >>
> >> Hope this helps
> >> Niki Dokovski | @nickytd
> >>
> >> [1] https://bitbucket.org/nickytd/websocket-echo-client
> >>
> >>
> >> On 04.05.2014, at 17:30, Romain Manni-Bucau <rmannibu...@gmail.com>
> wrote:
> >>
> >> > well I think you are not that right.
> >> >
> >> > 1) client works perfectly in TomEE. Outside...well outside TomEE you
> >> > are outside so that's fine if it doesn't work
> >> > 2) you are right client side is needed outside a server...80% of the
> >> > case it is javascript which is fine
> >> >
> >> > You can ask Tomcat to export their client part in an importable jar
> >> > but websocket implementation of tomcat is optimized for embedded mode.
> >> > That said I'm +1 for it but there is no link with TomEE itself
> >> >
> >> >
> >> >
> >> > Romain Manni-Bucau
> >> > Twitter: @rmannibucau
> >> > Blog: http://rmannibucau.wordpress.com/
> >> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >> > Github: https://github.com/rmannibucau
> >> >
> >> >
> >> > 2014-05-04 16:24 GMT+02:00 Chuck Davis <cjgun...@gmail.com>:
> >> >> Wtih all due respect, Romain, I have to take issue with your
> position.
> >> >> Andy just helped me learn how to connect JSE clients to the EJB
> >> container
> >> >> using the http protocol.  If EJB (Tomee/openEJB) is only for browser
> >> >> clients it's quite useless for any real work.  Without Swing/JavaFX
> >> client
> >> >> connectivity it will be consigned to such workloads as the social
> >> network.
> >> >> It's going to be a long time before any significant data input (i.e.
> the
> >> >> typical business workload) will be done with a browser interface.
>  It is
> >> >> essential that JSE clients be able to connect to/use EJB via Tomee
> via
> >> >> websockets.
> >> >>
> >> >> In a @ClientEndpoint
> >> >> WebsocketContainer container =
> >> ContainerProvider.getWebsocketContainer();
> >> >> must return a container so that the container can be used to get a
> >> session
> >> >> from the server.  Currently it throws an exception that there is no
> >> >> implementation class.  If that is not fixed soon Tomee/openEJB  will
> >> not be
> >> >> a welcoming project to those of us who write Java desktop
> applications.
> >> >>
> >> >> My $.02.
> >> >>
> >> >> CD
> >> >>
> >> >> P.S.  By the way, connecting to the EJB container using http to find
> the
> >> >> ejb seems to work nicely but it's no substitute for the advantages
> >> offered
> >> >> by websockets.
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> On Sun, May 4, 2014 at 6:23 AM, Romain Manni-Bucau <
> >> rmannibu...@gmail.com>wrote:
> >> >>
> >> >>> Well TomEE websocket implementation is to write clients from TomEE
> not
> >> >>> from JavaSE (where you don't have TomEE anymore).
> >> >>>
> >> >>> In TomEE clients work.
> >> >>>
> >> >>> So you need to provide us a maven project with a test showing the
> >> >>> issue you have.
> >> >>>
> >> >>>
> >> >>> Romain Manni-Bucau
> >> >>> Twitter: @rmannibucau
> >> >>> Blog: http://rmannibucau.wordpress.com/
> >> >>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >> >>> Github: https://github.com/rmannibucau
> >> >>>
> >> >>>
> >> >>> 2014-05-04 15:20 GMT+02:00 Chuck Davis <cjgun...@gmail.com>:
> >> >>>> Niki, I'm not sure what "http proxy setup for client connection"
> means
> >> >>> but
> >> >>>> it sounds suspiciously like the very piece I'm looking for --
> >> connecting
> >> >>> a
> >> >>>> Java client to the server with websocket.  Is that what you are
> >> saying?
> >> >>>> The piece WebsocketContainer container =
> >> >>>> ContainerProvider.getWebsocketContainer() will not currently work?
> >> >>>> Currently it returns an exception that there is no implementation
> >> class.
> >> >>>>
> >> >>>> If that is so, then my contention stands that Tomee needs a better
> >> >>>> implementation to allow Java clients to connect.
> >> >>>>
> >> >>>> Thanks.
> >> >>>>
> >> >>>> CD
> >> >>>>
> >> >>>>
> >> >>>> On Sat, May 3, 2014 at 8:24 AM, Niki Dokovski <nick...@gmail.com>
> >> wrote:
> >> >>>>
> >> >>>>> The only limitation in Apache Tomcat implementation of Java API
> for
> >> Web
> >> >>>>> Socket (JSR 356) is the missing http proxy setup for client
> >> connections.
> >> >>>>> This has already bean discussed in Tomcat dev lists and so far
> this
> >> is
> >> >>> left
> >> >>>>> either for future spec definitions or users demand. The rest of
> the
> >> >>>>> implementation is fully functional within the JSR 356 definitions.
> >> >>>>>
> >> >>>>> Best Regards
> >> >>>>> Niki
> >> >>>>>
> >> >>>>>
> >> >>>>> Niki Dokovski | @nickytd
> >> >>>>>
> >> >>>>>
> >> >>>
> >>
> >>
>

Reply via email to