By creating a ServletContextListener that sets a static ServletContext variable in a RegistryProxy class I created, I now have access to the Tapestry-IoC registry from anywhere in the application. So the internal wiring ought to be in place now.
However, when I use my custom endpoint Configurator to get an instance of ServerEndpoint (implementation) from the registry, it seems that what I get back is not castable: 15-Apr-2019 12:45:28.488 SEVERE [http-nio-8080-exec-915] org.apache.coyote.AbstractProtocol$ConnectionHandler.process Error reading request, ignored java.lang.ClassCastException: Cannot cast $HarbourServerEndpoint_39c9cc24eb8b2a to com.optomus.harbour.services.HarbourServerEndpointImpl at java.lang.Class.cast(Class.java:3369) at com.optomus.harbour.services.HarbourServerEndpointConfigurator.getEndpointInstance(HarbourServerEndpointConfigurator.java:17) at org.apache.tomcat.websocket.pojo.PojoEndpointServer.onOpen(PojoEndpointServer.java:44) at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.init(WsHttpUpgradeHandler.java:133) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:846) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Just wondering whether you have any idea why this might be? Accessing the registry is via a chain of 'generic' methods, but I can't find fault here. Given that Tapestry works similarly when actioning the @Inject annotation, you might immediately recognise where the fault lies. My Configurator method: @Override public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException { return endpointClass.cast(RegistryProxy.getService(HarbourServerEndpoint.class)); } My RegistryProxy method: public static <T> T getService(Class<T> serviceInterface){ Registry registry = (Registry)context.getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME); return registry.getService(serviceInterface); } Incidentally, altering my Configurator method to use old style casting (as per below) didn't solve the problem. @Override public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException { return (T)RegistryProxy.getService(HarbourServerEndpoint.class); } Finally, with no casting at all, the compiler gives the error: Error:(17, 40) java: incompatible types: inference variable T has incompatible bounds equality constraints: com.optomus.harbour.services.HarbourServerEndpoint upper bounds: T,java.lang.Object Regards, Chris. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org