Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [ClOSED] calljava class

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[ClOSED] calljava class
 Login/Join
 
Guru
posted
This is my first time using java in a webfocus report. I don't really know what I am doing so any help is appreciated.

To test this out, I created a jar file for the java class on stored it on our development server. I included the jar file location and the jscom3.jar location in the classpath environement variable. In the procedure I am using the following code (I don't need parameters yet):

 
SET EXORDER=PGM/FEX
CALLJAVA classpath.class
-EXIT
 


This is the error I receive:
(FOC1522) ntjprerr: CALLPGM connect error caused by:
(FOC1522) java.lang.ClassNotFoundException: ibi.srv77.HelloWorldApp. CPJAVA:
(FOC1522) Error in processing CONNECT command for Class
(FOC1522) ibi.srv77.HelloWorldApp
(FOC1522)

Any help would be appreciated. (the ibi.srv77 is the actual class and the location of the jar file)

CLASSPATH C:\ibi\srv77\home\etc\java\java15\jscom3.jar; C:\ibi\srv77\HelloWorldApp.jar

Another thing, I want this jar file to run on the users computer since I will be using Desktop.getDesktop()

This message has been edited. Last edited by: J,


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
 
Posts: 402 | Location: Upland, IN | Registered: June 08, 2012Report This Post
Virtuoso
posted Hide Post
The class is not found, so you class path is not correct. I'm not sure what you mean by putting the JSCOM3.jar on the class path, but you should add the JAR to the class path as defined in the Java Services properties. You can do that through the server console.

Once you add the JAR to the proper class path, you should then add a semi-colon and END to you CALLJAVA command.

Sample:
-* run the bulk loader here.
CALLJAVA com.ibi.calljava.CallMySQLBulkLoad,
  &U,
  &T,
  &RFNAME,
  &COLNAMES,
  &D;
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS MSBULK 
END
-RUN  


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Guru
posted Hide Post
Thanks dhagen,
If I try to run the jar on my pc it works fine. If I try to run it on the server, it says "cannot find main class.."


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
 
Posts: 402 | Location: Upland, IN | Registered: June 08, 2012Report This Post
Master
posted Hide Post
I believe if the required jar files are not in the report server java CLASSPATH then you need to add them either in the console.




Scott

 
Posts: 865 | Registered: May 24, 2004Report This Post
Virtuoso
posted Hide Post
Post your code. It sounds to me like you are just creating a class, but you should be using the CallPGM Java API. You have to implement the callpgm interface to make the process callable from the server. See the "Stored Procedure Reference" manual for instructions and examples.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Expert
posted Hide Post
I don't think you will be able to have the jar file run on the client pc, at best perhaps on the Web server, unless you have a applet or something.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Guru
posted Hide Post
Here is everything I have done.

-Manually compile java file on server:
set JARS=C:\ibi\srv77\home\etc\java\java15
javac HelloWorldApp.java -classpath %JARS%\ntj2c.jar;%JARS%\ibtrace.jar
jar cvf HelloWorldApp.jar HelloWorldApp.class

-Environment variable:
CLASSPATH=C:\ibi\srv77\com\ibi\calljava\HelloWorldApp.jar

-Restart server

-Run focus file containing following code
 
-* File jh_mail.fex
SET EXORDER=PGM/FEX
CALLJAVA com.ibi.calljava.HelloWorldApp;
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS MSBULK 
END
-RUN 
 


-Error Message:
(FOC1522) ntjprerr: CALLPGM connect error caused by:
(FOC1522) java.lang.ClassNotFoundException: com.ibi.calljava.HelloWorldApp.
(FOC1522) CPJAVA: Error in processing CONNECT command for Class
(FOC1522) com.ibi.calljava.HelloWorldApp
(FOC1522)

-Java code:
 
package com.ibi.calljava;


import javax.mail.*;
import javax.mail.internet.*;

import java.awt.Desktop;
import java.io.*;
class HelloWorldApp {
    public static void main(String[] args) throws IOException, AddressException, MessagingException {
    	String mailto = "user@example.com";
    	MimeMessage message = new MimeMessage(Session.getInstance(System.getProperties()));
    	MimeBodyPart content = new MimeBodyPart();
    	content.setText("");
    	Multipart multipart = new MimeMultipart();
    	multipart.addBodyPart(content);
    	message.setContent(multipart);
    	message.setHeader("X-Unsent", "1");
    	message.setSubject("hi");
    	message.setRecipients(Message.RecipientType.CC, mailto);
    	File mailFile = new File("c:/bmail.eml");
    	FileOutputStream stream = new FileOutputStream(mailFile);
    	message.writeTo(stream);
    	stream.close();
    	Desktop.getDesktop().open(mailFile);
    }
}
 

Basically this creates a .eml file to be opened with the default mail client. I was trying to come up with an alternative to the standard mailto since we were running into url character limit issues. Since I would be opening the mailFile on the users PC I am assuming this code would have to run on their PC.

This message has been edited. Last edited by: J,


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
 
Posts: 402 | Location: Upland, IN | Registered: June 08, 2012Report This Post
Expert
posted Hide Post
Can you check to see what the classpath is when the job is running ?

Add one of these to your fex

DOS echo %CLASSPATH%
WINNT echo %CLASSPATH%
! echo %CLASSPATH%


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Guru
posted Hide Post
In my fex?
 
-* File jh_mail.fex
SET EXORDER=PGM/FEX
DOS echo %CLASSPATH%
CALLJAVA com.ibi.calljava.HelloWorldApp;
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS MSBULK 
END
-RUN 
 

Output:
%CLASSPATH%
(FOC1522) ntjprerr: CALLPGM connect error caused by:
(FOC1522) java.lang.ClassNotFoundException: com.ibi.calljava.HelloWorldApp.
(FOC1522) CPJAVA: Error in processing CONNECT command for Class
(FOC1522) com.ibi.calljava.HelloWorldApp
(FOC1522)

Am I supposed to be setting the classpath at runtime?


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
 
Posts: 402 | Location: Upland, IN | Registered: June 08, 2012Report This Post
Guru
posted Hide Post
Just a side note, there was one time the error was different and mentioned having trouble reading a particular item within the class, but now it keeps failing to recognize the class period


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
 
Posts: 402 | Location: Upland, IN | Registered: June 08, 2012Report This Post
Virtuoso
posted Hide Post
J, it will not see your class because it is not created properly. You HAVE to implement the callpgm and all the necessary function calls. Only then will it see the class and execute it for you. Read the doc! The following is an example of what has to be there. The class is COLRGetFileName, and what it does is not that important, what is important is that it implements the callpgm, and it has all the required functions (execute, execute, fetch):
/*
 * Created on Dec 17, 2008
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.ibi.calljava;

import com.ibi.util.ValueEncoder;
import ibi.callpgm.callpgm;
import ibi.callpgm.ibiAnswerSet;
import ibi.callpgm.ibianswr;
import ibi.trace.IBILogFactory;
import ibi.trace.ILogger;

public class COLRGetFileName implements callpgm {
	private ibianswr answr = null;
	private int rows = 0;
	private int rownum = 0;
	private String report = null;
	private String key = null;
	private static final ILogger log = IBILogFactory.getEdaprintLogger();
	private boolean debug = false;
	
	public COLRGetFileName() {}

	/* Required for some reason. */
	public ibianswr	execute(String username, String password, Object object, String[] parms) throws Exception
	{ return null; }

	/* */
	public ibianswr	execute(String username, String password, String[] parms) throws Exception
	{
		if (parms.length > 2)
			debug = true;
		report = parms[0];
		key = parms[1];
		rows = 1; 
		answr = new ibianswr(1);
		answr.setColName(1, "ENC_NAME");
		answr.setColType(1, ibiAnswerSet.IBI_ALPHA);
		answr.setColSize(1, parms[0].length()*3);
		return answr;
	}

	public Integer fetch() throws Exception {
		rownum++;
		if (rownum > rows) {
			return callpgm.IBI_EOD;
		} else {
			if (debug) {
				log.info("In file name is: " + report);
				log.info("Out file name is: " + ValueEncoder.encodeInput(report, key));
			}
			answr.setColValue(1, ValueEncoder.encodeInput(report, key));
			return callpgm.IBI_DATA;
		}
	}
}

  


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Virtuoso
posted Hide Post
quote:
Originally posted by J:
Basically this creates a .eml file to be opened with the default mail client. I was trying to come up with an alternative to the standard mailto since we were running into url character limit issues. Since I would be opening the mailFile on the users PC I am assuming this code would have to run on their PC.


This is not a good candidate for callpgm. The callpgm runs on the WF server and there is no desktop. You have to change this to either email the message directly without user intervention, or change this to a JSP or SERVLET and return a HTML page that can then issue a mailto action via javascript.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Guru
posted Hide Post
Thank you for the help.


WebFOCUS 7.7.03/8.0.08
Dev Studio 7.7.03/8.0.08
App Studio 8.0.08
Windows 7
ALL Outputs
 
Posts: 402 | Location: Upland, IN | Registered: June 08, 2012Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [ClOSED] calljava class

Copyright © 1996-2020 Information Builders