Announcement Announcement Module
Collapse
No announcement yet.
Springs and RestEasy synchronization problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Springs and RestEasy synchronization problem

    The project i am working on is a combination of Springs , Hibernate and Resteasy services. In this project i need to get the data from mysql database using hibernate and Springs is used of configuring all the service and Impl classes.
    It has two methods which return database data in xml and json format using reseasy procedures.I have configured every thing correctly and the output is generated correctly but the problem is "The same code is sometimes producing the output and sometimes not"(It is giving a null pointer exception and stack trace is as follows).

    SEVERE: Servlet.service() for servlet [Resteasy] in context with path [/resteasy] threw exception
    org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
    at org.jboss.resteasy.core.SynchronousDispatcher.hand leApplicationException(SynchronousDispatcher.java: 323)
    at org.jboss.resteasy.core.SynchronousDispatcher.hand leException(SynchronousDispatcher.java:199)
    at org.jboss.resteasy.core.SynchronousDispatcher.hand leInvokerException(SynchronousDispatcher.java:175)
    at org.jboss.resteasy.core.SynchronousDispatcher.getR esponse(SynchronousDispatcher.java:529)
    at org.jboss.resteasy.core.SynchronousDispatcher.invo ke(SynchronousDispatcher.java:491)
    at org.jboss.resteasy.core.SynchronousDispatcher.invo ke(SynchronousDispatcher.java:120)
    at org.jboss.resteasy.plugins.server.servlet.ServletC ontainerDispatcher.service(ServletContainerDispatc her.java:200)
    at org.jboss.resteasy.plugins.server.servlet.HttpServ letDispatcher.service(HttpServletDispatcher.java:4 8)
    at org.jboss.resteasy.plugins.server.servlet.HttpServ letDispatcher.service(HttpServletDispatcher.java:4 3)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:405)
    at org.apache.coyote.http11.AbstractHttp11Processor.p rocess(AbstractHttp11Processor.java:964)
    at org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:304)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.NullPointerException
    at com.filter.rest.guiimpl.FilterRestServiceImpl.list NodesXML(FilterRestServiceImpl.java:37)
    at sun.reflect.GeneratedMethodAccessor41.invoke(Unkno wn Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke( MethodInjectorImpl.java:140)
    at org.jboss.resteasy.core.ResourceMethod.invokeOnTar get(ResourceMethod.java:252)
    at org.jboss.resteasy.core.ResourceMethod.invoke(Reso urceMethod.java:217)
    at org.jboss.resteasy.core.ResourceMethod.invoke(Reso urceMethod.java:206)
    at org.jboss.resteasy.core.SynchronousDispatcher.getR esponse(SynchronousDispatcher.java:514)
    ... 22 more


    Spring version is 3.0.4 RELEASE
    Springsecurity version 3.03 RELEASE
    Resteasy version 2.0.1 GA
    JDK 1.7
    Tomcat 7.0.22

    According to my guess the code might be creating a synchronization exception is:

    @Autowired
    FilterService fl;

    public List<Node> listNodesJSON(@Context ServletContext servletContext){

    return fl.listNodesJSON(servletContext);
    }
    public List<Node> listNodesXML(@Context ServletContext servletContext){

    return fl.listNodesJSON(servletContext);
    }

    Here FilterService is an interface which is implemented by my service class.

    The xml configuration(application context.xml) is as follows

    <context:annotation-config />
    <context:component-scan base-package="com.filter" />
    <tx:annotation-driven transaction-manager="transactionManager" />
    <bean class="org.springframework.dao.annotation.Persiste nceExceptionTranslationPostProcessor"/>

    <bean id="masterDAO" class="com.filter.dao.jpa.MasterJpaDao">
    </bean>
    <bean id="filterService" class="com.rest.filter.impl.FilterServiceImpl">
    </bean>

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close" p:driverClass="${jdbc.driverClassName}"
    p:jdbcUrl="${debug.prefix:}${jdbc.url}" p:user="${jdbc.username}"
    password="${jdbc.password}" p:initialPoolSize="10" p:maxPoolSize="30"
    p:acquireRetryAttempts="5" p:acquireRetryDelay="3000"
    p:idleConnectionTestPeriod="300">
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionM anager"
    p:entityManagerFactory-ref="entityManagerFactory" />

    <bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean"
    p:dataSource-ref="dataSource">
    <property name="loadTimeWeaver">
    <bean class="org.springframework.instrument.classloading .InstrumentationLoadTimeWeaver" />
    </property>
    <property name="persistenceUnitName" value="filterservicePU" />

    This bean <bean id="masterDAO" class="com.filter.dao.jpa.MasterJpaDao"> is for implementing the database methods which will
    make a database query to get the data.

    <bean id="filterService" class="com.rest.filter.impl.FilterServiceImpl"> this bean is used for making the view of the fetched data.
    If any details are required i am ready to post them.
    Please help me in solving this issue . Thanks in advance.
    Last edited by [email protected]; May 17th, 2012, 03:13 AM.
Working...
X