Announcement Announcement Module
Collapse
No announcement yet.
Urgent problem QuartzJobBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Urgent problem QuartzJobBean

    Hi everybody, i'm working on an application with spring2 and struts2 and have the next problem:
    When my application starts, a QuartzJobBean is executed.
    In that QuartzJobBean i should be able to get my persistenceService for insert an object into the database.
    That's my code

    applicationContext.xml

    <!-- Quartz Definitions -->

    <bean id="newFileByMailQuartzJob" class="org.springframework.scheduling.quartz.JobDe tailBean"
    lazy-init="false">
    <property name="jobClass" value="it.ingeniumtech.fido.web.daemon.NewFileByMa ilDaemon" />
    <property name="jobDataAsMap">
    <map>
    <entry key="mailService" value-ref="mailService" />
    </map>
    </property>
    </bean>

    <bean class="org.springframework.scheduling.quartz.Sched ulerFactoryBean"
    lazy-init="false">
    <property name="triggers">
    <list>
    <ref bean="newFileByMailTrigger"/>
    </list>
    </property>
    <property name="applicationContextSchedulerContextKey">
    <value>applicationContext</value>
    </property>
    </bean>

    <bean id="newFileByMailTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean"
    lazy-init="false">
    <property name="jobDetail" ref="newFileByMailQuartzJob"/>
    <property name="startDelay" value="1000" />
    <property name="repeatInterval" value="120000" />
    </bean>

    PersistenceService

    @Service("persistenceService")
    @Scope("request")
    public class PersistenceService implements InitializingBean, DisposableBean {

    @Autowired
    private AuthenticationServiceSessionData authenticationServiceSessionData;

    @Autowired
    private PersistenceServiceSingleton persistenceServiceSingleton;

    private SqlMapSession sqlMapSession;

    protected final Log logger = LogFactory.getLog(getClass());

    @Override
    public void afterPropertiesSet() throws Exception {
    this.sqlMapSession = this.persistenceServiceSingleton.getSqlMapClient()
    .openSession();
    }
    ...


    As you can see PersistenceService class has an request scope and when server starts throws me an Exception saying:

    Error creating bean with name 'persistenceService': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton;

    That error it's too clear. In fact i've done that.

    I've created a singleton bean :

    <bean id="infogestService" class="it.ingeniumtech.fido.web.service.mail.impor ter.InfogestImporter"
    lazy-init="false"
    factory-method="getInstance"
    init-method="initMethod">
    <property name="persistenceService" ref="persistenceService"/>
    </bean>

    and the persistenceBean with scoped-proxy

    <bean id="persistenceService" class="it.ingeniumtech.fido.web.service.Persistenc eService"
    lazy-init="false"
    scope="request">
    <aop:scoped-proxy/>
    </bean>

    And cut off all the annotations in the class.

    When i arrived to the breakpoint in singleton class and could see persistenService with CGLIB properties (obviously because this object have been proxied) but the properties of it like authenticationServiceSessionData and persistenceServiceSingleton are null

    I read in some posts that i could get the PersistenceService using applicationContext, but gave me the above same result.

    Does anyone know how could i do to get my PersistenceObject with those properties without null value.
    I 'll apreciate help a lot.
    Thanks

    P.D.: By the way i'm using Spring 2.0.
Working...
X