java.lang.NullPointerException

package oracle.apps.fnd.cp.sample;

//import java.sql.Connection;

//import java.sql.DriverManager;

//import java.sql.PreparedStatement;

//import java.sql.ResultSet;

//import java.sql.SQLException;

//import java.sql.Statement;

import java.lang.Object;

import java.io.FileOutputStream;

import oracle.apps.xdo.delivery.DeliveryRequest;

import oracle.apps.xdo.delivery.DeliveryManager;

import oracle.apps.xdo.delivery.DeliveryPropertyDefinitions;

public class EbsEmail

{

private String outfile;

public EbsEmail( )

{

try {

//get the report title

// create delivery manager instance

DeliveryManager delMgr = new DeliveryManager();

// create a delivery request

DeliveryRequest delReq = delMgr.createRequest

(DeliveryManager.TYPE_SMTP_EMAIL);

// set email subject

delReq.addProperty(DeliveryPropertyDefinitions.SMTP_SUBJECT,

"EBS Report:");

// set SMTP server host

delReq.addProperty(

DeliveryPropertyDefinitions.SMTP_HOST, "smtp.yahoo.com");

// set the sender email address

delReq.addProperty(DeliveryPropertyDefinitions.SMTP_FROM,

"email@oracle.com");

// set the destination email address

delReq.addProperty(DeliveryPropertyDefinitions.SMTP_TO_RECIPIENTS,

"to_host@yahoo.com" );

// set the content type of the email body

delReq.addProperty(DeliveryPropertyDefinitions.SMTP_CONTENT_TYPE,

"application/pdf");

// set the document file name appeared in the email

delReq.addProperty(DeliveryPropertyDefinitions.SMTP_CONTENT_FILENAME,

"bursting_engine.pdf");

// set the document to deliver

delReq.setDocument("bursting_engine.pdf");

FileOutputStream out = new FileOutputStream(outfile);

out.flush();

// submit the request

delReq.submit();

// close the request

delReq.close();

out.flush();

}

catch (Exception e) {

e.printStackTrace();

}

}

public static final void main(final String[] args)

{

// Arguments passed

//1.$PROFILES$.CONC_REQUEST_ID

//2.$PROFILES$.FILENAME

//3.$PROFILES$.USER_ID

EbsEmail ebsMail = new EbsEmail();

ebsMail.setOutfile("test1.txt");

}

public void setOutfile( String string ){

outfile = string;

}

}

From the above code, I'm getting the exception:

java.lang.NullPointerException

at java.io.FileOutputStream.<init>(FileOutputStream.java:172)

at java.io.FileOutputStream.<init>(FileOutputStream.java:70)

at oracle.apps.fnd.cp.sample.EbsEmail.<init>(EbsEmail.java:64)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:274)

at java.lang.Class.newInstance0(Class.java:308)

at java.lang.Class.newInstance(Class.java:261)

at oracle.apps.fnd.cp.request.Run.main(Run.java:157)

Exception in thread "main" java.lang.ClassCastException

at oracle.apps.fnd.cp.request.Run.main(Run.java:157)

APP-FND-01388: Cannot read value for profile option CONC_OUTFILE in routine &ROUTINE.

Concurrent request completed

Current system time is 07-MAY-2007 17:00:14

Can anyone let me know why this exception is coming

[3668 byte] By [java_browna] at [2007-11-27 3:37:34]
# 1
EbsEmail ebsMail = new EbsEmail();ebsMail.setOutfile("test1.txt");You set outfile too late. Your constructor is accessing it as though it were already set.
DrLaszloJamfa at 2007-7-12 8:40:50 > top of Java-index,Java Essentials,New To Java...
# 2
How can I set it within my EbsEmail class definition?
java_browna at 2007-7-12 8:40:50 > top of Java-index,Java Essentials,New To Java...
# 3

I would keep the constructor simple. The code you have in the constructor should really be in another method, say "sendMail":

EbsEmail ebsMail = new EbsEmail(); //does very little -- certainly doesn't try to use outfile.

ebsMail.setOutfile("test1.txt");

ebsMail.sendMail(); //uses outfile

DrLaszloJamfa at 2007-7-12 8:40:50 > top of Java-index,Java Essentials,New To Java...
# 4
Ok, I changed it in the constructor like this this.setOutfile("test1.txt");but now I'm getting this error:Exception in thread "main" java.lang.ClassCastExceptionat oracle.apps.fnd.cp.request.Run.main(Run.java:157)Does it make sense?
java_browna at 2007-7-12 8:40:50 > top of Java-index,Java Essentials,New To Java...