Author |
Message
|
yararaca |
Posted: Mon Jan 10, 2005 1:19 am Post subject: Calling EJB or web service from java plugin node |
|
|
Newbie
Joined: 10 Jan 2005 Posts: 4
|
Hi all
I would like to call either session EJB or a web service from within java plugin node. Unfortunatelly, neither seems to work. I have read several related threads, but didn't find any solution.
Can anybobody confirm that it is possible or am I just wasting my time? |
|
Back to top |
|
 |
mqmhr |
Posted: Mon Jan 10, 2005 4:06 am Post subject: |
|
|
Centurion
Joined: 28 Dec 2004 Posts: 105
|
It is very much possible to call a EJB from a Java Plugin (have seen the implementation in a project). I am not sure about Web Services, but if you are using WBIMB 5, then you can call Web Services using IBM primitive nodes. |
|
Back to top |
|
 |
JLRowe |
Posted: Mon Jan 10, 2005 5:17 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
What specifically is going wrong when you cannot call the EJB?
It is very do-able, although the EJB cannot participate in the message broker transaction. |
|
Back to top |
|
 |
yararaca |
Posted: Mon Jan 10, 2005 6:47 am Post subject: |
|
|
Newbie
Joined: 10 Jan 2005 Posts: 4
|
Thanks for info that it should work, I'll keep trying.
"What specifically is going wrong when you cannot call the EJB?" - well, that is really weird
I have a code like this:
public void evaluate(MbMessageAssembly assembly, MbInputTerminal arg1)
throws MbException {
try {
File elogFile =
new File(
"C:\\Share\\mqsi\\outfrombasicnode"
+ System.currentTimeMillis()
+ ".htm");
PrintStream elog =
new PrintStream(new FileOutputStream(elogFile), true);
System.setOut(elog);
System.out.println("Before Message manipulation");
MbMessage newMsg = new MbMessage(assembly.getMessage());
MbMessageAssembly newAssembly =
new MbMessageAssembly(assembly, newMsg);
MbOutputTerminal out = getOutputTerminal("out");
System.out.println("before properties");
Properties p = new Properties();
p.put(
Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
p.put(Context.PROVIDER_URL, "iiop://10.132.189.12:2809");
System.out.println("before ic");
InitialContext ic = new InitialContext(p);
System.out.println("after ic");
Object tmpObj = (Object) ic.lookup("ejb/bean/ListServantHome");
System.out.println("after lookup");
ListServantHome lsh =
(ListServantHome) PortableRemoteObject.narrow(
tmpObj,
ListServantHome.class);
System.out.println("after narrow");
ListServant ls = lsh.create();
System.out.println("End");
out.propagate(newAssembly);
newMsg.clearMessage();
} catch (Exception e) {
System.out.println("Exception block");
System.out.println(e.getMessage());
throw new RuntimeException();
} finally {
System.out.println("Finally block");
}
}
Everything is ok up to "before ic". Then the code neither continues to "after ic" nor falls to the "Exception block". It goes right to "Finally block" and the message finishes in fail terminal.
What can be wrong? I am lost. |
|
Back to top |
|
 |
JLRowe |
Posted: Mon Jan 10, 2005 8:51 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
What J2EE application client are you using?
If you are using the Thin client, then you have to fully qualify your JNDI name for the bean, dump the namespace to check the fully qualified name. |
|
Back to top |
|
 |
yararaca |
Posted: Tue Jan 11, 2005 5:59 am Post subject: |
|
|
Newbie
Joined: 10 Jan 2005 Posts: 4
|
I have WebSphere server installed on the MQ machine too, but I access EJB on yet another machine. Standalone client invoked from command line works ok.
I got one step further. The reason why I wasn't getting any exception was because I named the implementation class incorrectly. When I corrected it, the strange behaviour stopped. Calling of Web service is already OK, but EJB still doesn't work.
Currently I am getting following exception:
javax.naming.ServiceUnavailableException: A communication failure occurred while attempting to obtain an initial context using the provider url: "iiop://10.132.189.12:2809". Make sure that the host and port information is correct and that the server identified by the provider url is a running name server. If no port number is specified, the default port number 2809 is used. Other possible causes include the network environment or workstation network configuration. Root exception is org.omg.CORBA.TRANSIENT: Connection refused: connect:host=localhost,port=3510 minor code: 4942F301 completed: No at com.ibm.CORBA.transport.TransportConnectionBase.connect(TransportConnectionBase.java:353) at com.ibm.rmi.transport.TCPTransport.getConnection(TCPTransport.java:178) at com.ibm.rmi.iiop.TransportManager.get(TransportManager.java:84) at com.ibm.rmi.iiop.GIOPImpl.createRequest(GIOPImpl.java:133) at com.ibm.rmi.iiop.GIOPImpl.createRequest(GIOPImpl.java:101) at com.ibm.CORBA.iiop.ClientDelegate._createRequest(ClientDelegate.java:2386) at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1273) at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1172) at com.ibm.CORBA.iiop.ClientDelegate.request(ClientDelegate.java:1925) at org.omg.CORBA.portable.ObjectImpl._request(ObjectImpl.java:245) at com.ibm.WsnBootstrap._WsnNameServiceStub.getProperties(_WsnNameServiceStub.java:37) at com.ibm.ws.naming.util.WsnInitCtxFactory.mergeWsnNSProperties(WsnInitCtxFactory.java:1090) at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootContextFromServer(WsnInitCtxFactory.java:676) at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootJndiContext(WsnInitCtxFactory.java:604) at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:478) at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:102) at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:408) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:131) at javax.naming.InitialContext.lookup(InitialContext.java:359) at Basic.evaluate(Basic.java:87)
Of course, that the obvious host and port information is correct and the server is running. From cmd the call succeeds. What can I do? |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 11, 2005 6:14 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It says "Connection refused".
Is it possible that you have security enabled on the EJB methods? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
yararaca |
Posted: Wed Jan 12, 2005 2:55 am Post subject: |
|
|
Newbie
Joined: 10 Jan 2005 Posts: 4
|
I finally made it working. Thanks everybody for cooperation.
I will write down the list of the errors I have made to help another newbies. I am a complete newbie too in MQ, so feel free to correct me if anything is wrong.
1) I named the elements incorrectly and as a result of it I wasn't getting any exceptions.
Working combination for me was:
Basic.msgnode in the development environment palette
Basic.java as the implementation class
"BasicNode" as the return value from getNodeName() method
2) The "Connection refused" issue turned out to be an error on the application server side. This is a general WebSphere application server issue. In administration console -> Servers -> Application Servers -> server1 -> End Points -> BOOTSTRAP_ADDRESS -> Host must be name or ip address. Not localhost or even bigger stupidity.
3) Add dozens of jars to classes directory. Follow NoClassDefFoundException hints. One little tricky is implfactory.jar as the Exception doesn't show clearly what it wants. |
|
Back to top |
|
 |
covxr5 |
Posted: Sun Oct 01, 2006 5:08 am Post subject: |
|
|
Novice
Joined: 10 Apr 2006 Posts: 10
|
Hi,
I am trying to call EJB from JavaComputeNode and I am getting "Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory" exception. I am not able to figure out what are the jar files needed to make it work. Could you please provide me the list of jar files required?
Thanks. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Oct 01, 2006 6:43 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
covxr5 wrote: |
Hi,
I am trying to call EJB from JavaComputeNode and I am getting "Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory" exception. I am not able to figure out what are the jar files needed to make it work. Could you please provide me the list of jar files required?
Thanks. |
Read up on the Websphere J2EE client. You will need all those jars on the classpath. If you ask me, it is a heavyweight client....
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|