Bonjour,

Nouvel utilisateur de Spring (venant des ejb 3), j'essaie en vain de mettre une annotation @Transactional sur mon service. Dès que je le fais, je ne peux plus instancier mon bean :-( J'ai passé des heures dessus, sans comprendre : cela marche pourtant bien sur la couche dao...

Mon service s'appelle "taskoplanServiceImpl", ma dao "daoImpl".

Dès que je rajoute l'annotation sur le service -->

INFO: Binding service 'TaskoplanService' to RMI registry: RegistryImpl_Stub[UnicastRef [liveRef: [endpoint:[192.168.1.3:2484](remote),objID:[0:0:0, 0]]]]
Exception in thread "main" java.lang.ClassCastException: $Proxy20 cannot be cast to be.lapinsoft.taskoplan.server.TaskoplanServiceImpl
at be.lapinsoft.taskoplan.server.TaskoServ.main(TaskoServ.java:31)
Voici le fichier xml de config de spring :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
        <a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> 
        <a href="http://www.springframework.org/schema/beans/spring-beans.xsd" target="_blank">http://www.springframework.org/schem...ring-beans.xsd</a> 
        <a href="http://www.springframework.org/schema/aop" target="_blank">http://www.springframework.org/schema/aop</a> 
        <a href="http://www.springframework.org/schema/aop/spring-aop-2.0.xsd" target="_blank">http://www.springframework.org/schem...ng-aop-2.0.xsd</a>
        <a href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a> 
        http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
    <bean id="taskoplanService" class="be.lapinsoft.taskoplan.server.TaskoplanServiceImpl">
        <property name="dao" ref="daoImpl" />
    </bean>
    <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
        <!-- does not necessarily have to be the same name as the bean to be exported -->
        <property name="serviceName" value="TaskoplanService"/>
        <property name="service" ref="taskoplanService"/>
        <property name="serviceInterface" value="be.lapinsoft.taskoplan.remote.TaskoplanService" />
        <property name="registryPort" value="2484"/>
    </bean>
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor">
    </bean>
    <bean id="daoImpl" class="be.lapinsoft.taskoplan.server.DaoImpl">
        <!--property name="entityManagerFactory" ref="entityManagerFactory" /-->
    </bean>
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
                <property name="showSql" value="true" />
                <property name="generateDdl" value="true" />
                <property name="databasePlatform" value="oracle.toplink.essentials.platform.database.JavaDBPlatform"/>
            </bean>
        </property>
        <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
        </property>
    </bean>
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver" />
        <property name="url" value="jdbc:derby://localhost:1527/taskoplan" />
        <property name="username" value="taskoplan" />
        <property name="password" value="*****" />
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
    <tx:annotation-driven transaction-manager="transactionManager" />
</beans>