tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Dodunski" <ChrisFromSquir...@christopher.net.nz>
Subject Using WebSockets with a Tapestry WebApp running on Tomcat
Date Mon, 08 Apr 2019 08:42:18 GMT
Hi team,

I have developed a web application using the Apache Tapestry framework and
deployed on Apache Tomcat.  The application also supports WebSocket
connections with desktop clent applications.  Following the advice of the
Tapestry community, I included the server-side endpoint within the
Tapestry based application, but added the below declaration to the
AppModule configuration, which basically instructs Tapestry to ignore any
requests to the endpoint URI, leaving Tomcat to handle the request
instead.

    public static void contributeIgnoredPathsFilter(Configuration<String>
configuration) {
        configuration.add("/websocket/.*");
    }

The problem is that, as with any IoC based application, my WebSocket
endpoint relies on dependency injection to interact with the rest of the
application (ie. injected services).  And it seems, given that Tomcat is
left to handle WebSocket connections independent of the Tapestry
application, endpoints get instantiated but without the injected
dependencies.  So, of course, a null pointer exception occurs once the
endpoint attempts to invoke a dependency method.

Moreover, presumably Tomcat is instantiating endpoints outside of the
Tapestry realm, meaning that any class (static) field values are not
shared across endpoints instantiated by Tapestry itself.

Obviously leaving Tomcat to handle these WebSocket connections independent
of the Tapestry application isn't working.  Is there a common solution to
what I imagine is a pretty common scenario?  I'm not aware of how to have
Tomcat connect to an endpoint instance already instantiated within the
Tapestry application (one potential solution).

Thanks & regards,

Chris.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message