Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Use Aspectj during web services invocation

Hi,
    I change my aspect based on your information.  Aspect weaved to the web services properly. But during execution time it throws exeception on Glassfish server.

Web services code:

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;

public class SimpleInterestMidleware
{
    public void invokeService() throws AxisFault
    {
       ServiceClient client = new ServiceClient();
       Options opts = new Options();
       opts.setTo(new EndpointReference("http://localhost:8088/axis2/services/SimpleIntJava"));
       opts.setAction("urn:findInterest");
       client.setOptions(opts);
       System.out.println("Function calling sendReceive");
       OMElement res = client.sendReceive(createPayLoad());
       System.out.println(res);
    }
   private static OMElement createPayLoad()
   {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = fac.createOMNamespace("http://simpleintjava", "ns");
        OMElement method = fac.createOMElement("findInterest", omNs);
        OMElement value = fac.createOMElement("p", omNs);
        value.setText("1000");
        method.addChild(value);
        return method;
    }
}

AspectJ code:
public aspect SimpleInterestAspect
{
pointcut beforeaspect():call(* sendReceive(..));
    before():beforeaspect()
    {
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println("====Before aspect=====");
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
    }
}


Error:(During execution it throws following exception)

Function calling sendReceive

[ERROR] org/aspectj/lang/NoAspectBoundException
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
        at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
        at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
        at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
        at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/NoAspectBoundException


How can i solve this problem?

Thanks,



On Fri, Jan 10, 2014 at 1:46 AM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
For the constructor joinpoint you want this signature:

execution(EndpointReference.new(..))

For the sendReceive you have the signature right but that will only apply if you weave *into* the jar containing the implementation of sendReceive.  If you are weaving into the caller of sendReceive you need:

call(* sendReceive(..))
(And if using call() there, maybe you also want call(EndpointReference.new(..)) for the constructor)

cheers,
Andy








On 9 January 2014 02:03, Shanmuga Priya R <shanmugapriya1228@xxxxxxxxxxxxxx> wrote:
Hi,

     I wanted to use aspectj during invocation of web service from other service. For that i wanted to know how to specify the jointpoint.

Web services code:

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;

public class MiddleSimpleInterest
{
    public static void main(String[] args) throws AxisFault
    {
       ServiceClient client = new ServiceClient();
       Options opts = new Options();
       opts.setTo(new EndpointReference("http://localhost:8088/axis2/services/SimpleIntJava"));
       opts.setAction("urn:findInterest");
       client.setOptions(opts);
       OMElement res = client.sendReceive(createPayLoad());
       System.out.println(res);
    }
   private static OMElement createPayLoad()
   {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = fac.createOMNamespace("http://simpleintjava", "ns");
        OMElement method = fac.createOMElement("findInterest", omNs);
        OMElement value = fac.createOMElement("p", omNs);
        value.setText("1000");
        method.addChild(value);
        return method;
    }
}

Corresponding Aspectj code:
public aspect MiddlewareAspect
{
pointcut beforeaspect():execution(* *.sendReceive(..));
 
        pointcut beforeexeaspect():execution(* EndpointReference(..));
        before():beforeaspect()
        {
                System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
                System.out.println("====Before sendReceive=====");
                System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
         }
         before():beforeexeaspect()
         {
               System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
               System.out.println("====Before EndpointReference=====");
               System.out.println("~~~~~~~~~~~~~~~~~~~~~~");
         }
}

Error:

      For the above aspectj code i got the exception "Advice didn't match".


 How can i specify those 2 join points? Is it possible in aspectj?

Thanks,

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top