发表于: 2017-08-29 18:58:40

1 1080


今天完成的事情:总结一下任务8.9踩的坑

在使用JDK1.8.0_121及以上版本做任务的时候你可能会出现如下BUG

org.apache.tuscany.sca.host.rmi.RMIHostRuntimeException: RemoteException occurred in server thread; nested exception is: 

java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 

java.io.InvalidClassException: filter status: REJECTED

这是因为版本1.8.0_121及以上版本中有一个新的“实现序列化过滤”请参见:JDK-8155760。 

解决此问题的方法是:

转到您的jdk安装目录如:C:\ Program Files \ Java \ jdk1.8.0_131 \ jre \ lib \ security \ java.security并修改此设置:

把#号去掉,也就是去掉注释。

因为tuscany很早就停止维护了,spring能与它兼容的版本应设置为3.1.0及以下

在service模块中的pom文件添加依赖

<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-jdbc</artifactId>
   <version>3.0.5.RELEASE</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>3.0.5.RELEASE</version>
</dependency>
<!--spring test-->
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-test</artifactId>
   <version>3.0.5.RELEASE</version>
</dependency>
<dependency>
   <groupId>org.apache.tuscany.sca</groupId>
   <artifactId>tuscany-base-runtime</artifactId>
   <version>2.0.1</version>
</dependency>
<dependency>
   <groupId>org.apache.tuscany.sca</groupId>
   <artifactId>tuscany-implementation-spring-runtime</artifactId>
   <version>2.0.1</version>
</dependency>
<dependency>
   <groupId> org.apache.tuscany.sca</groupId >
   <artifactId>tuscany-binding-rmi-runtime</artifactId>
   <version> 2.0.1</version>
   <scope> runtime</scope>
</dependency>

service模块中的.composite配置文件

这个时候报红才是正常的,不用管他。

然后如果你出现了如下BUG即service启动成功但方法死活不成功,没有causedby信息。

这是JDK的问题如果你用的是JDK1.8.0_131和144请换成121

其他的bug看日志就能解决,在贴一下两个service的配置文件,很容易配错所以贴一下。

UserService.conposite

<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
          xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          name="UserService"  targetNamespace="http://UserService">
   <component name="UserComponent">
       <implementation.spring location="spring-tuscany.xml"/>
       <service name="UserService" >
           <tuscany:binding.rmi  uri="rmi://127.0.0.1:9090/UserService"/>
       </service>
   </component>
</composite>

UserService1.composite

<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
          xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          name="UserService"  targetNamespace="http://UserService">
   <component name="UserComponent">
       <implementation.spring location="spring-tuscany.xml"/>
       <service name="UserService1" >
           <tuscany:binding.rmi  uri="rmi://127.0.0.1:9091/UserService1"/>
       </service>
   </component>
</composite>

Spring-tuscany.xml(service)

<?xml version= "1.0" encoding ="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:sca="http://www.springframework.org/schema/sca"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/sca
    http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd" >
   <sca:service name="UserService" type="com.wyc.service.UserService" target="UserService"/>
       <bean id="UserService" name="UserService" class="com.wyc.serviceImpl.UserServiceImpl"/>
   <import resource="spring-mybatis.xml"/>
</beans>

Spring-tuscany.xml(service1)

<?xml version= "1.0" encoding ="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:sca="http://www.springframework.org/schema/sca"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/sca
    http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd" >
   <sca:service name="UserService1" type="com.wyc.service.UserService" target="UserService"/>
       <bean id="UserService" name="UserService" class="com.wyc.serviceImpl.UserServiceImpl"/>
   <import resource="spring-mybatis.xml"/>
</beans>

其他的配置文件不变,还有tuscany的暴露出rmi端口和spring rmi中暴露出的端口两者是独立的,即在做任务9的时候把你在任务8中spring-mybatis.xml暴露端口服务配置给注释掉,没试过两个端口一样了会怎样,好像是不影响,也能跑,应该是用了tuscany框架会默认用它来暴露rmi端口。

其他的应该都不是什么大问题就到这里了。

明天计划的事情:进复盘评审,学会用SVN来进行版本管理。

遇到的问题:JDK问题解决了

收获:如上


返回列表 返回列表
评论

    分享到