on 2006 Jul 12 8:46 AM
I have a piece of code where I will retrieve a EJBLocalHome. When I
deploy my application, it works fine. But My problem will rise if I
restart my SAP Web AS. After restart, It will throw ClassCastException.
I wonder why. Following is the snippets of my code:
//Begin of code snippet
String jndiName
= "localejbs/com/mbb/crrs/business/common/SeqNoGenerator";
EJBLocalHome home = (EJBLocalHome)context.lookup(jndiName);
if (oHome instanceof EJBLocalHome)
logger.debug("home is instance of EJBLocalHome");
else
logger.debug("home is NOT instance of EJBLocalHome");
if (oHome instanceof SequenceNoGeneratorLocalHome)
logger.debug("home is instance of SequenceNoGeneratorLocalHome");
else
logger.debug("home is NOT instance of SequenceNoGeneratorLocalHome");
if (oHome instanceof SequenceNoGeneratorHome)
logger.debug("home is instance of SequenceNoGeneratorHome");
else
logger.debug("home is NOT instance of SequenceNoGeneratorHome");
SeqNoGeneratorLocalHome seqHome = (SeqNoGeneratorLocalHome)home;
//End of code snippet
I found out that after deployed the application, The output of following code are:
->home is instance of EJBLocalHome
->home is instance of SequenceNoGeneratorLocalHome
->home is NOT instance of SequenceNoGeneratorHome
It shows that everything is OK. It returns the correct EJBLocalHome of SequenceNoGeneratorLocalHome. But after I restart the Web AS, the output
will be as following:
->home is instance of EJBLocalHome
->home is NOT instance of SequenceNoGeneratorLocalHome
->home is NOT instance of SequenceNoGeneratorHome
->ClassCastException is thrown
It seems like the object returned can't be cast from EJBLocalHome to SequenceNoGeneratorLocalHome. How can this happened?
Hi John,
The problem is must probably with class loader. From where are you calling your EJB?
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm calling it from a servlet which I deployed in SAP Web AS. Previously, this piece of code worked fine. I noticed after I applied the Support Package 17 of SAP Web AS, this began to happen.
So everytime I restart my SAP Web AS, I need to redeploy my application. This is very frustrating. Hope somebody could help.
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.