ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Java class not found in ESQL external Java call

Post new topic  Reply to topic
 Java class not found in ESQL external Java call « View previous topic :: View next topic » 
Author Message
msnyder
PostPosted: Sat Jan 28, 2006 8:14 pm    Post subject: Java class not found in ESQL external Java call Reply with quote

Apprentice

Joined: 24 May 2002
Posts: 32
Location: Jacksonville, FL

I'm getting a Java class not found error when invoking:

Code:
BROKER SCHEMA ESQL
CREATE PROCEDURE getValue(IN  codeType CHAR,
                        IN  key        CHAR,
                        OUT value   CHAR)
   RETURNS  CHAR
   LANGUAGE JAVA
   EXTERNAL NAME "ESQL.getValue";

I have included ESQL.jar which contains the getValue in my barfile. Obviously, I must not be referencing it correctly in this procedure definition. What change do I need to make? Thanks.
Back to top
View user's profile Send private message
msnyder
PostPosted: Sun Jan 29, 2006 8:48 am    Post subject: Additional information Reply with quote

Apprentice

Joined: 24 May 2002
Posts: 32
Location: Jacksonville, FL

Here is more information relevant to this issue:

1. The ESQL procedure definition is contained in a separate project schema named ESQL.
2. The external java method is contained in a separate Java project named ESQL_Java.
3. Both the ESQL and ESQL_Java projects are defined as project references to the message flow project MessageFlows.
4. The signature of the ESQL procedure definition matches the signature of the Java method, i.e. returns a string with 3 string parameters.

Quote:
Deploying Java classes
We recommend that you deploy your Java classes inside a Java Archive (JAR) file. There are two ways to deploy a JAR file to the broker:
1. By adding it to the Broker Archive (BAR) file
This is the recommended method.
You can add a JAR file to the BAR file manually, by hand, or automatically, using the tooling. It is recommended that you use the tooling.
If the tooling finds the correct Java class inside a referenced Java project open in the workspace, it automatically compiles the Java class into a JAR file and adds it to the BAR file. This is the same procedure that you follow to deploy a Java Compute node inside a JAR, as described in User-defined node classloading.
When deploying a JAR file from the tooling, a redeploy of the BAR file containing the JAR file causes the referenced Java classes to be reloaded by the flow that has been redeployed; as does stopping and restarting a message flow that references a Java class. Ensure that you stop and restart (or redeploy) all flows that reference the JAR file that you want to update. This avoids the problem of some flows running with the old version of the JAR file and other flows running with the new version.
Note that the tooling will only deploy a JAR file; it will not deploy a standalone Java class file.
2. By placing it in either of the following:
a. The <Workpath>/shared-classes/ folder on the machine running the broker
b. The CLASSPATH environment variable on the machine running the broker
This procedure must be done manually; you cannot use the tooling.
In this method, redeploying the message flow does not reload the referenced Java classes; neither does stopping and restarting the message flow. The only way to reload the classes in this case is to stop and restart the broker itself.
Note that although you can deploy a standalone Java class by placing it in one of the two locations above, it is still recommended that you use a JAR file instead.
To enable the broker to find a Java class, ensure that it is in one of the above locations. If the broker cannot find the specified class, it throws an exception.
Although you have the choices shown above when deploying the JAR file, it is recommended that you choose the first method (allowing the tooling to deploy the BAR file) because this provides the greatest flexability when redeploying the JAR file.

Even though ESQL_Java is a Project Reference, is opened in the workspace, and is referenced by the MessageFlow project, the tooling never automatically created a jar file as part of the bar file build process. So, I manually created a jar file in the ESQL_Java project which did get included by the tooling in the bar file.

However, the Java class is not found by the broker during runtime even though the jar file was deployed along with the other pieces of the project. Help!!!!
Back to top
View user's profile Send private message
msnyder
PostPosted: Sun Jan 29, 2006 8:11 pm    Post subject: Reply with quote

Apprentice

Joined: 24 May 2002
Posts: 32
Location: Jacksonville, FL

I've move ESQL.java and ESQL.class to a Java project that is definitely getting referenced by other functionality via Java node code. For this Java project, the broker is automatically creating the jar file and the other classes/methods in the jar file are getting invoke without problem albeit not from an ESQL procedure/function. However, the ESQL function call is still getting "Java method could not be found".

Here are the combinations I've tried without success for the external name - remember this class and method are contained in a jar file included in the bar file:

EXTERNAL NAME "PackageName.ClassName.Method" e.g. EXTERNAL NAME "CommonWMB.ESQL.getValue"
EXTERNAL NAME "ClassName.Method" e.g. EXTERNAL NAME "ESQL.getValue"
EXTERNAL NAME "Method" e.g. EXTERNAL NAME "getValue" which causes a syntax error

At this point, I'm assuming this is a bug unless someone can show me otherwise.
Back to top
View user's profile Send private message
mgk
PostPosted: Mon Jan 30, 2006 1:01 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

This looks like the signature of the java method does not match the esql signature, re-check this.

It is also worth checking that the name of the package in the Jar file is correctly specified in the external name clause. When you have made the bar file, open it up (it is just a zip file) and then open up the jar file (again just a zip file). Check the directory path (which follows the package name) inside the jar to the .class file. You need to specify this exactly in the external name clause.

If this does not work, can you post your Java code and the directory listing of the contents of the jar file.
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
msnyder
PostPosted: Mon Jan 30, 2006 3:45 am    Post subject: Reply with quote

Apprentice

Joined: 24 May 2002
Posts: 32
Location: Jacksonville, FL

The path of ESQL.class and ESQL.java inside of CommonWMB.jar is CommonWMB\. Here is the Java code:
Code:
package CommonWMB;

import CommonWMB.Cache;

public class ESQL {
   public static String ok   = "OK";
   public static String cacheError = "ERROR: ";
   public static String codeIndicator = "!!";

   public static String getValue(String codeType, String key, String value) {
      try {
         if (codeType == null) {
            return cacheError + "CodeType cannot be null";
         }
         String codeTypeUpper   = codeType.toString().toUpperCase();
         if (codeTypeUpper != "CODE" || codeTypeUpper != "DECODE") {   
            return cacheError + "CodeType must be CODE or DECODE";
         }   
         if (key == null) {
            return cacheError + "Key cannot be null";
         }
         String fullKey   = codeType.substring(1, 1) + codeIndicator + key;
         value = Cache.getInstance().get(fullKey).toString();
         
         return ok;

      } catch (Exception e) {
         return cacheError + "Unknown exception";
      }
   }
}
and I'm reposting the ESQL function definition:
Code:
BROKER SCHEMA ESQL

CREATE FUNCTION getValue(IN codeType CHAR, IN key CHAR, OUT cacheValue CHAR)
RETURNS CHAR
LANGUAGE JAVA
EXTERNAL NAME "ESQL.getValue";
I've also tried the following combinations for the external name:

CommonWMB.ESQL.getValue
CommonWMB.getValue

but still get the "Java class not found" error. Thanks in advance for your help.
Back to top
View user's profile Send private message
mgk
PostPosted: Mon Jan 30, 2006 4:58 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

Like I said, the problem is your ESQL signature. It does not match the Java signature (or vice versa).

Your Java sig is:

Code:
public static String getValue(String codeType, String key, String value)


To match this your ESQL sig has to be:

Code:
CREATE FUNCTION getValue(IN codeType CHAR, IN key CHAR, IN cacheValue CHAR)
RETURNS CHAR
LANGUAGE JAVA
EXTERNAL NAME "CommonWMB.ESQL.getValue";


Note that param three is now an IN param, and the EXTERNAL NAME includes the package name.

However, if you actually want param 3 to be an OUT param (and your esql suggests you do) then you need to change your Java sig to be:

Code:
public static String getValue(String codeType, String key, String[] value)


Note the that param 3 is now an array (and you must still include the package name). Obviously you will have to change your methods body to assign values to the array [0] element.

I think you should review the "ESQL to Java Datatype Mapping Table" that can be found in the docs under CREATE PROCEDURE.


Regards,


MGK
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Java class not found in ESQL external Java call
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.