users@glassfish.java.net

class loading question

From: Andrey Stelmashenko <ya-tam_at_hawaiian.org.ua>
Date: Tue, 29 Mar 2011 18:08:54 +0300

Hello community

I`m new to jee world. I work on jca1.6 connector and have some problem.
Here is the problem:
I have mycja.rar which consists of:
META-INF/ra.xml
ra.jar
*client.jar*

And I wrote sample webapp which uses myjca, it consists of:
META-INF
WEB-INF/classes
WEB-INF/lib/*client.jar*
WEB-INF/(xmls here)
(web pages here)

And there is such a code in the webapp class:
...
1 jndiContext = new InitialContext();
2 MmlConnectionFactory connectionFactory = (MmlConnectionFactory)
jndiContext.lookup("jca/MmlConnector");
3 MmlConnection connection = connectionFactory.getConnection();
4 connection.connect();
5//some stuff here
6 connection.close();
...

But when it gets MmlConnectionFactory, line 2, there an exception:
java.lang.ClassCastException:
mml.connection.impl.*MmlConnectionFactoryImpl*cannot be cast to
mml.connection.
*MmlConnectionFactory*

where *MmlConnectionFactoryImpl *implements *MmlConnectionFactory.*

MmlConnectionFactoryImpl is places in the ra.jar
and
MmlConnectionFactory is places in the client.jar

But I go another way and package connector and webapp without client.jar,
and client.jar i put into the glassfish/domain/domain1/lib it works fine.

Where am I wrong? Any suggestions?

Thanks a lot!

-- 
Sincerely,
Andrey Stelmashenko