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

Andrew is right.
GlassFish is built on an OSGi architecture, try modifying  the file :
Modifying configuration osgi.properties :

There are 2 modifications ( in red color) to do in file :

<GLASSFISH_ROOT>/glassfish/config/osgi.properties

 

# There is no need to use bootdelegation except for the following issues:

# 1. EclipseLink

# 4. NetBeans profiler packages exist in parent class loader (see issue #8612)

# 5. BTrace exists in bootclasspath.

org.osgi.framework.bootdelegation=${eclipselink.bootdelegation}, \

com.sun.btrace, com.sun.btrace.*, \

org.netbeans.lib.profiler, org.netbeans.lib.profiler.*, \

org.aspectj, org.aspectj.*, \

<yourpackageeAspect>, <yourpackageAspect>.*

# The OSGi R4.2 spec says boot delegation uses the boot class loader by default. We need

# to configure it to use the framework class loader because that class loader is

# configured with extra classes like jdk tools.jar, derby jars, etc. that must be

# made available in GlassFish to work.

# framework is the original value.

# org.osgi.framework.bundle.parent=framework

org.osgi.framework.bundle.parent=app

 

 

 

Cordialement / Best regards

 

Jean-Louis Pasturel

De : aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de Andy Clement
Envoyé : mardi 21 janvier 2014 00:35
À : aspectj-users@xxxxxxxxxxx
Objet : Re: [aspectj-users] Use Aspectj during web services invocation

 

-------------------------------------------------------------------------------------------------------------------------------------------------------
------
 
Oups, votre interlocuteur continue de vous ecrire a votre ancienne adresse email : @orange-ftgroup.com. Veuillez lui demander de mettre a jour son
carnet d'adresses. Vous pouvez le faire en utilisant ce modele d'email. Merci
 
 
Oops, your contact is still using your old email address @orange-ftgroup.com. Please could you tell them to update their address book details for you?
You can use this email template  if you like. Thanks
 
-------------------------------------------------------------------------------------------------------------------------------------------------------
------
 

The aspectjrt.jar file needs to be added such that the same classloader that sees your app can see the file. I'm not sure how to do that on a glassfish server. Can you put it alongside the aspects?

 

Andy

 

On 19 January 2014 19:17, Shanmuga Priya R <shanmugapriya1228@xxxxxxxxxxxxxx> wrote:

Hi,

 

     I added aspectjrt.jar to my project through "Add Library". But it throws same error.

 

On Sat, Jan 18, 2014 at 10:25 AM, Shanmuga Priya R <shanmugapriya1228@xxxxxxxxxxxxxx> wrote:

Hi,

 

     I added aspectjrt.jar to my project through "Add Library". But it throws same error.

 

On Sat, Jan 18, 2014 at 10:19 AM, Shanmuga Priya R <shanmugapriya1228@xxxxxxxxxxxxxx> wrote:

Hi,

     I'm not aware about aspectjrt.jar. How can i add this jar file to my project? Is it external jar file?

 

On Sat, Jan 18, 2014 at 3:59 AM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:

Caused by: java.lang.NoClassDefFoundError: org/aspectj/lang/NoAspectBoundException

 

That suggests you did not have the aspectjrt.jar file accessible to the running app code. 

The support classes for AspectJ woven code are in the small aspectjrt.jar file.

 

cheers,

Andy

 

On 17 January 2014 01:44, Shanmuga Priya R <shanmugapriya1228@xxxxxxxxxxxxxx> wrote:

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

 


_______________________________________________
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

 

 

 


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

 

_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.

Back to the top