Harshi Gunarathna

Greenhorn
+ Follow
since Oct 26, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Harshi Gunarathna

Dear Xiao Wu,

I tried to use Cewolf with Struts. But i do not understand to use it properly.
Please be kind enough to give a sample code for me to try out.

Thanks in advance,
Harshi
thanks Christophe
I tried it, but still i get some new Exceptions.Can you please describe the way to apply EJBInvokerJob class with EJB or else provide me a resource to understand it properly. Because i am new to EJB as well as Quartz.

Thanks in advance,
Harshi
hi,
I am trying to use Quartz job scheduler with EJB3 stateless session beans. I created one bean by implementing the org.quartz.job and the other with the trigger which provides the schedule for the job.My requirement is to invoke a method per minute.Inside the execute method i am calling a method of another stateless session bean (which implements its' remote interface).Once the program run it throws "NullPointerException".I tried to fix it but i couldn't fix it.


@Stateless
public class CronScheduleBean implements CronScheduleRemote {

public CronScheduleBean() {}

public String autoSchedule(String a)throws Exception {
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
JobDetail jd = new JobDetail("job1", "group1", CronJobBean.class);
CronTrigger ct = new CronTrigger("cronTrigger", "group2", "0 0/1 * * * ?");

sched.scheduleJob(jd, ct);
sched.start();
return a;
}
--------------------------------------------------------------------
@Stateless
public class CronJobBean implements CronJobRemote,Job {

@EJB
private ReportGenerationLocal reportGenerationBean;

public void execute(JobExecutionContext arg0) throws JobExecutionException {
System.out.println("ReportGenerationBean :" + new Date());

reportGenerationBean.generateEODReport("2008-10-26");

}
--------------------------------------------------------------------

Output

Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
ReportGenerationBean :Tue Nov 25 08:54:00 IST 2008
Job group1.job1 threw an unhandled Exception:
java.lang.NullPointerException
at com.mjoy.cp.reporting.CronJobBean.execute(CronJobBean.java:33)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Job (group1.job1 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: java.lang.NullPointerException



Can anyone please help me to fix this issue.
Thanks in advance,
Harshi.
Hi..
I am new to XML and DOM.I'm trying to output an XML document.I am using LinkedHashMap as the input to provide elements and subelements. The code is:

LinkedHashMap one = new LinkedHashMap();
LinkedHashMap two = new LinkedHashMap();
LinkedHashMap three = new LinkedHashMap();
LinkedHashMap four = new LinkedHashMap();
LinkedHashMap five = new LinkedHashMap();
one.put("No_Of_Tickets", two);
two.put("Time", three);
three.put("Adult", four);
four.put("Balcony", 5);
four.put("ODC", 10);
three.put("Children", five);
five.put("Balcony", 15);
five.put("ODC", 10);

Then i am using the below code to print the xml document.

public class Test {

//No generics
private LinkedHashMap table;
private Document dom;
Element rootEle;
Element one;

public Test(LinkedHashMap table) {
//create a list to hold the data
this.table = table;
//Get a DOM object
createDocument();
createDOMTree();
printToFile();
}

private void createDOMTree() {

//create the root element <Reports>
rootEle = dom.createElement("Report");

dom.appendChild(rootEle);

x((LinkedHashMap) table);


}

private void x(LinkedHashMap t) {
Iterator it = t.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
Object key = pairs.getKey();
Object value = pairs.getValue();
one = createElement(key, value);
rootEle.appendChild(one);
}
}

private Element createElement(Object key, Object value) {
Element next = dom.createElement(key.toString());

if (value instanceof LinkedHashMap) {

x((LinkedHashMap) value);
} else {
Text oneText = dom.createTextNode(value.toString());
next.appendChild(oneText);
}
return next;
}


public void printToFile() {


try {

//print
OutputFormat format = new OutputFormat(dom);
format.setIndenting(true);
//to generate a file output use fileoutputstream instead of system.out
XMLSerializer serializer = new XMLSerializer(new FileOutputStream(new File("C:/java/JavaApplication6/a.xml")), format);

serializer.serialize(dom);

} catch (IOException ie) {
ie.printStackTrace();
}
}

private void createDocument() {

//get an instance of factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
//get an instance of builder
DocumentBuilder db = dbf.newDocumentBuilder();

//create an instance of DOM
dom = db.newDocument();

} catch (ParserConfigurationException pce) {
//dump it
System.out.println("Error " + pce);
System.exit(1);
}

}
}

But as the output i get the below XML document.

<?xml version="1.0" encoding="UTF-8"?>
<Report>
<Balcony>5</Balcony>
<ODC>10</ODC>
<Adult/>
<Balcony>15</Balcony>
<ODC>10</ODC>
<Children/>
<Time/>
<No_Of_Tickets/>
</Report>

Here the correct output should be:

<?xml version="1.0" encoding="UTF-8"?>
<Report>
<No_Of_Tickets>
<Time>
<Adult>
<Balcony>5</Balcony>
<ODC>10</ODC>
<Adult/>
<Children>
<Balcony>15</Balcony>
<ODC>10</ODC>
<Children/>
<Time/>
<No_Of_Tickets/>
</Report>

Can somebody help me to find the issue with the code.Thanks in advance.

Regards,
Harshi
hi..I am also having the same kind of a problem. I have added the EJB3 module to a web project and trying to call methods in a stateless session bean through remote interface.

Here is the error:
Deploying application in domain failed; Error loading deployment descriptors for module [Merchants] -- Cannot resolve reference Unresolved Ejb-Ref com.mjoy.cp.interfaces.ReservationCPInterfaceBean/ticketReservationBean@jndi: @null@com.mjoy.cp.reservation.TicketReservationLocal@Session@null
Deployment error:
The module has not been deployed.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:166)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: The module has not been deployed.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:160)
... 16 more
BUILD FAILED





If somebody know the answer pleas help.

Thank you.
Thanks for the reply. But actually the folder is inside C:\java\ folder.
I did the tutorial http://www.netbeans.org/kb/61/javaee/entappclient.html
but once i run the app i get following warnings..
run-display-browser:
run-ac:

27-Oct-2008 07:30:12 com.sun.enterprise.appclient.MainWithModuleSupport <init>
WARNING: ACC003: Application threw an exception.
java.io.FileNotFoundException: C:\DOCUME~1\IBM\LOCALS~1\Temp\acc-xClient.jar1909\x-app-client_jar\Main.class (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at com.sun.enterprise.deployment.util.AnnotationDetector.containsAnnotation(AnnotationDetector.java:169)
at com.sun.enterprise.appclient.AppClientInfo.classContainsAnnotation(AppClientInfo.java:641)
at com.sun.enterprise.appclient.AppClientInfo.mainClassContainsPURefcAnnotations(AppClientInfo.java:413)
at com.sun.enterprise.appclient.AppClientInfo.appClientDependsOnPersistenceUnit(AppClientInfo.java:382)
at com.sun.enterprise.appclient.AppClientInfo.completeInit(AppClientInfo.java:175)
at com.sun.enterprise.appclient.AppClientInfoFactory.buildAppClientInfo(AppClientInfoFactory.java:149)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:366)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
at com.sun.enterprise.appclient.Main.main(Main.java:200)
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: C:\DOCUME~1\IBM\LOCALS~1\Temp\acc-xClient.jar1909\x-app-client_jar\Main.class (The system cannot find the file specified)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:487)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
at com.sun.enterprise.appclient.Main.main(Main.java:200)
Caused by: java.io.FileNotFoundException: C:\DOCUME~1\IBM\LOCALS~1\Temp\acc-xClient.jar1909\x-app-client_jar\Main.class (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at com.sun.enterprise.deployment.util.AnnotationDetector.containsAnnotation(AnnotationDetector.java:169)
at com.sun.enterprise.appclient.AppClientInfo.classContainsAnnotation(AppClientInfo.java:641)
at com.sun.enterprise.appclient.AppClientInfo.mainClassContainsPURefcAnnotations(AppClientInfo.java:413)
at com.sun.enterprise.appclient.AppClientInfo.appClientDependsOnPersistenceUnit(AppClientInfo.java:382)
at com.sun.enterprise.appclient.AppClientInfo.completeInit(AppClientInfo.java:175)
at com.sun.enterprise.appclient.AppClientInfoFactory.buildAppClientInfo(AppClientInfoFactory.java:149)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:366)
... 2 more
Java Result: 1

run-x-app-client:
run:
BUILD SUCCESSFUL (total time: 10 seconds)

I coudn't find it.can somebody help me to find the issue please??


Edited by Jaikiran: Fixed the URL
[ October 27, 2008: Message edited by: Jaikiran Pai ]