Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6609733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:45:09+00:00 2026-05-25T19:45:09+00:00

My problem is simple, when i run methods from my EventService from standalone app

  • 0

My problem is simple, when i run methods from my EventService from standalone app (by using ClassPathXmlApplicationContext in main() ) everything works fine.

@Service
@Transactional(readOnly = true)
public class EventService {
    Logger log = Logger.getLogger(EventService.class);
    @Autowired private EventDao eventDao;

    public List<Event> getAll() {
        return eventDao.getAll();
    }

    public List<Event> getAllContainsResource(int resourceId) {
        return eventDao.getAllWithResource(resourceId);
    }

    public String getName() {
        return "simpleName";
    }
}

When i run on tomcat (built-in server on STS), container starts correctly but when i send request (Flex app thru AMF) to getAll() method or getAllContainsResource(int) *NullPointerException* comes up. It shows that eventDao is null. I don’t know what can be the reason so please help. Here is my applicationContext :

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

    <!-- database connection -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/rapla" />
        <property name="username" value="root" />
        <property name="password" value="admin" />
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
                hibernate.c3p0.min_size=5
                hibernate.c3p0.max_size=20
                hibernate.c3p0.timeout=1800
                hibernate.c3p0.max_statements=50
                hibernate.show_sql=true
                hibernate.format_sql=true
                hibernate.use_sql_comments=true
        </value>
        </property>
        <property name="configLocation">
            <value>classpath:hibernate.cfg.xml</value>
        </property>
        <property name="configurationClass">
            <value>org.hibernate.cfg.AnnotationConfiguration</value>
        </property>
    </bean>


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

    <tx:annotation-driven transaction-manager="txManager" />

    <context:annotation-config />
    <context:component-scan base-package="org.pwsz.dao.hibernate" />
    <context:component-scan base-package="org.pwsz.services" />

    <flex:message-broker />

</beans>

XML for standalone application is same, ofcourse without

<flex:message-broker />

EventDaoImpl :

@Repository
public class EventDaoImpl implements EventDao {

    Logger log = Logger.getLogger(EventDaoImpl.class);
    @Autowired private SessionFactory sessionFactory;

    public Event getById(int id) {
        return (Event) sessionFactory.getCurrentSession().get(Event.class, id);
    }

    public List<Event> getAll() {
        return sessionFactory.getCurrentSession().createCriteria(Event.class).list();
    }

    public List<Event> getAllWithResource(Integer id) {
        List<Event> resulu = sessionFactory.getCurrentSession()
            .createCriteria(Event.class)
            .createCriteria("appointments.teachers")
            .add(Restrictions.eq("resourceId", id))
            .list();

        return resulu;
    }
}

Spring-flex connection works fine, i can request getName using Flex Remote Object but sending request for the other two generates null exception.

Regards


I checked problem in WebApp (using spring mvc) and everything works fine. I found that problem generates Hibernate which return null sessionFactory for DAOs (they are @autowired) when request comes from Flex (using AMF protocol).

flex.messaging.MessageException: java.lang.NullPointerException : null
    at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:444)
    at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
    at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1400)
    at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:1005)
    at flex.messaging.endpoints.AbstractEndpoint$$FastClassByCGLIB$$1a3ef066.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
    at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.flex.core.MessageInterceptionAdvice.invoke(MessageInterceptionAdvice.java:66)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:124)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.Cglib2AopProxy$FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:572)
    at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$247a330d.serviceMessage(<generated>)
    at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:103)
    at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
    at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
    at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
    at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:166)
    at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291)
    at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$247a330d.service(<generated>)
    at org.springframework.flex.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:109)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.traceNextValve(HttpRequestOperationCollectionValve.java:92)
    at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
    at org.pwsz.services.EventService.getAll(EventService.java:19)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:418)
    ... 47 more

So problem is still not solved, can anybody help ? thanks in advance


Finnaly i solved the problem i replaced blazeds services-config.xml :

<services-config>
    <services>
        <service id="remoting-service" class="flex.messaging.services.RemotingService">
            <default-channels>
                <channel ref="my-amf" />
            </default-channels>

            <adapters>
                <adapter-definition id="java-object"
                    class="flex.messaging.services.remoting.adapters.JavaAdapter"
                    default="true" />
            </adapters>

            <destination id="myService" channels="my-amf">
                <properties>
                    <source>org.abc.services.EventService</source>
                </properties>
            </destination>
        </service>
    </services>

    <channels>
        <channel-definition id="my-amf"
            class="mx.messaging.channels.AMFChannel">
            <endpoint
                url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
                class="flex.messaging.endpoints.AMFEndpoint" />
        </channel-definition>
    </channels>

</services-config>

by annotation in org.abc.services.EventService

@RemotingDestination(value="myService",channels={"my-amf"})

i tried also definition in appContext.xml and it works too :

<flex:remoting-destination destination-id="myService"  ref="eventService"/>

but i still don’t get why configuration in services-config didn’t work, the main problem was that for every AMF request Spring was generating new eventService object (without autowiring dao), notice that functions that don’t needed Dao worked fine.


my web.xml

<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>classpath:log4j.properties</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>rws</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>rws</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>
        index.jsp
    </welcome-file>
</welcome-file-list>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:45:10+00:00Added an answer on May 25, 2026 at 7:45 pm

    If you do not use the annotation @RemotingDestination or if you don’t declare the component in appContext.xml (or another xml used by Spring) the Spring framework will not be able to manage your bean (aka inhect properties etc), that’s why the DAO object is null. That’s true for all the components declared in the “classic” BlazeDS config files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found an odd problem when I run a simple csh script on Solaris.
I have a little problem with a simple vbScript. The script has to run
The problem is simple: Using bash, I want to add a directory to my
Logic error problem with the Gaussian Elimination code...This code was from my Numerical Methods
I've been using Apache CXF wsdl2java generated code to call methods from a webservice
I have just run into quite surprising problem. The case is simple: return all
I've run into a bit of a problem, which I simply cannot find a
Really simple problem: I want to split a connection string into its keyword /
Simple problem that I can't figure out... How can I print a '%' character
Simple problem (I think): I want to be able to invoke a click method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.