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] trying to write a standalone java api to schedule report

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] trying to write a standalone java api to schedule report
 Login/Join
 
<Barry>
posted
We are trying to create a Schedule using Report Caster java API. We are getting
a null pointer exception while creating a schedule instance using an API call
similar to

manager.createScheduleInstance(TimeInfo.ONCE,Distribution.LIBRARY,Task.WEBFOCUS-
_SERVER_PROCEDURE);

We are running a simple stand alone java program using the API to connect to
Report Caster on SOLARIS Server. Not using MRE client or any application server.
Included the following Jar files in class path.
reportcaster.jar,ibi_xml_apis_1_3.jar,webfocus_caster.jar,ojdbc14.jar.

The exception is java.lang.NullPointerException
at ibi.broker.security.ManagementContext.getConnectionManager(ManagementContext-
.java:111)
at ibi.broker.api.cci.interactive.AbstractInteractive.init(AbstractInteractive.-
java:64)
at ibi.broker.api.cci.interactive.AbstractInteractive.(AbstractInteractiv-
e.java:57)
at ibi.broker.api.cci.interactive.schedule.CreateScheduleInstance.(Create-
ScheduleInstance.java:58)
at ibi.broker.api.cci.interactive.schedule.ScheduleManagerImpl.createScheduleIn-
stance(ScheduleManagerImpl.java:129)

are we missing any jar files

This message has been edited. Last edited by: Kerry,
 
Report This Post
<Barry>
posted
I was wondering if the problem is in the connection to the Oracle Rcaster repository. We think that we copied over the correct jar files but do we have to configure to connect to the Oracle database.

We have a distribution server and WebFOCUS Reporting Server available and we tried the sample java api and had a connection failure. Do we have to set up the Oracle connection and send the Webfocus id for the Reporting server or will the java api automatically go to the connection on the reporting server?
 
Report This Post
Guru
posted Hide Post
Barry,

The first thing that I would try is to create a test job in caster itself.

Fernando


Prod WF 8.1.04, QA WF 8.2.03, Dev WF 8.2.03
 
Posts: 278 | Registered: October 10, 2006Report This Post
Virtuoso
posted Hide Post
You WILL have to have the Oracle JAR files available and on the classpath, but you do not need to pass and credentials. The API will query the report caster server to get the appropriate credentials. You will need to have everything on the classpath that is required, including a bunch of other stuff that you wouldn't necessarily think of. The following is a stand alone for executing an existing schedule. You might find stuff you need in there:

/*
 * Created on Apr 14, 2008
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.ibi.rcaster;

import ibi.broker.api.cci.ScheduleManager;
import ibi.broker.api.data.schedule.Schedule;
import ibi.broker.api.CasterManagedConnectionFactory;
import ibi.broker.api.cci.CasterConnection;
import ibi.broker.api.cci.CasterConnectionFactory;
import ibi.broker.api.cci.PasswordCredential;
import javax.resource.cci.ConnectionSpec;

public class InvokeSchedule {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("*--- ReportCaster Schedule Invoke Procedure ---*");

		String scheduleId = null;
		String userId = null;
		String passWord = null;
		String hostName = null;
		String hostPort = null;

		try {

			for (int i=0; i<args.length; i++) {
				String argument = args[i];

				if (!argument.startsWith("-")) {
					// called with the wrong argument.
					System.out.println("Error: Arguments must start with a [-]");
					displayHelp();
					System.out.println("*--- Schedule Invokation Utility FAILED. ---*");
					System.out.println("*--- Schedule Invokation Utility END ---*");
					System.exit(-1);
				}

				// check for help
				if (argument.startsWith("-?")) 
					displayHelp();

				if (argument.startsWith("-S"))
					scheduleId = argument.substring(2);

				if (argument.startsWith("-H")) 
					hostName = argument.substring(2);

				if (argument.startsWith("-L")) 
					hostPort = argument.substring(2);

				if (argument.startsWith("-U")) 
					userId = argument.substring(2);

				if (argument.startsWith("-P")) 
					passWord = argument.substring(2);
			}

			if (scheduleId == null || hostPort == null || hostName == null || userId == null || passWord == null) {
				
				System.out.println("Error: command line arguments were not valid.");
				displayHelp();
				System.out.println("*--- Schedule Invokation Utility FAILED. ---*");
				System.out.println("*--- Schedule Invokation Utility END ---*");
				System.exit(-1);
			
			} else {

				System.out.println(" ");
				System.out.println("Schedule Invokation Procedure:");
				System.out.println("Schedule Id: " + scheduleId);
				System.out.println("ReportCaster Host: " + hostName);
				System.out.println("ReportCaster Port: " + hostPort);
				System.out.println("User id: " + userId);
				System.out.println(" ");

				CasterManagedConnectionFactory managedConnectionFactory = new CasterManagedConnectionFactory();
				managedConnectionFactory.setServerName(hostName);
				managedConnectionFactory.setPortNumber(hostPort);
				CasterConnectionFactory connectionFactory = (CasterConnectionFactory)managedConnectionFactory.createConnectionFactory();
				ConnectionSpec credential = new PasswordCredential(userId, passWord.toCharArray());
				CasterConnection casterConnection = ((CasterConnection)connectionFactory.getConnection(credential));

				ScheduleManager manager = casterConnection.getScheduleManager();

				//get schedule by id
				Schedule schedule = manager.getSchedule(scheduleId);

				//run schedule 
				String processId = manager.run(schedule);

				// Print result
				System.out.println("processId = " + processId);
				System.out.println(" ");
				System.out.println("*--- Schedule Invokation Utility END ---*");
			}

		} 
		catch (Exception e) {
			System.out.println("Exception in main: " + e.toString());
			System.exit(-1); 
		}
		System.exit(0);
	}

	private static void displayHelp() {
		System.out.println(" ");
		System.out.println("Schedule Invokation Utility Command Line Help");
		System.out.println("    -?      Display Help.");
		System.out.println("    -H      Server Host Name: [localhost]");
		System.out.println("    -L      Server Listening Port: [8200]");
		System.out.println("    -U      Connection User ID.");
		System.out.println("    -P      Connection Password.");
		System.out.println("    -S      Schedule ID: [S1356osnpo01]");
		System.out.println(" ");
		System.out.println("Examples:");
		System.out.println(" java com.ibi.rcaster.InvokeSchedule -Hlocalhost -L8200 -Uuserid -Ppassword -SS1356osnpo01");
		System.exit(-1);		
	}

}
  


The followin are all the JARs that were required on my classpath (I was using MySQL tables).

C:/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/reportcaster.jar
C:/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/connector-api.jar
C:/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/ibi_xml_apis_1_3.jar
C:/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/webfocus_caster.jar
C:/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/jlink.jar
C:/ibi/ReportCaster76/lib/ibi_xerces_2_7_1.jar
C:/install/MySql/mysql-connector-java-5.0.8/mysql-connector-java-5.0.8-bin.jar 


"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
<Barry>
posted
dhagan

Thanks for the post we were missing a jar file, you were a great help
 
Report This Post
Member
posted Hide Post
dhagan,

i know this is an old post but maybe you can help... your solution is exactly what i was looking for but i fail to get it running.

i can compile your code but during executin i got some errors - also i'm not that good in java programming to be honest :

compile:

dwh1 tmp # javac -classpath "/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/reportcaster.jar:/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/connector-api.jar:/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/ibi_xml_apis_1_3.jar:/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/webfocus_caster.jar:/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/jlink.jar:/opt/ibi/ReportCaster76/lib/ibi_xerces_2_7_1.jar:/usr/lib/jvm/java-6-sun-1.6.0.12/jre/lib/ext/mysql-connector-java-5.1.7-bin.jar" InvokeSchedule.java
dwh1 tmp #

execution:

dwh1 tmp # java -classpath ".:/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/reportcaster.jar:/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/connector-api.jar:/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/ibi_xml_apis_1_3.jar:/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/webfocus_caster.jar:/opt/ibi/WebFOCUS76/webapps/rcaster76/WEB-INF/lib/jlink.jar:/opt/ibi/ReportCaster76/lib/ibi_xerces_2_7_1.jar:/usr/lib/jvm/java-6-sun-1.6.0.12/jre/lib/ext/mysql-connector-java-5.1.7-bin.jar" InvokeSchedule
Exception in thread "main" java.lang.NoClassDefFoundError: InvokeSchedule (wrong name: com/ibi/rcaster/InvokeSchedule)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: InvokeSchedule. Program will exit.


any easy hint what i do wrong?

thanks
torsten


webfocus76
debian linux
HTML
 
Posts: 8 | Registered: September 10, 2009Report This Post
Virtuoso
posted Hide Post
I posted this in a PM, but just to state this for the record: My guess is that you java file is not in the directory that is reflected in the package statement. Easy fix is to comment out the package line in the java code, then recompile, then re-execute.


"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
Member
posted Hide Post
thanks a lot - works like a charm


webfocus76
debian linux
HTML
 
Posts: 8 | Registered: September 10, 2009Report 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] trying to write a standalone java api to schedule report

Copyright © 1996-2020 Information Builders