Author |
Message
|
bareilles |
Posted: Mon Oct 01, 2007 3:12 am Post subject: PB java.lang.ClassCastException: javax.naming.Reference |
|
|
Newbie
Joined: 01 Oct 2007 Posts: 7
|
Hi,
Since my jms queue are managed by MQ Series, i have an error
classcastexception on the lookup. The object returned by the lookup is
javax.naming.Reference but i should have an object QueueConnectionFactory. The queues MQ series are OK because i can used these in an application websphere 6 but with my standalone application it didn't work (jvm sun 1.4.2_14).
Environnement WAS 6.0.2.5
MQ series
class path:
Code: |
log4j-1.2.13.jar
sibc.jms.jar
sibc.jndi.jar
sibc.orb.jar |
Code: |
private static void listenQueue() {
ConnectionFactory qcf;
Connection connection;
Session session;
MessageListener listener;
MessageConsumer queueConsumer;
try {
qcf = (javax.jms.ConnectionFactory) ctx.lookup(properties.getProperty(Constants.JMSCF_JNDI_NAME));
connection = qcf.createConnection(); |
An idea ?
Thanks a lot, |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Oct 01, 2007 3:15 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You need the full J2EE CLIENT footprint on your classpath.
What you have shown us is way too light... The was J2EE client footprint is kind of heavy....  _________________ MQ & Broker admin |
|
Back to top |
|
 |
bareilles |
Posted: Mon Oct 01, 2007 3:27 am Post subject: The full class path |
|
|
Newbie
Joined: 01 Oct 2007 Posts: 7
|
The full class path:
Code: |
/product/projet/JVM1_4_2/bin/java -classpath /product/projet/lib/001_projetSimulatorReceiver.jar:/product/projet/lib/log4j-1.2.13.jar:/product/projet/lib/sibc.jms.jar:/product/projet/lib/sibc.jndi.jar:/product/projet/lib/sibc.orb.jar:/product/projet/env/ com.projet.simulator.standalone.receiver.Main /users/projet/projet_log/001_projetSimulatorReceiver_env/001_projetSimulatorReceiver.pinlog |
StackTrace full:
Code: |
java.lang.ClassCastException
at com.projet.simulator.standalone.receiver.Main.listenQueue(Main.java:57)
at com.projet.simulator.standalone.receiver.Main.main(Main.java:32)
|
line 57: qcf = (javax.jms.ConnectionFactory) ctx.lookup(properties.getProperty(Constants.JMSCF_JNDI_NAME));
I add the methode for initialize the context:
Code: |
/**
* Initialize the context for connecting to the server.
*/
private static void initContext() {
logger.debug("Initializing the context");
// Creating the hashmap wich is used to configure the context.
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL, properties.getProperty(Constants.host_url));
env.put("java.naming.corba.orb", org.omg.CORBA.ORB.init((String[]) null, null));
try {
// Initializing the context with hashmap informations.
ctx = new InitialContext(env);
logger.debug("Context initialized");
} catch (NamingException e) {
logger.error("Can't initialize context", e);
logger.error(e.toString());
System.exit(Integer.parseInt(properties.getProperty(Constants.err_cnx_host)));
} catch (Exception e) {
logger.error(e.toString());
System.exit(Integer.parseInt(properties.getProperty(Constants.err_unknown)));
}
} |
|
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Oct 01, 2007 2:03 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
And where is javax.jms.jar ??
This too is needed on the classpath... and a lot more.
Read up on WAS and find what the J2EE client foot print is. For a successful extraction of the CF from the context, you will need the full J2EE client footprint.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
bareilles |
Posted: Mon Oct 01, 2007 11:34 pm Post subject: |
|
|
Newbie
Joined: 01 Oct 2007 Posts: 7
|
As you can see in my classpath there is the jar : sibc.jms.jar it contain the special classes for an application sun interfaced with a WAS6 server (http://www-1.ibm.com/support/docview.wss?uid=swg24012804).
In this jar there are all classes i need to used the JMS queue. (an particurlary the javax.jms.ConnectionFactory)
Before used MQ series JMS queue my application was OK (before i used the default JMS messenger) |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Oct 02, 2007 3:27 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Well, I was assuming you were using the SIBus and not MQSeries because you certainly don't show any of the classes necessary for MQSeries on the classpath...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
bareilles |
Posted: Tue Oct 02, 2007 3:31 am Post subject: classe pour mq series |
|
|
Newbie
Joined: 01 Oct 2007 Posts: 7
|
Hi,
thanks a lot for your answer.
Where can i found this classes ?
thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Oct 02, 2007 3:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Read the using Java manual. It's all there.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
bareilles |
Posted: Tue Oct 02, 2007 3:38 am Post subject: livrairies |
|
|
Newbie
Joined: 01 Oct 2007 Posts: 7
|
Ok, no need to have specials ibm livrairies... Only default librairies java.
thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Oct 02, 2007 3:44 am Post subject: Re: livrairies |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
bareilles wrote: |
Ok, no need to have specials ibm livrairies... Only default librairies java.
thanks |
And how are you going to connect to a provider without any of the provider libraries ??? Told to read the manual...It is all there as well as in the WAS manual where it tells you how to do a J2EE Client connection  _________________ MQ & Broker admin |
|
Back to top |
|
 |
bareilles |
Posted: Tue Oct 02, 2007 3:52 am Post subject: i know |
|
|
Newbie
Joined: 01 Oct 2007 Posts: 7
|
Don't worry, i know i must add librairies for mq, but last time it was specials librairy to have communication between sun application and was6.
Now i will find what i need in the redbook.  |
|
Back to top |
|
 |
bareilles |
Posted: Fri Oct 05, 2007 3:36 am Post subject: No solutions |
|
|
Newbie
Joined: 01 Oct 2007 Posts: 7
|
My problem persists.
I have found this bug on ibm web site about the version WAS server 6.1, it seems to be similar with my problem but i'm in WAS 6.0.2.5...
There is a local fix on the version WAS 6.1 but i don't know where is the famous "Access to internal classes" on the graphic interface of administration on WAS 6.0.2.5 ....An idea? or An other idea about my problem?
Quote: |
PK30540: CLASSCASTEXCEPTION OCCURS DURING JNDI LOOKUP OF JMS CONNECTION FACTORY WHEN "ACCESS TO INTERNAL SERVER CLASSES" SET TO RESTRICT
APAR status
Closed as program error.
Error description
In WebSphere Application Server V6.1, when the "Access to
internal server classes" option is set to "Restrict" for an
application server, a JNDI lookup of any JMS connection factory
will fail with the following exception:
.
java.lang.ClassCastException: javax.naming.Reference
incompatible with javax.jms.QueueConnectionFactory
Local fix
Set "Access to internal classes" to "Allow".
Problem summary
****************************************************************
* USERS AFFECTED: WebSphere Application Server version 6.1 *
* users running with internal class access *
* mode set to restricted attempting to access *
* queue connection factory resources. *
****************************************************************
* PROBLEM DESCRIPTION: Java Naming and Directory Interface *
* (JNDI) lookup requests for queue *
* connection factories return a Reference *
* rather than the requested factory *
* object when internal class access mode *
* is set to restricted. *
****************************************************************
* RECOMMENDATION: *
****************************************************************
The bundle containing the queue connection factory class does
not export the package containing the factory class, so the JNDI
object factory for queue connection factories cannot be loaded.
Additionally, the protection classloader filters the queue
connection factory class itself, which prevents it from being
located.
Problem conclusion
Export the queue connection factory factory class package from
the runtime bundle, and add the queue connection factory class
to the protection classloader exception list. These changes
will allow both classes to be loaded.
The fix for this APAR is currently targeted for inclusion in
fixpak 6.1.0.5.
Please refer to the recommended updates page for delivery
information:
http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
Temporary fix
Comments
APAR information
APAR number
PK30540
Reported component name
WEBSPH APP SERV
Reported component ID
5724J0800
Reported release
61Z
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2006-08-25
Closed date
2006-09-20
Last modified date
2007-01-02
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Modules/Macros
CLASSLDR
Publications Referenced
Fix information
Fixed component name
WEBSPH APP SERV
Fixed component ID
5724J0800
Applicable component levels
R61A PSY
UP
R61H PSY
UP
R61I PSY
UP
R61P PSY
UP
R61S PSY
UP
R61W PSY
UP
R61Z PSY
UP |
|
|
Back to top |
|
 |
|