flex与java交互出现Channel.Connect.Failed error NetConnection.Call.BadVersion: : url:

本文介绍了解决Flex客户端与Java服务端交互时出现sendFailed异常的方法。通过配置Spring的安全策略及Struts2的排除模式,成功解决了Flex访问Java服务端的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

近期在做flex开发,过程中需要与java服务端进行交互,而服务端采用spring3.2+struts2搭建,并且通过blazeds与flex客户端通信。过程中采用了spring-flex1.0.3.jar ,使用maven进行管理,自动会依赖相关jar,这里不详述。

主要是在通信过程中,通过flex客户端访问服务端是发生了异常 send Failed,这个异常只在页面进行了提示,详细的信息通过debug查看到如下:

Channel.Connect.Failed error NetConnection.Call.BadVersion: : url:'http://localhost:8080/manualdrived-designer/messagebroker/amf'。 

于是查找原因,后直接通过以上url进行访问,出现了500错误。想到可能是由于权限导致。

于是在spring的配置文件中添加匿名权限,/messagebroker/**=anon。再访问就可以了。下参考:

<!-- 自定义filterChainDefinitions -->
    <bean id="menuFilterChainDefinition" class="com.cattsoft.system.security.MenuFilterChainDefinition">
        <property name="filterChainDefinitions">
            <!-- 此部分的filterChain将加载在最前面 -->
            <value>
                /static/** = anon
                /themes/** = anon
                /flex/** = anon
                /messagebroker/**=anon

                /index.jsp = anon
                / = anon
                /main!index = anon
                /main!login = authc
                /main!verifycode = anon

                /main!home = authc
                /main!logout = authc
            </value>
        </property>
        <property name="finalFilterChainDefinitions">
            <!-- 此部分的filterChain将加载在最后面 -->
            <value>
                /** = authc
            </value>
        </property>
    </bean>

 另外如果添加了以上访问后依然存在错误,debug后出现404,通过url直接访问也是404,且提示错误为:

HTTP Status 404 - There is no Action mapped for action name messagebroker.

那么可能是因为采用struts2的注解方式将所有的访问默认都映射成了action,这样就需要在struts.xml中配置

<constant name="struts.action.excludePattern" value="/messagebroker/amf/*.*" /> 使其不背struts2管理

 

2025-08-06 16:56:29.536 ERROR 2308 --- [ Timer-0] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization. com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host PC-20160722JXJKSQL2008R2, port 1433 has failed. Error: "PC-20160722JXJKSQL2008R2. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:228) ~[mssql-jdbc-6.4.0.jre8.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285) ~[mssql-jdbc-6.4.0.jre8.jar:na] at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2437) ~[mssql-jdbc-6.4.0.jre8.jar:na] at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:641) ~[mssql-jdbc-6.4.0.jre8.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2245) ~[mssql-jdbc-6.4.0.jre8.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921) ~[mssql-jdbc-6.4.0.jre8.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762) ~[mssql-jdbc-6.4.0.jre8.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077) ~[mssql-jdbc-6.4.0.jre8.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:623) ~[mssql-jdbc-6.4.0.jre8.jar:na] at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.2.jar:na] at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354) ~[HikariCP-3.4.2.jar:na] at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202) ~[HikariCP-3.4.2.jar:na] at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473) [HikariCP-3.4.2.jar:na] at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554) [HikariCP-3.4.2.jar:na] at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) [HikariCP-3.4.2.jar:na] at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) [HikariCP-3.4.2.jar:na] at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158) [spring-jdbc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116) [spring-jdbc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79) [spring-jdbc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80) [mybatis-spring-2.0.2.jar:2.0.2] at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67) [mybatis-spring-2.0.2.jar:2.0.2] at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) [mybatis-3.5.2.jar:3.5.2] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426) [mybatis-spring-2.0.2.jar:2.0.2] at com.sun.proxy.$Proxy63.selectList(Unknown Source) [na:na] at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223) [mybatis-spring-2.0.2.jar:2.0.2] at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80) [mybatis-3.5.2.jar:3.5.2] at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:57) [mybatis-3.5.2.jar:3.5.2] at com.sun.proxy.$Proxy64.getTablexx_flc(Unknown Source) [na:na] at com.nbheyi.hy_menjin.timer.importRsxxTimer.import_hyc_xx(importRsxxTimer.java:64) [classes/:na] at com.nbheyi.hy_menjin.timer.importRsxxTimer.access$100(importRsxxTimer.java:18) [classes/:na] at com.nbheyi.hy_menjin.timer.importRsxxTimer$1.run(importRsxxTimer.java:43) [classes/:na] at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_181] at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_181] org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host PC-20160722JXJKSQL2008R2, port 1433 has failed. Error: "PC-20160722JXJKSQL2008R2. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". ### The error may exist in class path resource [mappers/YiDongMapper.xml] ### The error may involve com.nbheyi.hy_menjin.mapper.mapper4.YiDongMapper.getTablexx_flc ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host PC-20160722JXJKSQL2008R2, port 1433 has failed. Error: "PC-20160722JXJKSQL2008R2. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:78) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440) at com.sun.proxy.$Proxy63.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223) at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:57) at com.sun.proxy.$Proxy64.getTablexx_flc(Unknown Source) at com.nbheyi.hy_menjin.timer.importRsxxTimer.import_hyc_xx(importRsxxTimer.java:64) at com.nbheyi.hy_menjin.timer.importRsxxTimer.access$100(importRsxxTimer.java:18) at com.nbheyi.hy_menjin.timer.importRsxxTimer$1.run(importRsxxTimer.java:43) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host PC-20160722JXJKSQL2008R2, port 1433 has failed. Error: "PC-20160722JXJKSQL2008R2. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". ### The error may exist in class path resource [mappers/YiDongMapper.xml] ### The error may involve com.nbheyi.hy_menjin.mapper.mapper4.YiDongMapper.getTablexx_flc ### The error occurred while executing a query ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host PC-20160722JXJKSQL2008R2, port 1433 has failed. Error: "PC-20160722JXJKSQL2008R2. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426) ... 11 more Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host PC-20160722JXJKSQL2008R2, port 1433 has failed. Error: "PC-20160722JXJKSQL2008R2. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82) at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80) at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67) at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336) at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) ... 17 more Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host PC-20160722JXJKSQL2008R2, port 1433 has failed. Error: "PC-20160722JXJKSQL2008R2. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.". at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:228) at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285) at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2437) at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:641) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2245) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:623) at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354) at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)
最新发布
08-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值