You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Dodunski <Ch...@christopher.net.nz> on 2019/04/08 08:42:18 UTC

Using WebSockets with a Tapestry WebApp running on Tomcat

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


Re: Using WebSockets with a Tapestry WebApp running on Tomcat

Posted by John Dale <jc...@gmail.com>.
IoC - *shudders*

Can't this be used to "inject" mass surveillance into J2E apps?  It
was curiously missing in the bullet items down the home page of
tapestry.  :p

So, you're expecting to inject dependencies into components
instantiated on a websocket?

By "the rest of the application" below, are you referring to
application code that's in tapestry, early in the chain of execution,
or code that is on/behind your websocket?

So, you're looking for some feature in tapestry that would inject some
kind of remoteable dependencies into/onto your websocket?

This is an interesting question to me .. it to ok me about 10 years,
but I created substitutes for both tapestry and HBN/Cayenne.  I found
that all the source code I needed to deploy ORM/MVC/JSON/HTML5 was
300KB.  I like being able to step through JavaScript, then step
through Java for debugging without having to negotiate etherial stubs
to far off services.

Looking forward to hearing about the resources you're trying to have
injected into your code.

Have a good one,

John
DB2DOM.COM


On 4/8/19, Christopher Dodunski <Ch...@christopher.net.nz> wrote:
> 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
>
>

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