on 06-13-2005 7:35 AM
Hi,
I am trying to access the queue connection factory from a standalone java application. I am using the following code
<b>Properties props = new Properties();
QueueConnectionFactory queueConnFact = null;
try{
props.put("Context.INITIAL_CONTEXT_FACTORY", "com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put("Context.PROVIDER_URL", "server:50004");
props.put("Context.SECURITY_PRINCIPAL", "user");
props.put("Context.SECURITY_CREDENTIALS", "pass");
Context ctx = new InitialContext(props);
// Look up the connection factory
queueConnFact = (QueueConnectionFactory)PortableRemoteObject.narrow(ctx.lookup("jmsfactory/default/QueueConnectionFactory"), QueueConnectionFactory.class);</b>
However i get the following exception.
<i><b>Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial</b></i>
Please do let me know what additional i have to do make the code work.
Regards
Sidharth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Don't know why but the URL points to somewhere else
The lookup is not right. It must be :
try {
factory = (QueueConnectionFactory) cxt.lookup("jmsfactory/default/QueueConnectionFactory");
} catch (NamingException ne) {
System.out.println( "NamingException -> "" + ne.getMessage() + """);
}
HTH
Martin
Hi,
Sorry I didn't saw it earlier:
remove all quotes from Context.XXXXX, i.e.
props.put("Context.PROVIDER_URL", "server:50004");
should be
props.put(Context.PROVIDER_URL, "server:50004");
And yes, you gotta have logging.jar, exception.jar, jms.jar and sapj2eeclient.jar in your CLASSPATH.
You can find them at: C:\usr\sap\{SID_NUMBER}\JC\j2ee\j2eeclient directory.
HTH
Martin
Hi Martin,
Now i get the stack trace which i have pasted below
java.lang.NoClassDefFoundError: com/sap/tc/logging/LogController
at com.sap.engine.services.security.login.SecurityContext.setAnonymousPrincipal(SecurityContext.java:492)
at com.sap.engine.services.security.login.TicketGenerator.getSecuritySession(TicketGenerator.java:119)
at com.sap.engine.services.security.login.SecurityContext.load(SecurityContext.java:230)
at com.sap.engine.services.rmi_p4.Message.loadContextObject(Message.java:363)
at com.sap.engine.services.rmi_p4.Message.parseMessage(Message.java:239)
at com.sap.engine.services.rmi_p4.Message.getByteArrayInputStream(Message.java:314)
at com.sap.engine.services.rmi_p4.Call.getResultStream(Call.java:176)
at com.sap.engine.services.security.remote.RemoteSecurity_Stub.getRemoteLoginContext(RemoteSecurity_Stub.java:657)
at com.sap.engine.services.security.remote.login.RemoteLoginContext.<init>(RemoteLoginContext.java:93)
at com.sap.engine.services.jndi.implclient.LoginHelper.clientSideLogin(LoginHelper.java:78)
at com.sap.engine.services.jndi.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:402)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at com.wipro.jmsproducer.CProducer.main(CProducer.java:31)
Exception in thread "main"
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
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.