Connexion à un EJB statefull
Bonjour à tous ,alors voilà j'essaye de me connecter à mon ejb statefull lors de l'utilisation de ma fonction:
J'ai l'erreur suivante ;
Code:
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
| Exception in thread "AWT-EventQueue-1" javax.ejb.EJBException: java.lang.IllegalStateException: JBAS014366: Session id hasn't been set for stateful component: AmortissementAvecEtat
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:80)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:43)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.invokeMethod(MethodInvocationMessageHandler.java:302)
at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.access$200(MethodInvocationMessageHandler.java:64)
at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler$1.run(MethodInvocationMessageHandler.java:196)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
at ...asynchronous invocation...(Unknown Source)
at org.jboss.ejb.client.remoting.InvocationExceptionResponseHandler$MethodInvocationExceptionResultProducer.getResult(InvocationExceptionResponseHandler.java:99)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:270)
at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:47)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:272)
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocationResult(ReceiverInterceptor.java:132)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:260)
at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:399)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:140)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
at $Proxy0.calculerAmortissement(Unknown Source)
at client.Amortissement.conserver(Amortissement.java:237)
at client.Amortissement$3.actionPerformed(Amortissement.java:180)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source) |
Voici ma fonction qui récupère la connexion :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public void conserver(int Somme,int Date,int annee,int duree,int taux) {
// TODO Auto-generated method stub
// Appel du stateless bean
AmortissementAvecEtatRemote Amortissement;
try {
Amortissement = lookupRemoteStatelessAvecEtatAmortissement();
Amortissement.calculerAmortissement( Somme, Date, annee, duree, taux);
Object[][] donnee = Amortissement.calculerAmortissement(Somme, Date, annee, duree, taux);
String[] entetes = {"mois", "annee", "mensualite", "amortissement", "interet"};
JTable table = new JTable( donnee,entetes);
table.size();
table.setBounds(116, 240, 300,300);
getContentPane().add(table);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
Ma fonction de connexion :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| // Connexion au serveur et lookup du bean
private static AmortissementAvecEtatRemote lookupRemoteStatelessAvecEtatAmortissement() throws NamingException {
AmortissementAvecEtatRemote remote=null;
try {
Properties jndiProps = new Properties();
jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
InitialContext ctx = new InitialContext(jndiProps);
remote = (AmortissementAvecEtatRemote) ctx.lookup("ejb:/AmortissementEJB/AmortissementAvecEtat!hw.AmortissementAvecEtatRemote");
} catch (Exception e) {
e.printStackTrace();
}
return remote;
} |
et voici mon ejb :
Code:
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
| package hw;
import java.util.ArrayList;
import javax.ejb.LocalBean;
import javax.ejb.Stateful;
/**
* Session Bean implementation class Amortissement
*/
@Stateful
public class AmortissementAvecEtat implements AmortissementAvecEtatRemote {
private ArrayList<Object[][]> buffer = new ArrayList<Object[][]>();
/**
* Default constructor.
*/
public AmortissementAvecEtat() {
// TODO Auto-generated constructor stub
}
public Object [][] calculerAmortissement(int somEmprunt, int moisDebut,
int anneeDebut, int dureePret, int tauxAnnuel) {
// CALCUL DE L'AMORTISSEMENT
double tauxMensuel = ((double)tauxAnnuel / 12) / 100;
int dureeMensuelPret = dureePret * 12;
int capitalRestantDu = somEmprunt;
int moisPeriode = moisDebut;
int anneePeriode = anneeDebut;
int amortissementPeriode = 0;
int interetsPeriode = 0;
int mensualiteConstante = (int) Math.round((((double)(somEmprunt * tauxMensuel)) /
((double)(1 - Math.pow(1 + tauxMensuel, -dureeMensuelPret)))));
/* tableauAmortissement [...][0] : mois de la période
* tableauAmortissement [...][1] : année de la période
* tableauAmortissement [...][2] : mensualité
* tableauAmortissement [...][3] : amortissement
* tableauAmortissement [...][4] : intérêts
*/
Object [][] tableauAmortissement = new Object [dureeMensuelPret][5];
for (int i = 0; i < dureeMensuelPret; i++) {
interetsPeriode = (int) (capitalRestantDu * tauxMensuel);
amortissementPeriode = mensualiteConstante - interetsPeriode;
tableauAmortissement [i][0] = moisPeriode;
tableauAmortissement [i][1] = anneePeriode;
tableauAmortissement [i][2] = mensualiteConstante;
tableauAmortissement [i][3] = amortissementPeriode;
tableauAmortissement [i][4] = interetsPeriode;
capitalRestantDu = capitalRestantDu - amortissementPeriode;
moisPeriode++;
if (moisPeriode == 13) {
moisPeriode = 1;
anneePeriode++;
}
}
this.buffer.add(tableauAmortissement);
return tableauAmortissement;
}
public ArrayList<Object[][]> getBuffer() {
return buffer;
}
public void setBuffer(ArrayList<Object[][]> buffer) {
this.buffer = buffer;
}
} |
Merci d'avance :)