kanishkpanwar
asked on
Add an external folder to CLASSPATH for jsp compilation
I have a web application running in c:\app. This folder has all the jsp pages and the WEB-INF folder (obviosly) and other stuff.
I have some java classes (in different packages) in c:\lib\java\ (class name example:- ExternalClass.java
I refer to these "some" java classes in a class named MyClass.java (saved in \app\WEB-INF\classes\) which is used in a JSP page.
I get a jasper something error saying that it is unable to find the ExternalClass.java
Kindly suggest.
Thanks,
Kanishk.
I have some java classes (in different packages) in c:\lib\java\ (class name example:- ExternalClass.java
I refer to these "some" java classes in a class named MyClass.java (saved in \app\WEB-INF\classes\) which is used in a JSP page.
I get a jasper something error saying that it is unable to find the ExternalClass.java
Kindly suggest.
Thanks,
Kanishk.
ASKER
1) I have the library in classpath.
2) yes, I do use import statement.
2) yes, I do use import statement.
ASKER
I get this
------------------
javax.servlet.ServletExcep tion: net/tinyos/message/Message Listener
org.apache.jasper.runtime. PageContex tImpl.doHa ndlePageEx ception(Pa geContextI mpl.java:8 25)
org.apache.jasper.runtime. PageContex tImpl.hand lePageExce ption(Page ContextImp l.java:758 )
org.apache.jsp.Main_jsp._j spService( Main_jsp.j ava:148)
org.apache.jasper.runtime. HttpJspBas e.service( HttpJspBas e.java:94)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 24)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:292)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:236)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
wsn.Main.doPost(Main.java: 88)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 709)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
root cause
java.lang.NoClassDefFoundE rror: net/tinyos/message/Message Listener
java.lang.ClassLoader.defi neClass0(N ative Method)
java.lang.ClassLoader.defi neClass(Cl assLoader. java:539)
java.security.SecureClassL oader.defi neClass(Se cureClassL oader.java :123)
org.apache.catalina.loader .WebappCla ssLoader.f indClassIn ternal(Web appClassLo ader.java: 1634)
org.apache.catalina.loader .WebappCla ssLoader.f indClass(W ebappClass Loader.jav a:860)
org.apache.catalina.loader .WebappCla ssLoader.l oadClass(W ebappClass Loader.jav a:1307)
org.apache.catalina.loader .WebappCla ssLoader.l oadClass(W ebappClass Loader.jav a:1189)
org.apache.jasper.servlet. JasperLoad er.loadCla ss(JasperL oader.java :148)
org.apache.jasper.servlet. JasperLoad er.loadCla ss(JasperL oader.java :69)
java.lang.ClassLoader.load ClassInter nal(ClassL oader.java :302)
org.apache.jsp.Main_jsp._j spService( Main_jsp.j ava:124)
org.apache.jasper.runtime. HttpJspBas e.service( HttpJspBas e.java:94)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 24)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:292)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:236)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
wsn.Main.doPost(Main.java: 88)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 709)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
------------------
javax.servlet.ServletExcep
org.apache.jasper.runtime.
org.apache.jasper.runtime.
org.apache.jsp.Main_jsp._j
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
wsn.Main.doPost(Main.java:
javax.servlet.http.HttpSer
javax.servlet.http.HttpSer
root cause
java.lang.NoClassDefFoundE
java.lang.ClassLoader.defi
java.lang.ClassLoader.defi
java.security.SecureClassL
org.apache.catalina.loader
org.apache.catalina.loader
org.apache.catalina.loader
org.apache.catalina.loader
org.apache.jasper.servlet.
org.apache.jasper.servlet.
java.lang.ClassLoader.load
org.apache.jsp.Main_jsp._j
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
wsn.Main.doPost(Main.java:
javax.servlet.http.HttpSer
javax.servlet.http.HttpSer
I can't see problem. But someone can help.
>2) yes, I do use import statement.
Show us that line.
>org.apache.jsp.Main_jsp._ jspService (Main_jsp. java:124)
>org.apache.jsp.Main_jsp._ jspService (Main_jsp. java:148
Show us those lines. Look in Tomcat's work folder for Main_jsp.java
>2) yes, I do use import statement.
Show us that line.
>org.apache.jsp.Main_jsp._
>org.apache.jsp.Main_jsp._
Show us those lines. Look in Tomcat's work folder for Main_jsp.java
ASKER
jsp file:
<%@ page language="java" import="java.util.*,wsn.*" pageEncoding="UTF-8"%>
java file:
package wsn;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
import edu.rit.util.Timer;
import edu.rit.util.TimerTask;
import edu.rit.util.TimerThread;
import net.tinyos.message.Message ;
import net.tinyos.message.Message Listener;
import net.tinyos.message.MoteIF;
import net.tinyos.oscope.OscopeMs g;
import net.tinyos.util.PrintStrea mMessenger ;
/**
*
*
* @author Kanishk Panwar
*
*/
public class DataReadingLayer implements MessageListener, Runnable {
private static final int HUMIDITY = 0;
private static final int TEMPERATURE = 1;
private static final int TSR = 2;
private static final int PAR = 3;
private static final int ITEMP = 4;
private static final int IVOLT = 5;
private static final int MOTEID = 6;
private static final int READING = 7;
private static final int LAST_READ = 8;
private static final int[] MONITORED_CHANNELS = { 0, 1, 2, 5 };
private static boolean monitor = true;
private static DataReadingLayer INSTANCE = null;
private HashMap moteList = new HashMap();
/**
*
*
*/
public DataReadingLayer() {
// register message listener - serial forwarder must be running
MoteIF mote = new MoteIF(PrintStreamMessenge r.err, -1);
mote.registerListener(new OscopeMsg(), this);
System.out.println("Starte d...");
startMonitoring();
}
/**
*
*
*/
public void run() {
while (getMonitoringStatus()) {
try {
this.wait();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
*
*/
private synchronized static void createInstance() {
INSTANCE = new DataReadingLayer();
}
/**
*
* @return
*/
public static DataReadingLayer getInstance() {
if (INSTANCE == null)
createInstance();
return INSTANCE;
}
/**
*
*
*/
public synchronized static boolean doesInstanceExist() {
if(INSTANCE==null)
return true;
return false;
}
/**
*
*/
public synchronized static void releaseInstance() {
INSTANCE = null;
}
/**
*
*
* @author Kanishk Panwar
*
*/
public class Motes implements TimerTask {
HashMap channelReadings = new HashMap();
HashMap readingAnomaly = new HashMap();
HashMap readingTiming = new HashMap();
private Timer myTimer = null;
private int id;
/**
*
* @param moteID
*/
public Motes(int moteID) {
id = moteID;
if (myTimer == null)
myTimer = TimerThread.getDefault().c reateTimer (this);
myTimer.start(10000L);
}
/**
*
* @param channel
* @param value
*/
public void updateReading(int channel, double value, Date current,
boolean anomalyStatus) {
if (!myTimer.isTriggered())
myTimer.stop();
if (!channelReadings.contains Key(new Integer(channel)))
channelReadings.put(new Integer(channel), new Vector());
Vector readings = (Vector) channelReadings
.get(new Integer(channel));
if (readings.size() == 20)
readings.remove(0);
readings.add(new Double(value));
channelReadings.put(new Integer(channel), readings);
// update timings
if (!readingTiming.containsKe y(new Integer(channel)))
readingTiming.put(new Integer(channel), new Vector());
Vector timings = (Vector) readingTiming.get(new Integer(channel));
if (timings.size() == 20)
timings.remove(0);
timings.add(WSNUtil.dateTi meFormat.f ormat(curr ent));
readingTiming.put(new Integer(channel), timings);
// update anomaly
if (!readingAnomaly.containsK ey(new Integer(channel)))
readingAnomaly.put(new Integer(channel), new Vector());
Vector anomaly = (Vector) readingAnomaly.get(new Integer(channel));
if (anomaly.size() == 20)
anomaly.remove(0);
anomaly.add(new Boolean(anomalyStatus));
readingAnomaly.put(new Integer(channel), anomaly);
myTimer.start(10000L);
}
/**
*
*/
public void action(Timer theTimer) {
stopMote(theTimer, id);
}
/**
*
* @param channel
* @return
*/
public String[][] getChannelReadings(int channel) {
Vector readings = (Vector) channelReadings
.get(new Integer(channel));
Vector timings = (Vector) readingTiming.get(new Integer(channel));
Vector anomaly = (Vector) readingAnomaly.get(new Integer(channel));
if (readings.size() == 0)
return null;
String[][] current = new String[3][readings.size()] ;
for (int i = 0; i < readings.size(); i++) {
current[0][i] = ((Double) readings.get(i)).toString( );
current[1][i] = (String) timings.get(i);
current[2][i] = ((Boolean) anomaly.get(i)).toString() ;
}
return current;
}
/**
*
* @param channel
* @return
*/
public String[] getOnlyChannelReadings(int channel) {
return getChannelReadings(channel )[0];
}
/**
*
* @return
*/
public int getMoteID() {
return id;
}
/**
*
* @return
*/
public int[] getChannels() {
Set set = channelReadings.keySet();
int[] retVal = new int[set.size()];
int i = 0;
Iterator iter = set.iterator();
while (iter.hasNext()) {
retVal[i] = ((Integer) iter.next()).intValue();
i++;
}
return retVal;
}
public Vector[][] getReadingAndAnomaly() {
Vector[][] v = new Vector[4][2];
v[0][0] = (Vector) channelReadings.get(new Integer(HUMIDITY));
v[0][1] = (Vector) channelReadings.get(new Integer(TEMPERATURE));
v[0][2] = (Vector) channelReadings.get(new Integer(TSR));
v[0][3] = (Vector) channelReadings.get(new Integer(IVOLT));
v[1][0] = (Vector) readingAnomaly.get(new Integer(HUMIDITY));
v[1][1] = (Vector) readingAnomaly.get(new Integer(TEMPERATURE));
v[1][2] = (Vector) readingAnomaly.get(new Integer(TSR));
v[1][3] = (Vector) readingAnomaly.get(new Integer(IVOLT));
return v;
}
} // inner-class
/**
*
*
* @param theTimer
*/
public void stopMote(Timer theTimer, int moteId) {
theTimer.stop();
moteList.put(new Integer(moteId), null);
System.out.println("MOTE IS DEAD !!");
}
/**
*
*/
public synchronized void messageReceived(int to, Message m) {
System.out.println("Icomin g message...");
double rawReading = 0d;
double currentReading = 0d;
Date date = new Date();
boolean isAnomaly = false;
boolean doUpdate = false;
OscopeMsg myMessage = (OscopeMsg) m; // data packet
int channel = myMessage.get_channel(); // type of data for this packet
int numElements = myMessage.numElements_data (); // number of samples
int moteID = myMessage.get_sourceMoteID (); // id# of the sensor this
// data is from
// Object of inner helper class.
Motes myMote = null;
// check if the data reading mote is in the list
if (moteList.containsKey(new Integer(moteID))) {
myMote = (Motes) moteList.get(new Integer(moteID));
} else {
myMote = new Motes(moteID);
}
// mote has been invalidated.
if (myMote == null)
return;
// get the average value of the new sampled data from the packet
for (int i = 0; i < numElements; i++) {
rawReading = rawReading + myMessage.getElement_data( i);
}
rawReading = rawReading / numElements;
switch (channel) {
case HUMIDITY:
currentReading = -4 + (0.0405 * rawReading) + (-0.0000028)
* (rawReading) * (rawReading);
doUpdate = true;
break;
case TEMPERATURE:
/*
* newVal = -39.60 + ( 0.01 * value ); newVal = ((newVal * 9)/5) +
* 32; // convert to Fahrenheit // update previous values Double
* vals[] = (Double[]) prevTemperature.get(new Integer(moteID)); for
* (int i = 9; i > 0; i--) { vals[i] = vals[i-1]; // shift each
* value over 1; drop oldest value } vals[0] = new Double(newVal); //
* most recent value prevTemperature.remove(new Integer(moteID));
* prevTemperature.put(new Integer(moteID), vals);
*
* try { // high temperature warning if (newVal > HIGH_TEMP) {
* String dString = "[" + cal.getTime().toString() + "] " + "***
* HIGH TEMPERATURE WARNING *** \n sensor " + moteID + ":
* temperature = " + Double.toString(newVal).su bstring(0, 5) + " F"; } //
* high temperature warning if (newVal < LOW_TEMP) { String dString =
* "[" + cal.getTime().toString() + "] " + "*** LOW TEMPERATURE
* WARNING *** \n sensor " + moteID + ": temperature = " +
* Double.toString(newVal).su bstring(0, 5) + " F"; } // sudden
* temperature change warning if (vals[DELTA_GAP] != null) { double
* temp = vals[DELTA_GAP].doubleValu e(); if ( (((newVal - temp) /
* newVal) >= DELTA_NORM) || (((temp - newVal) / temp) >=
* DELTA_NORM) ) { String dString = "[" + cal.getTime().toString() + "] " +
* "*** SUDDEN TEMPERATURE CHANGE WARNING *** sensor " + moteID + ":
* temperature = " + Double.toString(newVal).su bstring(0, 5) + " F"; } } }
*
* catch (Exception e) { }
*/
currentReading = -39.60 + (0.01 * rawReading);
currentReading = ((currentReading * 9) / 5) + 32;
doUpdate = true;
break;
case TSR:
currentReading = rawReading;
try {
// load the serialized neural network
// NeuralNetLoader loader = new NeuralNetLoader("light.nn" );
// NeuralNet lightNN = loader.getNeuralNet();
/*
* if (lightNN != null) { // attach DirectSynapse at input Layer
* input = lightNN.getInputLayer(); input.removeAllInputs();
* DirectSynapse memInp = new DirectSynapse();
* input.addInputSynapse(memI np); // attach DirectSynapse at
* output Layer output = lightNN.getOutputLayer();
* output.removeAllOutputs(); DirectSynapse memOut = new
* DirectSynapse(); output.addOutputSynapse(me mOut); // run the
* network lightNN.getMonitor().setLe arning(fal se);
* lightNN.start(); double[] temp = new double[1]; temp[0] =
* newVal; Pattern iPattern = new Pattern(temp); // Interrogate
* the net memInp.fwdPut(iPattern); Pattern pattern =
* memOut.fwdGet(); double output1 = pattern.getArray()[0];
* double output2 = pattern.getArray()[1]; double output3 =
* pattern.getArray()[2];
*
* if (output1 > 0.8) { String dString = "[" +
* cal.getTime().toString() + "] " + "*** LOW LIGHT WARNING***
* \n sensor " + moteID + ": intensity = " +
* Double.toString(newVal); buf = dString.getBytes();
* DatagramPacket packet = new DatagramPacket(buf, buf.length,
* group, 1979); socket.send(packet); } else if (output3 > 0.8) {
* byte[] buf = new byte[256]; InetAddress group =
* InetAddress.getByName("230 .0.0.2"); String dString = "[" +
* cal.getTime().toString() + "] " + "*** HIGH LIGHT WARNING ***
* \n sensor " + moteID + ": intensity = " +
* Double.toString(newVal); buf = dString.getBytes();
* DatagramPacket packet = new DatagramPacket(buf, buf.length,
* group, 1979); socket.send(packet); } Pattern stop = new
* Pattern(new double[1]); stop.setCount(-1);
* memInp.fwdPut(stop); memOut.fwdGet(); }
*/
}
catch (Exception e) {
}
doUpdate = true;
break;
case PAR:
break;
case ITEMP:
break;
case IVOLT:
currentReading = ((rawReading / 4096) * 1.5) * 2;
doUpdate = true;
break;
default:
break;
}
if (doUpdate) {
// update mote data and store it in the hashmap
DecimalFormat df2 = new DecimalFormat("#,###,###,# #0.00");
currentReading = new Double(df2.format(currentR eading))
.doubleValue();
myMote.updateReading(chann el, currentReading, date, isAnomaly);
moteList.put(new Integer(moteID), myMote);
// JDBCLayer.storeReadingInDa tabase(cha nnel, currentReading, date,
// isAnomaly);
if (isAnomaly)
new Thread(new CreatePDF(myMote, WSNUtil.dateTimeFormat.for mat(date)) ).start();
// update database.
new Thread(new DAOConnection(moteID, channel, currentReading, date,
isAnomaly)).start();
}
}
/**
*
*
*/
public void stopMonitoring() {
monitor = false;
}
/**
*
*
*/
public void startMonitoring() {
monitor = true;
}
/**
*
* @return
*/
public boolean getMonitoringStatus() {
return monitor;
}
/**
*
* @return
*/
public int getMoteCount() {
return moteList.size();
}
/**
*
* @param moteID
*/
public synchronized Vector[][] getMoteDetail(int moteID) {
return ((Motes) moteList.get(new Integer(moteID)))
.getReadingAndAnomaly();
}
/**
*
* @return
*/
public Vector[] getSystemDetails() {
Vector[] readings = new Vector[MONITORED_CHANNELS. length];
for (int i = 0; i < MONITORED_CHANNELS.length; i++) {
}
return readings;
}
/**
* for testing only
* @param abc
*/
public static void main (String[] abc) {
new Thread(DataReadingLayer.ge tInstance( )).start() ;
}
}
--------------------
Line 124:
if(DataReadingLayer.doesIn stanceExis t()) {
<%@ page language="java" import="java.util.*,wsn.*"
java file:
package wsn;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
import edu.rit.util.Timer;
import edu.rit.util.TimerTask;
import edu.rit.util.TimerThread;
import net.tinyos.message.Message
import net.tinyos.message.Message
import net.tinyos.message.MoteIF;
import net.tinyos.oscope.OscopeMs
import net.tinyos.util.PrintStrea
/**
*
*
* @author Kanishk Panwar
*
*/
public class DataReadingLayer implements MessageListener, Runnable {
private static final int HUMIDITY = 0;
private static final int TEMPERATURE = 1;
private static final int TSR = 2;
private static final int PAR = 3;
private static final int ITEMP = 4;
private static final int IVOLT = 5;
private static final int MOTEID = 6;
private static final int READING = 7;
private static final int LAST_READ = 8;
private static final int[] MONITORED_CHANNELS = { 0, 1, 2, 5 };
private static boolean monitor = true;
private static DataReadingLayer INSTANCE = null;
private HashMap moteList = new HashMap();
/**
*
*
*/
public DataReadingLayer() {
// register message listener - serial forwarder must be running
MoteIF mote = new MoteIF(PrintStreamMessenge
mote.registerListener(new OscopeMsg(), this);
System.out.println("Starte
startMonitoring();
}
/**
*
*
*/
public void run() {
while (getMonitoringStatus()) {
try {
this.wait();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
*
*/
private synchronized static void createInstance() {
INSTANCE = new DataReadingLayer();
}
/**
*
* @return
*/
public static DataReadingLayer getInstance() {
if (INSTANCE == null)
createInstance();
return INSTANCE;
}
/**
*
*
*/
public synchronized static boolean doesInstanceExist() {
if(INSTANCE==null)
return true;
return false;
}
/**
*
*/
public synchronized static void releaseInstance() {
INSTANCE = null;
}
/**
*
*
* @author Kanishk Panwar
*
*/
public class Motes implements TimerTask {
HashMap channelReadings = new HashMap();
HashMap readingAnomaly = new HashMap();
HashMap readingTiming = new HashMap();
private Timer myTimer = null;
private int id;
/**
*
* @param moteID
*/
public Motes(int moteID) {
id = moteID;
if (myTimer == null)
myTimer = TimerThread.getDefault().c
myTimer.start(10000L);
}
/**
*
* @param channel
* @param value
*/
public void updateReading(int channel, double value, Date current,
boolean anomalyStatus) {
if (!myTimer.isTriggered())
myTimer.stop();
if (!channelReadings.contains
channelReadings.put(new Integer(channel), new Vector());
Vector readings = (Vector) channelReadings
.get(new Integer(channel));
if (readings.size() == 20)
readings.remove(0);
readings.add(new Double(value));
channelReadings.put(new Integer(channel), readings);
// update timings
if (!readingTiming.containsKe
readingTiming.put(new Integer(channel), new Vector());
Vector timings = (Vector) readingTiming.get(new Integer(channel));
if (timings.size() == 20)
timings.remove(0);
timings.add(WSNUtil.dateTi
readingTiming.put(new Integer(channel), timings);
// update anomaly
if (!readingAnomaly.containsK
readingAnomaly.put(new Integer(channel), new Vector());
Vector anomaly = (Vector) readingAnomaly.get(new Integer(channel));
if (anomaly.size() == 20)
anomaly.remove(0);
anomaly.add(new Boolean(anomalyStatus));
readingAnomaly.put(new Integer(channel), anomaly);
myTimer.start(10000L);
}
/**
*
*/
public void action(Timer theTimer) {
stopMote(theTimer, id);
}
/**
*
* @param channel
* @return
*/
public String[][] getChannelReadings(int channel) {
Vector readings = (Vector) channelReadings
.get(new Integer(channel));
Vector timings = (Vector) readingTiming.get(new Integer(channel));
Vector anomaly = (Vector) readingAnomaly.get(new Integer(channel));
if (readings.size() == 0)
return null;
String[][] current = new String[3][readings.size()]
for (int i = 0; i < readings.size(); i++) {
current[0][i] = ((Double) readings.get(i)).toString(
current[1][i] = (String) timings.get(i);
current[2][i] = ((Boolean) anomaly.get(i)).toString()
}
return current;
}
/**
*
* @param channel
* @return
*/
public String[] getOnlyChannelReadings(int
return getChannelReadings(channel
}
/**
*
* @return
*/
public int getMoteID() {
return id;
}
/**
*
* @return
*/
public int[] getChannels() {
Set set = channelReadings.keySet();
int[] retVal = new int[set.size()];
int i = 0;
Iterator iter = set.iterator();
while (iter.hasNext()) {
retVal[i] = ((Integer) iter.next()).intValue();
i++;
}
return retVal;
}
public Vector[][] getReadingAndAnomaly() {
Vector[][] v = new Vector[4][2];
v[0][0] = (Vector) channelReadings.get(new Integer(HUMIDITY));
v[0][1] = (Vector) channelReadings.get(new Integer(TEMPERATURE));
v[0][2] = (Vector) channelReadings.get(new Integer(TSR));
v[0][3] = (Vector) channelReadings.get(new Integer(IVOLT));
v[1][0] = (Vector) readingAnomaly.get(new Integer(HUMIDITY));
v[1][1] = (Vector) readingAnomaly.get(new Integer(TEMPERATURE));
v[1][2] = (Vector) readingAnomaly.get(new Integer(TSR));
v[1][3] = (Vector) readingAnomaly.get(new Integer(IVOLT));
return v;
}
} // inner-class
/**
*
*
* @param theTimer
*/
public void stopMote(Timer theTimer, int moteId) {
theTimer.stop();
moteList.put(new Integer(moteId), null);
System.out.println("MOTE IS DEAD !!");
}
/**
*
*/
public synchronized void messageReceived(int to, Message m) {
System.out.println("Icomin
double rawReading = 0d;
double currentReading = 0d;
Date date = new Date();
boolean isAnomaly = false;
boolean doUpdate = false;
OscopeMsg myMessage = (OscopeMsg) m; // data packet
int channel = myMessage.get_channel(); // type of data for this packet
int numElements = myMessage.numElements_data
int moteID = myMessage.get_sourceMoteID
// data is from
// Object of inner helper class.
Motes myMote = null;
// check if the data reading mote is in the list
if (moteList.containsKey(new Integer(moteID))) {
myMote = (Motes) moteList.get(new Integer(moteID));
} else {
myMote = new Motes(moteID);
}
// mote has been invalidated.
if (myMote == null)
return;
// get the average value of the new sampled data from the packet
for (int i = 0; i < numElements; i++) {
rawReading = rawReading + myMessage.getElement_data(
}
rawReading = rawReading / numElements;
switch (channel) {
case HUMIDITY:
currentReading = -4 + (0.0405 * rawReading) + (-0.0000028)
* (rawReading) * (rawReading);
doUpdate = true;
break;
case TEMPERATURE:
/*
* newVal = -39.60 + ( 0.01 * value ); newVal = ((newVal * 9)/5) +
* 32; // convert to Fahrenheit // update previous values Double
* vals[] = (Double[]) prevTemperature.get(new Integer(moteID)); for
* (int i = 9; i > 0; i--) { vals[i] = vals[i-1]; // shift each
* value over 1; drop oldest value } vals[0] = new Double(newVal); //
* most recent value prevTemperature.remove(new
* prevTemperature.put(new Integer(moteID), vals);
*
* try { // high temperature warning if (newVal > HIGH_TEMP) {
* String dString = "[" + cal.getTime().toString() + "] " + "***
* HIGH TEMPERATURE WARNING *** \n sensor " + moteID + ":
* temperature = " + Double.toString(newVal).su
* high temperature warning if (newVal < LOW_TEMP) { String dString =
* "[" + cal.getTime().toString() + "] " + "*** LOW TEMPERATURE
* WARNING *** \n sensor " + moteID + ": temperature = " +
* Double.toString(newVal).su
* temperature change warning if (vals[DELTA_GAP] != null) { double
* temp = vals[DELTA_GAP].doubleValu
* newVal) >= DELTA_NORM) || (((temp - newVal) / temp) >=
* DELTA_NORM) ) { String dString = "[" + cal.getTime().toString() + "] " +
* "*** SUDDEN TEMPERATURE CHANGE WARNING *** sensor " + moteID + ":
* temperature = " + Double.toString(newVal).su
*
* catch (Exception e) { }
*/
currentReading = -39.60 + (0.01 * rawReading);
currentReading = ((currentReading * 9) / 5) + 32;
doUpdate = true;
break;
case TSR:
currentReading = rawReading;
try {
// load the serialized neural network
// NeuralNetLoader loader = new NeuralNetLoader("light.nn"
// NeuralNet lightNN = loader.getNeuralNet();
/*
* if (lightNN != null) { // attach DirectSynapse at input Layer
* input = lightNN.getInputLayer(); input.removeAllInputs();
* DirectSynapse memInp = new DirectSynapse();
* input.addInputSynapse(memI
* output Layer output = lightNN.getOutputLayer();
* output.removeAllOutputs();
* DirectSynapse(); output.addOutputSynapse(me
* network lightNN.getMonitor().setLe
* lightNN.start(); double[] temp = new double[1]; temp[0] =
* newVal; Pattern iPattern = new Pattern(temp); // Interrogate
* the net memInp.fwdPut(iPattern); Pattern pattern =
* memOut.fwdGet(); double output1 = pattern.getArray()[0];
* double output2 = pattern.getArray()[1]; double output3 =
* pattern.getArray()[2];
*
* if (output1 > 0.8) { String dString = "[" +
* cal.getTime().toString() + "] " + "*** LOW LIGHT WARNING***
* \n sensor " + moteID + ": intensity = " +
* Double.toString(newVal); buf = dString.getBytes();
* DatagramPacket packet = new DatagramPacket(buf, buf.length,
* group, 1979); socket.send(packet); } else if (output3 > 0.8) {
* byte[] buf = new byte[256]; InetAddress group =
* InetAddress.getByName("230
* cal.getTime().toString() + "] " + "*** HIGH LIGHT WARNING ***
* \n sensor " + moteID + ": intensity = " +
* Double.toString(newVal); buf = dString.getBytes();
* DatagramPacket packet = new DatagramPacket(buf, buf.length,
* group, 1979); socket.send(packet); } Pattern stop = new
* Pattern(new double[1]); stop.setCount(-1);
* memInp.fwdPut(stop); memOut.fwdGet(); }
*/
}
catch (Exception e) {
}
doUpdate = true;
break;
case PAR:
break;
case ITEMP:
break;
case IVOLT:
currentReading = ((rawReading / 4096) * 1.5) * 2;
doUpdate = true;
break;
default:
break;
}
if (doUpdate) {
// update mote data and store it in the hashmap
DecimalFormat df2 = new DecimalFormat("#,###,###,#
currentReading = new Double(df2.format(currentR
.doubleValue();
myMote.updateReading(chann
moteList.put(new Integer(moteID), myMote);
// JDBCLayer.storeReadingInDa
// isAnomaly);
if (isAnomaly)
new Thread(new CreatePDF(myMote, WSNUtil.dateTimeFormat.for
// update database.
new Thread(new DAOConnection(moteID, channel, currentReading, date,
isAnomaly)).start();
}
}
/**
*
*
*/
public void stopMonitoring() {
monitor = false;
}
/**
*
*
*/
public void startMonitoring() {
monitor = true;
}
/**
*
* @return
*/
public boolean getMonitoringStatus() {
return monitor;
}
/**
*
* @return
*/
public int getMoteCount() {
return moteList.size();
}
/**
*
* @param moteID
*/
public synchronized Vector[][] getMoteDetail(int moteID) {
return ((Motes) moteList.get(new Integer(moteID)))
.getReadingAndAnomaly();
}
/**
*
* @return
*/
public Vector[] getSystemDetails() {
Vector[] readings = new Vector[MONITORED_CHANNELS.
for (int i = 0; i < MONITORED_CHANNELS.length;
}
return readings;
}
/**
* for testing only
* @param abc
*/
public static void main (String[] abc) {
new Thread(DataReadingLayer.ge
}
}
--------------------
Line 124:
if(DataReadingLayer.doesIn
I still can't find the problem. But maybe someone will be able to help.
>1) I have the library in classpath.
You have the wsn package and the net.tinyos.message package. The wsn package should be in Tomcat's classpath , that is it should in WEB-INF/classes if it not in a jar. If it is in a jar it should be in WEB-INF/lib. The package net.tinyos.message should be in your compiler's classpath. I guess you better show us your classpath. rrz
>1) I have the library in classpath.
You have the wsn package and the net.tinyos.message package. The wsn package should be in Tomcat's classpath , that is it should in WEB-INF/classes if it not in a jar. If it is in a jar it should be in WEB-INF/lib. The package net.tinyos.message should be in your compiler's classpath. I guess you better show us your classpath. rrz
If the above doesn't work, then try moving both packages into Tomcat, just for a test ?
You could try moving your external classes to $JAVA_HOME/jre/lib/ext
Look at
http://tomcat.apache.org/tomcat-5.0-doc/class-loader-howto.html
Look at
http://tomcat.apache.org/tomcat-5.0-doc/class-loader-howto.html
I think the problem is that Tomcat has its own classpath that is separate from the system classpath. So you can put your external classes in $JAVA_HOME/jre/lib/ext or you can try to edit Tomcat's startup scripts(which is probably a bad idea). I am sorry that I didn't say this at first comment. Maybe someone else has a solution.
ASKER
the problem is that I cannot move my code from that location because it is a part of a sensor network OS called "TinyOS". I won't mind changing my startup scripts. I mean there is some configurtion for jasper2 whivh I don't know how to edit.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Why can't you just copy the jar file into the web-inf/lib directory?
Ok, so it will have two copies of it on your system, but its worth a try.
Or have you already done that?
Ok, so it will have two copies of it on your system, but its worth a try.
Or have you already done that?
ASKER
THANK A TON MAN!! It worked. :) *heterosexual hug* :D
If c:\lib\java is not in your classpath , then you should put it there.
>I refer to these "some" java classes in a class named MyClass.java
You should import those "different packages" in MyClass.java. For example
import com.package1.*;
import com.package2.someClass;