先描述下配置:
Tomcat 9
JDK 1.8
Nutz 1.r.68.v20200427
症状描述:
服务启动无异常,配置的Module可正常访问,使用Jmeter连接WebSocket无结果,日志显示“NOT Action match”
2021-07-28 17:03:26.185 [http-nio-8080-exec-4] DEBUG - Search mapping for [GET] path=/websocket : NOT Action match
WebSocket连接地址:ws://localhost:8080/relay-service/websocket
服务器完整日志:
2021-07-28 17:00:58.740 [RMI TCP Connection(3)-127.0.0.1] INFO - NutFilter[nutz] starting ...
2021-07-28 17:00:58.755 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Locations count=4 time use 3ms
2021-07-28 17:00:58.758 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Locations count=14 time use 3ms
2021-07-28 17:00:58.766 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Loading by class org.nutz.mvc.impl.NutLoading
2021-07-28 17:00:58.768 [RMI TCP Connection(3)-127.0.0.1] INFO - Nutz Version : 1.r.68.v20200427
2021-07-28 17:00:58.768 [RMI TCP Connection(3)-127.0.0.1] INFO - Nutz.Mvc[nutz] is initializing ...
2021-07-28 17:00:58.768 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Web Container Information:
2021-07-28 17:00:58.768 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - Default Charset : UTF-8
2021-07-28 17:00:58.768 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - Current . path : D:\apache-tomcat-9.0.50\bin\.
2021-07-28 17:00:58.768 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - Java Version : 1.8.0_301
2021-07-28 17:00:58.768 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - File separator : \
2021-07-28 17:00:58.769 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - Timezone : Asia/Shanghai
2021-07-28 17:00:58.769 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - OS : Windows 10 amd64
2021-07-28 17:00:58.769 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - ServerInfo : Apache Tomcat/9.0.50
2021-07-28 17:00:58.769 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - Servlet API : 4.0
2021-07-28 17:00:58.769 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - ContextPath : /relay-service
2021-07-28 17:00:58.769 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - context.tempdir : C:\Users\COCO\AppData\Local\JetBrains\IntelliJIdea2021.2\tomcat\f7b28e45-b335-41ba-9a5a-bc9193a41240\work\Catalina\localhost\relay-service
2021-07-28 17:00:58.769 [RMI TCP Connection(3)-127.0.0.1] DEBUG - - MainModule : com.chinacoco.service.relay.MainModule
2021-07-28 17:00:58.770 [RMI TCP Connection(3)-127.0.0.1] DEBUG - >> app.root = E:/Projects/relay-service/service/target/relay-service
2021-07-28 17:00:58.806 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Using 107 castor for Castors
2021-07-28 17:00:58.807 [RMI TCP Connection(3)-127.0.0.1] DEBUG - @IocBy(type=org.nutz.mvc.ioc.provider.ComboIocProvider, args=["*js", "config/", "*anno", "com.chinacoco.service.relay"],init=[])
2021-07-28 17:00:58.828 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Found 1 resource by src( config/ ) , regex( ^(.+[.])(js|json)$ )
2021-07-28 17:00:58.828 [RMI TCP Connection(3)-127.0.0.1] DEBUG - loading [ioc.js]
2021-07-28 17:00:58.830 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Loaded 1 bean define from path=[config/] --> [conf]
2021-07-28 17:00:58.835 [RMI TCP Connection(3)-127.0.0.1] INFO - > scan 'com.chinacoco.service.relay'
2021-07-28 17:00:58.836 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Found 6 resource by src( com/chinacoco/service/relay/ ) , regex( ^.+[.]class$ )
2021-07-28 17:00:58.838 [RMI TCP Connection(3)-127.0.0.1] INFO - > add 'webSocketEndpoint ' - com.chinacoco.service.relay.endpoint.WebSocketEndpoint
2021-07-28 17:00:58.840 [RMI TCP Connection(3)-127.0.0.1] INFO - > add 'commandModule ' - com.chinacoco.service.relay.module.CommandModule
2021-07-28 17:00:58.846 [RMI TCP Connection(3)-127.0.0.1] INFO - ... NutIoc init complete
2021-07-28 17:00:58.848 [RMI TCP Connection(3)-127.0.0.1] INFO - Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ...
2021-07-28 17:00:58.849 [RMI TCP Connection(3)-127.0.0.1] DEBUG - @Views(DefaultViewMaker.class)
2021-07-28 17:00:58.852 [RMI TCP Connection(3)-127.0.0.1] DEBUG - @ChainBy(org.nutz.mvc.impl.NutActionChainMaker)
2021-07-28 17:00:58.856 [RMI TCP Connection(3)-127.0.0.1] DEBUG - module class location 'file:/E:/Projects/relay-service/service/target/relay-service/WEB-INF/classes/'
2021-07-28 17:00:58.857 [RMI TCP Connection(3)-127.0.0.1] DEBUG - > scan 'com.chinacoco.service.relay'
2021-07-28 17:00:58.859 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Found 6 resource by src( com/chinacoco/service/relay/ ) , regex( ^.+[.]class$ )
2021-07-28 17:00:58.861 [RMI TCP Connection(3)-127.0.0.1] DEBUG - >> add 'com.chinacoco.service.relay.module.CommandModule'
2021-07-28 17:00:58.861 [RMI TCP Connection(3)-127.0.0.1] DEBUG - Use org.nutz.mvc.impl.NutEntryDeterminer as EntryMethodDeterminer
2021-07-28 17:00:58.872 [RMI TCP Connection(3)-127.0.0.1] INFO - Optional processor class not found, disabled : org.nutz.integration.shiro.NutShiroProcessor
2021-07-28 17:00:58.878 [RMI TCP Connection(3)-127.0.0.1] INFO - Optional processor class not found, disabled : org.nutz.plugins.validation.ValidationProcessor
2021-07-28 17:00:58.892 [RMI TCP Connection(3)-127.0.0.1] DEBUG - '/command/test' >> (CommandModule.java:17).test : void | @Ok(http:200) @Fail(http:500) | by 0 Filters | (I:UTF-8/O:UTF-8)
2021-07-28 17:00:58.892 [RMI TCP Connection(3)-127.0.0.1] INFO - Found 1 module methods
2021-07-28 17:00:58.893 [RMI TCP Connection(3)-127.0.0.1] DEBUG - @Localization not define
2021-07-28 17:00:58.893 [RMI TCP Connection(3)-127.0.0.1] INFO - Setup application...
2021-07-28 17:00:58.894 [RMI TCP Connection(3)-127.0.0.1] INFO - Nutz.Mvc[nutz] is up in 125ms
[2021-07-28 05:00:58,910] Artifact relay-service:war exploded: Artifact is deployed successfully
[2021-07-28 05:00:58,910] Artifact relay-service:war exploded: Deploy took 1,064 milliseconds
2021-07-28 17:03:11.871 [http-nio-8080-exec-3] DEBUG - Found mapping for [POST] path=/command/test : CommandModule.test(CommandModule.java:17)
2021-07-28 17:03:11.873 [http-nio-8080-exec-3] DEBUG - Get 'commandModule'<class com.chinacoco.service.relay.module.CommandModule>
2021-07-28 17:03:11.874 [http-nio-8080-exec-3] DEBUG - Load AopConfigure for anno=org.nutz.ioc.aop.Aop by type=org.nutz.ioc.aop.config.impl.AnnotationAopConfigration
2021-07-28 17:03:11.875 [http-nio-8080-exec-3] DEBUG - >> Load definition name=commandModule
2021-07-28 17:03:11.875 [http-nio-8080-exec-3] DEBUG - Found IocObject(commandModule) in AnnotationIocLoader(packages=[com.chinacoco.service.relay])
2021-07-28 17:03:11.875 [http-nio-8080-exec-3] DEBUG - >> Make...'commandModule'<class com.chinacoco.service.relay.module.CommandModule>
2021-07-28 17:03:11.884 [http-nio-8080-exec-3] DEBUG - Save object 'commandModule' to [app]
2021-07-28 17:03:11.885 [http-nio-8080-exec-3] DEBUG - Load class com.chinacoco.service.relay.module.CommandModule without AOP
2021-07-28 17:03:11.893 [http-nio-8080-exec-3] DEBUG - Get 'webSocketEndpoint'<class com.chinacoco.service.relay.endpoint.WebSocketEndpoint>
2021-07-28 17:03:11.893 [http-nio-8080-exec-3] DEBUG - >> Load definition name=webSocketEndpoint
2021-07-28 17:03:11.893 [http-nio-8080-exec-3] DEBUG - Found IocObject(webSocketEndpoint) in AnnotationIocLoader(packages=[com.chinacoco.service.relay])
2021-07-28 17:03:11.893 [http-nio-8080-exec-3] DEBUG - >> Make...'webSocketEndpoint'<class com.chinacoco.service.relay.endpoint.WebSocketEndpoint>
2021-07-28 17:03:11.893 [http-nio-8080-exec-3] DEBUG - Save object 'webSocketEndpoint' to [app]
2021-07-28 17:03:11.893 [http-nio-8080-exec-3] DEBUG - Load class com.chinacoco.service.relay.endpoint.WebSocketEndpoint without AOP
2021-07-28 17:03:26.185 [http-nio-8080-exec-4] DEBUG - Search mapping for [GET] path=/websocket : NOT Action match
MainModule
package com.chinacoco.service.relay;
import org.nutz.mvc.annotation.*;
@Ok("http:200")
@Fail("http:500")
@SetupBy(value = MainSetup.class)
@IocBy(args={
"*js", "config/",
"*anno", "com.chinacoco.service.relay"
})
@Modules
public final class MainModule {
}
WebSocketEndpoint
package com.chinacoco.service.relay.endpoint;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.plugins.mvc.websocket.AbstractWsEndpoint;
import org.nutz.plugins.mvc.websocket.NutWsConfigurator;
import javax.websocket.server.ServerEndpoint;
@ServerEndpoint(value = "/websocket", configurator = NutWsConfigurator.class)
@IocBean
public class WebSocketEndpoint extends AbstractWsEndpoint {
}
Maven Dependencies
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz</artifactId>
<version>1.r.68.v20200427</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz-plugins-websocket</artifactId>
<version>1.r.68.v20200427</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
实在是想不出还有哪里需要配置了……OTZ