Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] aspect is not recognized

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




Back to the top