0

When I get my services using application context to get bean with name, all services in other package runs fine, but services in century package throws exceptions as title.

<bean id="txManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="contextHolder" class="com.globalsion.util.spring.ApplicationContextFactory" />

<bean id="hibInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    <property name="sessionFactory">
        <ref local="sessionFactory" />
    </property>
</bean>

<aop:config>
    <aop:pointcut id="allServiceMethods"
        expression="execution(* 
    com.**.service.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethods" />
</aop:config>
<aop:config>
    <aop:pointcut id="baseServiceMethods"
        expression="execution(* 
    com.**.service.**.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="baseServiceMethods" />
</aop:config>
<aop:config>
    <aop:pointcut id="allDaoMethods" expression="execution(* 
    com.**.dao.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="allDaoMethods" />
</aop:config>
<aop:config>
    <aop:pointcut id="baseDaoMethods"
        expression="execution(* 
    com.**.dao.**.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="baseDaoMethods" />
</aop:config>
<aop:config>
    <aop:pointcut id="allBeanMethods"
        expression="execution(* 
    com.**.jsf.bean.**.**.**(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="allBeanMethods" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
        <tx:method name="*" propagation="REQUIRED" />
        <tx:method name="*newTrans" propagation="REQUIRES_NEW" />
        <tx:method name="get*" propagation="NOT_SUPPORTED"
            read-only="true" />
        <tx:method name="find*" propagation="NOT_SUPPORTED"
            read-only="true" />
    </tx:attributes>
</tx:advice>

My supplier service interface.

package com.century.service;

import com.century.data.Supplier;
import com.globalsion.service.base.Service;

public interface SupplierService extends Service<Supplier> {

}

My supplier service implementation.

package com.century.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.primefaces.model.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.century.dao.SupplierDAO;
import com.century.data.Supplier;

@Service("com.century.service.SupplierService")
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    private SupplierDAO classDAO;

    public SupplierDAO getClassDAO() {
        return classDAO;
    }

    public void setClassDAO(SupplierDAO classDAO) {
        this.classDAO = classDAO;
    }

    // My other irrelevant methods
}

My barcode service in com inventory service package which is working fine.

package com.inventory.service;

import com.inventory.data.Barcode;
import com.globalsion.service.base.Service;

public interface BarcodeService extends Service<Barcode>{

}

My barcode service impl.

package com.inventory.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.primefaces.model.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.globalsion.dao.AutoNumberDAO;
import com.inventory.dao.BarcodeDAO;
import com.inventory.data.Barcode;

@Service("com.inventory.service.BarcodeService")
public class BarcodeServiceImpl implements BarcodeService {
    @Autowired
    private BarcodeDAO classDAO;
    @Autowired
    private AutoNumberDAO autoNumberDAO;

    public BarcodeDAO getClassDAO() {
        return classDAO;
    }

    public void setClassDAO(BarcodeDAO classDAO) {
        this.classDAO = classDAO;
    }

    public AutoNumberDAO getAutoNumberDAO() {
        return autoNumberDAO;
    }

    public void setAutoNumberDAO(AutoNumberDAO autoNumberDAO) {
        this.autoNumberDAO = autoNumberDAO;
    }

    // My other irrelevant methods
}

Anybody has any idea what is wrong with my codes? Thanks.

Lance
  • 31
  • 5
  • you have to define your `SupplierService` bean as well in application context like your are defining other bean ` ` – Amit Jun 22 '17 at 04:16
  • @AmitK Thanks for replying, I think that if I have `aop:pointcut id="allServiceMethods"`, the `Supplier Service` which falls under the package pattern should be registered as well, is that not the case? – Lance Jun 22 '17 at 05:25
  • `` in the upper part of my spring context which I omitted in the question, seems like I forgot to add in the `com.century`, thanks for all the help. – Lance Jun 22 '17 at 05:40
  • yeah its required if you are using annotation scan based DI. – Amit Jun 22 '17 at 05:42

0 Answers0