| Author | 
		  Message
		 | 
		
		  | rock33 | 
		  
		    
			  
				 Posted: Mon Oct 07, 2013 5:50 am    Post subject: Call a java function from esql code in WMB v8.0 | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 22 Mar 2013 Posts: 12
  
  | 
		  
		    
			  
				Hi All,
 
 
I am trying to call user defined java function from esql.
 
 
I have created an Message broker application and added the java project (Myutil)as an project reference.
 
 
Once the bar file has generated from message broker tool kit Myutil.jar have successfully added as part of bar file.
 
 
Java project name : Myutil
 
 
Esql Code :
 
 
	CREATE FUNCTION Main() RETURNS BOOLEAN
 
	BEGIN
 
		CALL CopyMessageHeaders();
 
		-- CALL CopyEntireMessage();
 
		
 
		DECLARE c1 CHARACTER 'Good';
 
		DECLARE c2 CHARACTER 'Morning';
 
		DECLARE c3 CHARACTER;
 
		SET c3 = myProc( c1, c2);
 
		SET OutputRoot.XMLNSC.Result.value=c3;
 
		RETURN TRUE;
 
	END;
 
	
 
	
 
	CREATE FUNCTION  myproc( IN P1 CHARACTER, OUT P2 CHARACTER)
 
	 RETURNS CHARACTER
 
	 LANGUAGE JAVA 
 
	 EXTERNAL NAME "com.own.pack.MyClass.addValues";
 
	 
 
 
	 
 
Java method :
 
	 
 
	 package com.own.pack;
 
 
	public class MyClass {
 
	
 
	public static String addValues( String c1, String c2)
 
	{
 
		return (c1+c2);
 
	}
 
	}
 
	
 
	I am getting the below exception : 
 
	
 
	Text:CHARACTER:The Java method could not be found
 
	
 
	Even if I have placed the Myutil.jar file in Message broker runtime directory C:\Program Files\ibm\MQSI\8.0.0.2\classes\   but getting the same exception.
 
 
Any help would be really appreciated. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Mon Oct 07, 2013 5:57 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				Try importing the Global Cache Sample and comparing it to yours.
 
 
Perhaps your java project is not setup correctly? _________________ WMQ User since 1999
 
MQSI/WBI/WMB/'Thingy' User since 2002
 
Linux user since 1995
 
 
 
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lancelotlinc | 
		  
		    
			  
				 Posted: Mon Oct 07, 2013 6:07 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Knight
 
 Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA 
  | 
		  
		    
			  
				Your signature is not correct.
 
 
   
	| Code: | 
   
  
	| myproc( IN P1 CHARACTER, OUT P2 CHARACTER)  | 
   
 
 
 
But you are passing in two strings where the second string is an OUT value.
 
 
In addition, you really need to wrap your head around where this jar should go. Did you mean 'shared-classes' rather than 'classes' ? _________________ http://leanpub.com/IIB_Tips_and_Tricks
 
Save $20: Coupon Code: MQSERIES_READER | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | rock33 | 
		  
		    
			  
				 Posted: Mon Oct 07, 2013 6:25 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 22 Mar 2013 Posts: 12
  
  | 
		  
		    
			  
				Thanks a lot lancelotlinc for spotting the minor bug.
 
 
Its is working fine. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Mon Oct 07, 2013 6:28 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				
   
	| lancelotlinc wrote: | 
   
  
	|  Did you mean 'shared-classes' rather than 'classes' ? | 
   
 
 
 
DO NOT PUT ANYTHING IN THE CLASSES DIRECTORY. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | rock33 | 
		  
		    
			  
				 Posted: Mon Oct 07, 2013 6:54 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 22 Mar 2013 Posts: 12
  
  | 
		  
		    
			  
				Thanks mqjeff.
 
 
I have placed .jar file into shared-classes only. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |