flex - dpHibernate: serializerFactory not initialized by Spring -> NullPointerException on service access -


i trying dphibernate 2.0 rc6 running on apache tomcat 7.0.12 blazeds 4.0.0.14931, spring 3.0.5 , spring-blazeds-integration 1.5.0.m2

with following configuration server starts fine, want access service or rdsdispatchservlet via flashbuilder4 dcd getting nullpointerexception. seems serializerfactory not correctly injected dphibernate hibernateutil. did miss in configuration in remoting-config.xml?

web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee"            xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"            xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"            xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"            version="2.5">     <display-name>server</display-name>    <description>server side based on blazeds, spring , hibernate</description>    <listener>      <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>    </listener>    <listener>     <listener-class>flex.messaging.httpflexsession</listener-class>    </listener>     <!-- begin spring integration -->    <servlet>      <servlet-name>springmessagebroker</servlet-name>      <servlet-class>        org.springframework.web.servlet.dispatcherservlet      </servlet-class>      <!-- <init-param> -->      <!-- <param-name>contextconfiglocation</param-name> -->      <!-- <param-value></param-value> not use if using contextloaderlistener (would load app context twice -> error) -->      <!-- </init-param> -->      <init-param>         <param-name>services.configuration.file</param-name>         <param-value>/web-inf/flex/services-config.xml</param-value>      </init-param>     <load-on-startup>1</load-on-startup>   </servlet>   <servlet-mapping>     <servlet-name>springmessagebroker</servlet-name>     <url-pattern>/messagebroker/*</url-pattern>   </servlet-mapping>   <!-- end spring integration -->    <!-- begin rds -->   <servlet>     <servlet-name>rdsdispatchservlet</servlet-name>     <servlet-class>flex.rds.server.servlet.frontendservlet</servlet-class>     <init-param>         <param-name>useappserversecurity</param-name>         <param-value>false</param-value>     </init-param>             <init-param>         <param-name>messagebrokerid</param-name>         <param-value>_messagebroker</param-value>     </init-param>             <load-on-startup>10</load-on-startup>   </servlet>   <servlet-mapping>     <servlet-name>rdsdispatchservlet</servlet-name>     <url-pattern>/cfide/main/ide.cfm</url-pattern>   </servlet-mapping>   <!-- end rds -->    <welcome-file-list>     <welcome-file>index.html</welcome-file>     <welcome-file>index.htm</welcome-file>   </welcome-file-list>    <filter>     <filter-name>dphibernatesessionfilter</filter-name>     <filter-class>org.dphibernate.filters.hibernatesessionservletfilter</filter-class>   </filter>   <filter-mapping>     <filter-name>dphibernatesessionfilter</filter-name>     <url-pattern>/*</url-pattern>   </filter-mapping> </web-app> 

applicationcontext.xml (spring servlet default configuration file)

<beans  xmlns="http://www.springframework.org/schema/beans"     xmlns:flex="http://www.springframework.org/schema/flex"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns:tx="http://www.springframework.org/schema/tx"     xmlns:context="http://www.springframework.org/schema/context"     xmlns:jdbc="http://www.springframework.org/schema/jdbc"     xmlns:security="http://www.springframework.org/schema/security"     xsi:schemalocation="         http://www.springframework.org/schema/beans         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd         http://www.springframework.org/schema/flex         http://www.springframework.org/schema/flex/spring-flex-1.0.xsd         http://www.springframework.org/schema/tx         http://www.springframework.org/schema/tx/spring-tx-3.0.xsd         http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context-3.0.xsd">      <import resource="flexcontext.xml" />     <import resource="dataaccesscontext.xml" />     <import resource="dphibernatecontext.xml"/>      <!-- enable spring transaction manager annotations -->     <tx:annotation-driven />      <context:annotation-config />      <bean class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">             <property name="locations" value="/web-inf/server.properties" /></bean>      <context:component-scan base-package="com.mycompany.myproject.*" /> </beans> 

flexcontext.xml (definitions of services available flex)

<beans  xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"      xmlns:flex="http://www.springframework.org/schema/flex"     xsi:schemalocation="         http://www.springframework.org/schema/beans          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd         http://www.springframework.org/schema/flex               http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">       <flex:message-destination id="chat"/>      <flex:message-broker services-config-path="/web-inf/flex/services-config.xml">             <flex:remoting-service default-adapter-id="dphibernateremotingadapter" default-channels="my-amf,my-secure-amf" />             <flex:message-service default-channels="my-streaming-amf,my-polling-amf"/>     </flex:message-broker> </beans> 

fphibernatecontext.xml (configuration of dphibernate)

<beans xmlns="http://www.springframework.org/schema/beans"       xmlns:flex="http://www.springframework.org/schema/flex"         xmlns:security="http://www.springframework.org/schema/security"       xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"        xmlns:aop="http://www.springframework.org/schema/aop"       xmlns:context="http://www.springframework.org/schema/context"        xmlns:tx="http://www.springframework.org/schema/tx"       xmlns:util="http://www.springframework.org/schema/util"       xsi:schemalocation="http://www.springframework.org/schema/aop                           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd                           http://www.springframework.org/schema/beans                           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd                           http://www.springframework.org/schema/context                           http://www.springframework.org/schema/context/spring-context-3.0.xsd                           http://www.springframework.org/schema/flex                            http://www.springframework.org/schema/flex/spring-flex-1.0.xsd                           http://www.springframework.org/schema/security                            http://www.springframework.org/schema/security/spring-security-3.0.xsd                                   http://www.springframework.org/schema/tx                            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd                           http://www.springframework.org/schema/util                            http://www.springframework.org/schema/util/spring-util-3.0.xsd                           ">   <!-- defines remoting adapter, intercepts inbound & outbound messages, , routes them thruogh dphibernate -->   <bean id="dphibernateremotingadapter"     class="org.springframework.flex.core.manageablecomponentfactorybean">     <constructor-arg value="org.dphibernate.adapters.remotingadapter" />     <property name="properties">               <value>       {"dphibernate" :         {           "serializerfactory" : "org.dphibernate.serialization.springcontextserializerfactory"         }       }       </value>     </property>   </bean>   <bean id="dphibernatemessagingadapter"     class="org.springframework.flex.core.manageablecomponentfactorybean">      <constructor-arg value="org.dphibernate.adapters.messagingadapter" />    </bean>     <bean id="dataaccessservice" class="org.dphibernate.services.springlazyloadservice" autowire="constructor">     <flex:remoting-destination />   </bean>    <!-- required -->   <bean id="hibernatesessionfilter" class="org.dphibernate.filters.springhibernatesessionservletfilter" />    <!-- cache used prevent serializing same object many times during serialization.  required -->   <bean id="dphibernatecache"      class="org.dphibernate.serialization.dphibernatecache" scope="prototype" />    <!-- main serializer. converts outbound pojo's asobjects dphibernate proxies lazy loading.  required -->   <bean id="dphibernateserializer"     class="org.dphibernate.serialization.hibernateserializer" scope="prototype">     <property name="pagesize" value="10"/>   </bean>   <bean id="dphibernatedeserializer" class="org.dphibernate.serialization.hibernatedeserializer" scope="prototype" />   <!--  handles entity updates (crud).  required if using entity persistence. -->   <bean id="objectchangeupdater"      class="org.dphibernate.persistence.state.authenticatedobjectchangeupdater"      scope="prototype">     <property name="preprocessors" ref="dphibernatepreprocessors" />     <property name="postprocessors" ref="dphibernatepostprocessors" />   </bean>    </beans> 

remoting-config.xml (imported in services-config.xml)

<service id="remoting-service"           class="flex.messaging.services.remotingservice"          messagetypes="flex.messaging.messages.remotingmessage">    <adapters>     <adapter-definition id="hibernate-object" class="org.dphibernate.adapters.remotingadapter" default="true">       <properties>         <hibernate>           <sessionfactory>             <class>org.dphibernate.utils.hibernateutil</class>             <getcurrentsessionmethod>getcurrentsession</getcurrentsessionmethod>               </sessionfactory>         </hibernate>       </properties>     </adapter-definition>     <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.javaadapter"/>   </adapters>    <default-channels>     <channel ref="my-amf"/>   </default-channels> </service> 

nullpointerexception (on service access or rds access via fb4 dcd)

startinternal info: starting servlet engine: apache tomcat/7.0.12 11.04.2011 18:34:19 org.apache.catalina.core.applicationcontext log info: initializing spring root webapplicationcontext 1027 [thread-2] info org.hibernate.annotations.common.version - hibernate commons annotations 3.2.0.final 1066 [thread-2] info org.hibernate.cfg.environment - hibernate 3.6.2.final 1074 [thread-2] info org.hibernate.cfg.environment - hibernate.properties not found 1085 [thread-2] info org.hibernate.cfg.environment - bytecode provider name : javassist 1116 [thread-2] info org.hibernate.cfg.environment - using jdk 1.4 java.sql.timestamp handling 2146 [thread-2] info org.hibernate.cfg.configuration - hibernate validator not found: ignoring 2182 [thread-2] info org.hibernate.cfg.search.hibernatesearcheventlistenerregister - unable find org.hibernate.search.event.fulltextindexeventlistener on classpath. hibernate search not enabled. 2194 [thread-2] info org.hibernate.connection.connectionproviderfactory - initializing connection provider: org.springframework.orm.hibernate3.localdatasourceconnectionprovider 2658 [thread-2] info org.hibernate.cfg.settingsfactory - database -> name : mysql version : 5.0.51a-24+lenny5-log major : 5 minor : 0 2658 [thread-2] info org.hibernate.cfg.settingsfactory - driver -> name : mysql-ab jdbc driver version : mysql-connector-java-5.1.15 ( revision: ${bzr.revision-id} ) major : 5 minor : 1 2861 [thread-2] info org.hibernate.dialect.dialect - using dialect: org.hibernate.dialect.mysqlinnodbdialect 2981 [thread-2] info org.hibernate.transaction.transactionfactoryfactory - transaction strategy: org.springframework.orm.hibernate3.springtransactionfactory 2991 [thread-2] info org.hibernate.transaction.transactionmanagerlookupfactory - no transactionmanagerlookup configured (in jta environment, use of read-write or transactional second-level cache not recommended) 2991 [thread-2] info org.hibernate.cfg.settingsfactory - automatic flush during beforecompletion(): disabled 2991 [thread-2] info org.hibernate.cfg.settingsfactory - automatic session close @ end of transaction: disabled 2991 [thread-2] info org.hibernate.cfg.settingsfactory - jdbc batch size: 20 2991 [thread-2] info org.hibernate.cfg.settingsfactory - jdbc batch updates versioned data: disabled 2998 [thread-2] info org.hibernate.cfg.settingsfactory - scrollable result sets: enabled 2998 [thread-2] info org.hibernate.cfg.settingsfactory - jdbc3 getgeneratedkeys(): enabled 2998 [thread-2] info org.hibernate.cfg.settingsfactory - connection release mode: auto 3003 [thread-2] info org.hibernate.cfg.settingsfactory - maximum outer join fetch depth: 2 3003 [thread-2] info org.hibernate.cfg.settingsfactory - default batch fetch size: 1 3003 [thread-2] info org.hibernate.cfg.settingsfactory - generate sql comments: disabled 3003 [thread-2] info org.hibernate.cfg.settingsfactory - order sql updates primary key: disabled 3003 [thread-2] info org.hibernate.cfg.settingsfactory - order sql inserts batching: disabled 3003 [thread-2] info org.hibernate.cfg.settingsfactory - query translator: org.hibernate.hql.ast.astquerytranslatorfactory 3023 [thread-2] info org.hibernate.hql.ast.astquerytranslatorfactory - using astquerytranslatorfactory 3023 [thread-2] info org.hibernate.cfg.settingsfactory - query language substitutions: {} 3023 [thread-2] info org.hibernate.cfg.settingsfactory - jpa-ql strict compliance: disabled 3023 [thread-2] info org.hibernate.cfg.settingsfactory - second-level cache: enabled 3023 [thread-2] info org.hibernate.cfg.settingsfactory - query cache: disabled 3029 [thread-2] info org.hibernate.cfg.settingsfactory - cache region factory : org.hibernate.cache.impl.bridge.regionfactorycacheproviderbridge 3074 [thread-2] info org.hibernate.cache.impl.bridge.regionfactorycacheproviderbridge - cache provider: org.hibernate.cache.hashtablecacheprovider 3084 [thread-2] info org.hibernate.cfg.settingsfactory - optimize cache minimal puts: disabled 3084 [thread-2] info org.hibernate.cfg.settingsfactory - structured second-level cache entries: disabled 3131 [thread-2] info org.hibernate.cfg.settingsfactory - echoing sql stdout 3138 [thread-2] info org.hibernate.cfg.settingsfactory - statistics: disabled 3138 [thread-2] info org.hibernate.cfg.settingsfactory - deleted entity synthetic identifier rollback: disabled 3138 [thread-2] info org.hibernate.cfg.settingsfactory - default entity-mode: pojo 3138 [thread-2] info org.hibernate.cfg.settingsfactory - named query checking : enabled 3138 [thread-2] info org.hibernate.cfg.settingsfactory - check nullability in core (should disabled when bean validation on): enabled 3239 [thread-2] info org.hibernate.impl.sessionfactoryimpl - building session factory 3282 [thread-2] info org.hibernate.type.basictyperegistry - type registration [blob] overrides previous : org.hibernate.type.blobtype@17f7be7b 3282 [thread-2] info org.hibernate.type.basictyperegistry - type registration [java.sql.blob] overrides previous : org.hibernate.type.blobtype@17f7be7b 3282 [thread-2] info org.hibernate.type.basictyperegistry - type registration [materialized_clob] overrides previous : org.hibernate.type.materializedclobtype@9fa8988 3282 [thread-2] info org.hibernate.type.basictyperegistry - type registration [wrapper_materialized_blob] overrides previous : org.hibernate.type.wrappedmaterializedblobtype@1f5b44d6 3282 [thread-2] info org.hibernate.type.basictyperegistry - type registration [clob] overrides previous : org.hibernate.type.clobtype@21044daf 3282 [thread-2] info org.hibernate.type.basictyperegistry - type registration [java.sql.clob] overrides previous : org.hibernate.type.clobtype@21044daf 3282 [thread-2] info org.hibernate.type.basictyperegistry - type registration [characters_clob] overrides previous : org.hibernate.type.primitivecharacterarrayclobtype@21882d18 3282 [thread-2] info org.hibernate.type.basictyperegistry - type registration [wrapper_characters_clob] overrides previous : org.hibernate.type.characterarrayclobtype@734893da 3282 [thread-2] info org.hibernate.type.basictyperegistry - type registration [materialized_blob] overrides previous : org.hibernate.type.materializedblobtype@21e30857 3379 [thread-2] info org.hibernate.impl.sessionfactoryobjectfactory - not binding factory jndi, no jndi name configured 11.04.2011 18:34:36 org.apache.catalina.core.applicationcontext log info: initializing spring frameworkservlet 'springmessagebroker' 11.04.2011 18:34:36 org.apache.coyote.abstractprotocolhandler start info: starting protocolhandler ["http-bio-8080"] 11.04.2011 18:34:36 org.apache.coyote.abstractprotocolhandler start info: starting protocolhandler ["ajp-bio-8009"] 11.04.2011 18:34:36 org.apache.catalina.startup.catalina start info: server startup in 21332 ms 11.04.2011 18:49:02 org.apache.catalina.core.standardwrappervalve invoke schwerwiegend: servlet.service() servlet [rdsdispatchservlet] in context path [/myjavaserver] threw exception java.lang.nullpointerexception @ org.dphibernate.utils.hibernateutil.getsessionfactory(unknown source) @ org.dphibernate.filters.hibernatesessionservletfilter.getsessionfactory(unknown source) @ org.dphibernate.filters.abstracthibernatesessionservletfilter.dofilter(unknown source) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:243) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:240) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:164) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:462) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:164) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:100) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:395) @ org.apache.coyote.http11.http11processor.process(http11processor.java:250) @ org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:188) @ org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:166) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:302) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:886) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:908) @ java.lang.thread.run(thread.java:662)

org.dphibernate.utils.hibernateutil (snippet)

private static iserializerfactory serializerfactory; // should injected spring  public static sessionfactory getsessionfactory() throws hibernateexception {     return serializerfactory.getsessionfactory(); // null on call? } 

the remotingconfig.xml isn't needed, , appears what's causing problems.

typically, in spring configuration, hibernateutil class you've shown there isn't used (the springcontextserializerfactory returns sessionfactory ensure you're getting correct 1 spring session)

however, looks remotingconfig.xml file overwriting default settings, forcing use old hibernateutil approach, throwing npe.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -