[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-dev] NoAspectBoundException while initilizing...
|
The exception is due to the aspect doing this:
> String no_person=null;
>
> Float persons=Float.parseFloat(no_person);
parseFloat is throwing the null pointer exception which prevents
aspect instantiation.
Andy
On 15 February 2011 03:45, shantha <mail2shantha@xxxxxxxxx> wrote:
>
> hi,
> i am using eclipse 3.5 and AJDT...
> i am trying to execute my classechange_aspect class..the aspect method is
> nothing calling...
> and its giving an exception
>
> org.aspectj.lang.NoAspectBoundException: Exception while initializing
> classexchange_aspect: java.lang.NullPointerException
>
>
>
> and my aspect code is:
> import TGS.ClassExchange;
> public aspect classexchange_aspect {
> double discount=0.5;
> String no_person=null;
>
> Float persons=Float.parseFloat(no_person);
> public pointcut compute():call (ClassExchange.new(float));
> ClassExchange around():compute()
>
> {
> return getObject(proceed());
> }
> ClassExchange getObject(ClassExchange c)
> {
> if(c.check()==0)
> return c;
> else
> {
>
> System.out.println("parameter 1 ="+persons + "\nparameter 2
> ="+discount);
> return new ClassExchange(persons,(float) discount);}
> }
> }
>
>
>
> my java code is...
>
>
> package TGS;
>
> import java.io.IOException;
> import java.io.PrintWriter;
> import java.text.DateFormat;
> import java.text.SimpleDateFormat;
> import java.util.Calendar;
> import java.util.Date;
>
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import javax.servlet.http.HttpSession;
>
>
> public class ClassExchange extends HttpServlet {
> private static final long serialVersionUID = 1L;
>
>
> public float x,y,z,n;
> public int ch,ad,tot_per;
> double cost=5000.00;
> public int flag=0;
> public ClassExchange() {
> super();
>
> }
>
>
>
> public ClassExchange(float a) {
>
> x=a;
> y=1;
>
> }
>
> public ClassExchange(Float a, float b) {
>
>
> x=a;
> y=b;
>
> }
>
>
> public float discount() {
>
> return (float)5000.00*x*y;
> }
>
>
> /**
> * @see HttpServlet#doGet(HttpServletRequest request,
> HttpServletResponse response)
> */
> public int check() {
> // TODO Auto-generated method stub
>
> try
> {
> DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
> //get current date time with Date()
> Date date = new Date();
>
>
> System.out.println(dateFormat.format(date));
> Calendar cal = Calendar.getInstance();
> System.out.println(dateFormat.format(cal.getTime()));
> SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
> Date date1 = sdf.parse("31/01/2011");
> Date datecompare=sdf.parse(dateFormat.format(cal.getTime()));
> Date date2 = sdf.parse("15/02/2011");
>
> System.out.println(sdf.format(date1));
> System.out.println(sdf.format(date2));
> System.out.println(sdf.format(datecompare));
>
>
> if((datecompare.compareTo(date1)>0)&&(datecompare.compareTo(date2)<0))
> {
> flag=1;
> }}
> catch (Exception ex)
> {
> System.out.println(ex);
> }
> System.out.println(flag);
> return flag;
> }
>
>
> protected void doPost(HttpServletRequest request,
> HttpServletResponse response) {
> // TODO Auto-generated method stub
> HttpSession sess=request.getSession(true);
>
> try{
> PrintWriter out = response.getWriter();
> out.println("<html>");
> out.println("<head>");
> out.println("<title>Servlet flights</title>");
> out.println("</head>");
> out.println("<body>");
> double result;
> new ClassExchange().check();
>
>
> String per=(String)
> sess.getAttribute("per");
>
>
> Float persons=Float.parseFloat(per);
>
> System.out.println(persons);
>
> System.out.println("Cukoos_Class_Exchange_Pattern");
> result = new
> ClassExchange(persons).discount();//aspect is called here
> System.out.println("result = " +result);
>
> out.println("<form method=post
> action=Display_Details>");
> out.println("</body>");
> out.println("</html>");
> out.println("<input name=flight_submit value=BOOK NOW
> type=submit>");
>
> out.println("</form>");
> }
> catch(Exception ex)
> {
> System.out.println(ex);
> }
> }
>
>
> /**
> * @see HttpServlet#doPost(HttpServletRequest request,
> HttpServletResponse response)
> */
> protected void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
> // TODO Auto-generated method stub
>
> }
>
> }
>
>
>
>
> pls help me... i dont know what to do....when i tried without using
> servlet...i got perfect answer pls......
> thanks in advance.....
>
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/NoAspectBoundException-while-initilizing-tp3306627p3306627.html
> Sent from the AspectJ - dev mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>