Bonjour,

Je travaille avec ejb2.1 xdoctlet, eclipse sous oc4j.

Mon problème est que mes beans CMP ne sont pas stocké dans la base de donnée ca reste disant temporaire.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
Context ctx = new InitialContext(properties);
       Object objref = ctx.lookup ("My");
           home = (MyHome) PortableRemoteObject.narrow ( objref, MyHome.class ) ;
home.create(BigDecimal.valueOf(5), BigDecimal.valueOf(54));
Dans ce cas mon bean est créer je peut le manipuler mais pas enregistrer dans la base.

Si je cherche par clé primaire dans la base j'ai cette exception:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
javax.ejb.ObjectNotFoundException: Exception [EJB - 10008] : bean de type [My] introuvable via la recherche [findByPrimaryKey].
at oracle.toplink.internal.ejb.cmp.EJBExceptionFactory.objectNotFound(EJBExceptionFactory.java:325)
	at oracle.toplink.internal.ejb.cmp.finders.Finder.checkNullResult(Finder.java:224)
	at oracle.toplink.internal.ejb.cmp.finders.Finder.processResults(Finder.java:214)
	at oracle.toplink.internal.ejb.cmp.finders.Finder.internalExecute(Finder.java:100)
	at oracle.toplink.internal.ejb.cmp.finders.FindByPrimaryKey.executeFindByPk(FindByPrimaryKey.java:33)
	at oracle.toplink.internal.ejb.cmp.finders.FinderManager.findByPrimaryKey(FinderManager.java:125)

Voici le contenu de mon fichier ejb-jar.xml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
 
<?xml version="1.0" encoding="UTF-8"?>
 
<ejb-jar id="ejb-jar_1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
 
   <description><![CDATA[02firstentity generated by eclipse wtp xdoclet extension.]]></description>
   <display-name>02firstentity</display-name>
 
   <enterprise-beans>
 
      <!-- Session Beans -->
     <!--
       To add session beans that you have deployment descriptor info for, add
       a file to your XDoclet merge directory called session-beans.xml that contains
       the <session></session> markup for those beans.
     -->
 
      <!-- Entity Beans -->
      <entity id="ContainerManagedEntity_My">
         <description><![CDATA[<!-- begin-xdoclet-definition -->]]></description>
 
         <ejb-name>My</ejb-name>
 
         <home>b.MyHome</home>
         <remote>b.My</remote>
         <local-home>b.MyLocalHome</local-home>
         <local>b.MyLocal</local>
 
         <ejb-class>b.MyCMP</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>java.math.BigDecimal</prim-key-class>
         <reentrant>false</reentrant>
         <cmp-version>2.x</cmp-version>
         <abstract-schema-name>MySCHEMA</abstract-schema-name>
         <cmp-field id="CMPAttribute_1">
            <description><![CDATA[<!-- begin-user-doc --> CMP Field a_bind Returns the a_bind]]></description>
            <field-name>a_bind</field-name>
         </cmp-field>
         <cmp-field id="CMPAttribute_2">
            <description><![CDATA[<!-- begin-user-doc --> CMP Field c_bind Returns the c_bind]]></description>
            <field-name>c_bind</field-name>
         </cmp-field>
         <primkey-field>a_bind</primkey-field>
 
         <query>
            <query-method>
               <method-name>findAll</method-name>
               <method-params>
               </method-params>
            </query-method>
            <ejb-ql><![CDATA[SELECT OBJECT(a) FROM MySCHEMA as a]]></ejb-ql>
         </query>
	  <!-- Write a file named ejb-finders-MyBean.xml if you want to define extra finders. -->
 
      </entity>
 
     <!--
       To add entity beans that you have deployment descriptor info for, add
       a file to your XDoclet merge directory called entity-beans.xml that contains
       the <entity></entity> markup for those beans.
     -->
 
      <!-- Message Driven Beans -->
     <!--
       To add message driven beans that you have deployment descriptor info for, add
       a file to your XDoclet merge directory called message-driven-beans.xml that contains
       the <message-driven></message-driven> markup for those beans.
     -->
 
   </enterprise-beans>
 
   <!-- Relationships -->
 
   <!-- Assembly Descriptor -->
     <!--
       To specify your own assembly descriptor info here, add a file to your
       XDoclet merge directory called assembly-descriptor.xml that contains
       the <assembly-descriptor></assembly-descriptor> markup.
     -->
 
   <assembly-descriptor id="AssemblyDescriptor_1">
     <!--
       To specify additional security-role elements, add a file in the merge
       directory called ejb-security-roles.xml that contains them.
     -->
 
   <!-- method permissions -->
     <!--
       To specify additional method-permission elements, add a file in the merge
       directory called ejb-method-permissions.ent that contains them.
     -->
 
   <!-- transactions -->
     <!--
       To specify additional container-transaction elements, add a file in the merge
       directory called ejb-container-transactions.ent that contains them.
     -->
 
   <!-- finder transactions -->
 
   <!-- message destinations -->
     <!--
       To specify additional message-destination elements, add a file in the merge
       directory called ejb-message-destinations.ent that contains them.
     -->
 
   <!-- exclude list -->
     <!--
       To specify an exclude-list element, add a file in the merge directory
       called ejb-exclude-list.xml that contains it.
     -->
   </assembly-descriptor>
 
</ejb-jar>