Java transformer error

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
chetan.c
Participant
Posts: 112
Joined: Tue Jan 17, 2012 2:09 am
Location: Bangalore

Post by chetan.c »

Hi,

In the beginning of the code,can you show us what is the package and class you are pointing to.

Like this.. http://tinyurl.com/d8sgf6n.


Thanks,
Chetan.C
sneha123
Participant
Posts: 17
Joined: Mon Nov 05, 2012 8:42 am

Post by sneha123 »

sample code i took from dsxchange only


package SampleJavaPlugIns;

import com.ascentialsoftware.jds.Row;
import com.ascentialsoftware.jds.Stage;
import com.ascentialsoftware.jds.Column;
/* import com.ascentialsoftware.tr4j.*;

/**
* @author eostic
*
* DataStage PlugIn Development
*
* Ernie Ostic
* Ascential Software
*
* This class is based on one of the samples in the javadocs written by ASCL engineering.
*
* It has then been customized to test additional calls supported by the java plugin API,
* and illustrate how the plugin can "discover" how it is being used in the job. It certainly does NOT
* exercise every possible call, nor explore all the things, such as reference links, etc.
* that can be performed with javaPack. However, it is helpful in validating that the plugins
* are working and provides another baseline example.
*
* NO WARRANTIES OR VALIDATED TECHNIQUES IMPLIED BY THIS CODE. USE THIS AT YOUR OWN RISK AND FOR
* EDUCATIONAL AND LEARNING PURPOSES ONLY.
*
*/
public class ExamineRows extends Stage {

public void initialize()
{

//*------------------------------------------------------------------------------------*
// What kind of Links do I have (am I being invoked with)...ie what type of Stage
//
// a JavaTransformer Stage would typically have Input -and- Output links...
//*------------------------------------------------------------------------------------*

/* trace("initialization analysis");
if (hasInputLink()) {warn("Input Link Found"); }
if (hasOutputLink()) {warn("Output Link Found"); }
if (hasReferenceLink()) {warn("Reference Link Found"); }
if (hasRejectLink()) {warn("Reject Link Found"); } */

//Ultimately, determining link types should trigger branching to different parts of the code,
//depending on what type of operation we're expected to be coding for...source/target/transform.
//This way a java developer could (in theory, but less likely in reality) write a very "generic" class
//that would work in many situations, perhaps having it's "function" passed in as a property

//*------------------------------------------------------------------------------------*
// Obtain user properties from the generic "box" property of the plugin GUI
//*------------------------------------------------------------------------------------*

String UserProperties=getUserProperties();

//*------------------------------------------------------------------------------------*
//write values of the user properties to the DS log as info message
//*------------------------------------------------------------------------------------*
//* info (UserProperties);
trace("For the first row list the column names and their SQL data types.");

if (isTraceOn()) {
trace("Trace is on");
}
//*------------------------------------------------------------------------------------*
// Trace works, but only if the user, in the Director, selects the third radio button
// for "Subroutine Calls" ...IN COMBINATION with any additional radio button of the 4.
//*------------------------------------------------------------------------------------*

trace("Tracing has been turned on"); //only appears if tracing is on from Director
}



int rowNumber;
int outColNumber;

public int process()
{
// Read a row, convert all its columns to upper case,
// and write the result. If any column of the input row
// contains the character '*', the row is rejected.


Row inputRow = readRow();

trace("Java class just received a row...");

rowNumber = rowNumber + 1;

if (inputRow == null) {
return OUTPUT_STATUS_END_OF_DATA;
}

boolean reject = false;
int columnCount = inputRow.getColumnCount();
Row outputRow = createOutputRow();


for (int columnNumber = 0; columnNumber < columnCount; columnNumber++) {
String value = inputRow.getValueAsString(columnNumber);


if (rowNumber == 1)
{

Column MetaDataForMyColumn = inputRow.getColumn(columnNumber);
String colName = MetaDataForMyColumn.getName();
int colSQLType=MetaDataForMyColumn.getSQLType();
String colSQLTypeName=Column.getSQLTypeName(colSQLType);


trace(colName);
trace(colSQLTypeName);


}
//*--------------------------------------------------------------------------------------------------------------
// "reject" any rows that have asterisks [these will go down a link that the DS developer marks as "reject" link
//*--------------------------------------------------------------------------------------------------------------

outColNumber=columnNumber;

if (value.indexOf("*") >=0) {
reject = true;
// warn("Value found with Asterisk. Reject the row");
outputRow.setValueAsString(outColNumber, value);
} else {
outputRow.setValueAsString(outColNumber, value.toUpperCase());
}
}

if (reject) {
rejectRow(outputRow);
} else {
writeRow(outputRow);
}
return OUTPUT_STATUS_READY;
}

}
Sneha!!!!!
chetan.c
Participant
Posts: 112
Joined: Tue Jan 17, 2012 2:09 am
Location: Bangalore

Post by chetan.c »

Hi,


Create a folder "SampleJavaPlugIns" in the directory of your present class file location.
Your class file should be present inside the "SampleJavaPlugIns" folder.




Thanks,
Chetan.C
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

The details of how to do this are in an annotation in the Job sample itself...load the .dsx that you downloaded with the source ...there is an annotation box that outlines how deep to specify the classpath based on whether you are using a .jar or an independent simple class file as in the example.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

Actucally your class name is ExamineRows not the SampleJavaPlugIns.ExamineRows. SampleJavaPlugIns is your package's name. So just type "ExmineRows" (without quotes) in the Transformer Class Name box.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or just read the annotation. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
sneha123
Participant
Posts: 17
Joined: Mon Nov 05, 2012 8:42 am

Post by sneha123 »

awesome
Thanks Guys it is done now
Sneha!!!!!
eq8547
Premium Member
Premium Member
Posts: 4
Joined: Mon Feb 25, 2013 9:39 am
Location: SAN ANTONIO

Java Transformer sample job

Post by eq8547 »

Hi Ernie,

Can you please let me know where I can find the dsx file of the Job sample you mentioned above.

I'm encountering the same java.lang.ClassNotFoundException issue.

Thanks,
Edgar
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Probably should be a new thread, but see if you can download it at www.dsrealtime.com . Look in the table of contents (link at upper right) for posts on java. Some people have had issues downloading it. You have to rename it after you download (see the post).

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply