aspect is not recognized

View: New views
4 Messages — Rating Filter:   Alert me  

aspect is not recognized

by Leyzerzon, Simeon -2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm trying to put an aspect into otherwise regular Java projects and are facing issues with MyEclipse.  Here's my setup:

There are 2 projects - TestBusiness & TestLib, and the first one depends on the second:

TestBusiness --> TestLib.

TestBusiness has a JUnit test:

=======================================================================================
package com.test.gdos.iris.gma.dao;

import static org.junit.Assert.*;

import javax.annotation.Resource;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:cachingContext-gma.xml","classpath:dataAccessContext-gma-jta.xml"})
public class FooGmaDaoTest {



        @Resource(name="fooGma")
        private IExecutiveSummaryGmaDao fooGmaDao;


        @Test
        public void testGetExecutiveSummaryDatagridsDaoBuffer() {

                assertNotNull(fooGmaDao.getExecutiveSummaryDatagridsDaoBuffer("EXEC_SMRY", "PROD", "ALL", "ALL", "Jul", "2009","",""));
                assertNotNull(fooGmaDao.getExecutiveSummaryDatagridsDaoBuffer("EXEC_SMRY", "PROD", "ALL", "ALL", "Jul", "2009","",""));
        }

}
========================================================================================================

with the following configurations:

=====cachingContext-gma.xml=============================================================================

<?xml version="1.0" encoding="UTF-8"?>
<!--
        GMA cache-related configurations.
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
                xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
                xmlns:aop="http://www.springframework.org/schema/aop"
                xmlns:ehcache="http://www.springmodules.org/schema/ehcache"
                xsi:schemaLocation="
                        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
                        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
                        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                        http://www.springmodules.org/schema/ehcache http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd
                        ">
<!--
<context:component-scan base-package="com.citi.gdos.iris.gma.dao" />
 -->


<aop:config>
 <aop:pointcut id="getAllDaoExPointcut"
        expression="execution(* *..FooGmaDao.getExecutiveSummaryDatagridsDaoBuffer(..))" />
 <aop:advisor id="methodTimingAdvisor"
  advice-ref="methodTimingAdvice" pointcut-ref="getAllDaoExPointcut" />
</aop:config>

<bean id="methodTimingAdvice" class="com.test.gdos.smart.applib.service.logging.MethodTimingInterceptor" />

<bean id="gmaCacheKeyGenerator" class="com.test.gdos.smart.applib.service.cache.IrisCacheKeyGenerator" />

 <ehcache:config configLocation="classpath:ehcache-gma.xml"/>
 <ehcache:annotations>
        <ehcache:cacheKeyGenerator refId="gmaCacheKeyGenerator"/>
        <ehcache:caching cacheName="fooCache" id="fooModel"/>
 </ehcache:annotations>


</beans>


============================================================


======== dataAccessContext-gma-jta.xml ==================================

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
                xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
                xmlns:aop="http://www.springframework.org/schema/aop"

                xsi:schemaLocation="
                        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
                        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
                        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                        ">


     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
                <property name="driverClass" value="oracle.jdbc.OracleDriver"/>
        <property name="jdbcUrl" value="jdbc:oracle:thin:@tordev44.citi.ca.citicorp.com:1722:MDWD"/>
        <property name="user" value="gma"/>
        <property name="password" value="citibank1"/>
    </bean>


        <context:component-scan base-package="com.citi.gdos.iris.gma.dao" />

 <!--
        <jee:jndi-lookup id="dataSource" jndi-name="IRIS_MAP_DataSource"/>
 -->

        <!-- Template of DataSource -->
        <bean id="jdbcTemplate"
                class="org.springframework.jdbc.core.JdbcTemplate"
                 p:dataSource-ref="dataSource" >
        </bean>


        <!-- Gma Base DAO -->

        <bean id="gmaDaoBaseDaoImpl"  class="com.test.gdos.iris.gma.dao.GmaBaseDao">
                <property name="jdbcTemplate">
                        <ref bean="jdbcTemplate" />
                </property>
        </bean>

            <bean id="fooGma" parent="gmaDaoBaseDaoImpl"
        class="com.test.gdos.iris.gma.dao.FooGmaDao">

        <property name="sql">
            <value>P_ENTL_HC_ANLS_GET_SMRY_VW</value>
        </property>
    </bean>

</beans>
=========================================================================


Also, ehcache-gma.xml is as follows in TestBusiness:

==========================================
<ehcache>

        <diskStore path="java.io.tmpdir" />

        <defaultCache maxElementsInMemory="500"
                eternal="true"
                overflowToDisk="false"
                memoryStoreEvictionPolicy="LFU" />

        <cache name="fooCache"
                maxElementsInMemory="500"
                eternal="false"
                overflowToDisk="false"
                memoryStoreEvictionPolicy="LFU" />


</ehcache>

===========================================


Everything is fine until I make TestLib project an AspectJ-aware one and add an aspect to it with the following contents:


CachingIntroduction.aj
import org.springmodules.cache.annotations.Cacheable;

public aspect CachingIntroduction {

        declare @method :
                public * *DAO.*(..) :
                        @Cacheable(modelId="fooModel");

}

At this point, MyEclipse starts complaining with multiple messages:

Syntax error on token "@", aspect header expected
Syntax error on token "declare", delete this token
Syntax error, insert "body" to complete ClassBodyDeclarations

Looks like the aspect is not being recognized by MyEclipse as an aspect.  I tried to add the same aspect with .java extension and using @Aspect inside it with the same results.  Not sure what I'm missing.

I can see MyEclipse added AspectJ runtime library to the project which resolves to C:\Genuitec\Common\plugins\org.aspectj.runtime_1.6.6.20090723171200\aspectjrt.jar for me.

I could appload a zip file with this setup, but not sure if it's possible through this userlist.

Could someone please help?


TIA.
Simeon


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

Re: aspect is not recognized

by Andrew Eisenberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It sounds like your project is not using the ajbuilder and is using
the javabuilder instead.

Your .project file should look something like this:

<projectDescription>
        <name>myproject</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
                <buildCommand>
                        <name>org.eclipse.ajdt.core.ajbuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>
        <natures>
                <nature>org.eclipse.ajdt.ui.ajnature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
</projectDescription>

Notice that the ajbuilder is being used and the ajnature is above the
javanature.

If your .project file looks different, try right clicking on the
project Configure -> Add AspectJ Support

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

RE: aspect is not recognized

by Leyzerzon, Simeon -2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just checked, my .project file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
        <name>TestLib</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
                <buildCommand>
                        <name>org.eclipse.ajdt.core.ajbuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>
        <natures>
                <nature>org.eclipse.ajdt.ui.ajnature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
</projectDescription>


Thank you,
Simeon

-----Original Message-----
From: aspectj-users-bounces@... [mailto:aspectj-users-bounces@...] On Behalf Of Andrew Eisenberg
Sent: Friday, September 18, 2009 5:42 PM
To: aspectj-users@...
Subject: Re: [aspectj-users] aspect is not recognized

It sounds like your project is not using the ajbuilder and is using the javabuilder instead.

Your .project file should look something like this:

<projectDescription>
        <name>myproject</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
                <buildCommand>
                        <name>org.eclipse.ajdt.core.ajbuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>
        <natures>
                <nature>org.eclipse.ajdt.ui.ajnature</nature>
                <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
</projectDescription>

Notice that the ajbuilder is being used and the ajnature is above the javanature.

If your .project file looks different, try right clicking on the project Configure -> Add AspectJ Support

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

Re: aspect is not recognized

by Andrew Eisenberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, that looks fine to me.  There are other possibilities.

1. Are you opening this file in a Java editor instead of an AJ editor?
2. Are you seeing editor problems instead of compiler problems (ie- do
these problems only appear in the editor and not in the problems
view)?
3. Are there any exceptions in the error log?

On Mon, Sep 21, 2009 at 7:00 AM, Leyzerzon, Simeon
<simeon.leyzerzon@...> wrote:

> Just checked, my .project file is as follows:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <projectDescription>
>        <name>TestLib</name>
>        <comment></comment>
>        <projects>
>        </projects>
>        <buildSpec>
>                <buildCommand>
>                        <name>org.eclipse.ajdt.core.ajbuilder</name>
>                        <arguments>
>                        </arguments>
>                </buildCommand>
>        </buildSpec>
>        <natures>
>                <nature>org.eclipse.ajdt.ui.ajnature</nature>
>                <nature>org.eclipse.jdt.core.javanature</nature>
>        </natures>
> </projectDescription>
>
>
> Thank you,
> Simeon
_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users