Hello, everyone:

i am playing with GWT(2.6) with Hibernate recently. the integration works 
well in devmode, i can operate local mysql db correctly. But when i tried 
to deploy the war to my local tomcat server, i got following error:

27-Sep-2015 16:48:45.335 SEVERE [http-apr-8080-exec-9] 
org.apache.catalina.core.ApplicationContext.log Exception while dispatching 
incoming RPC call
 com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public 
abstract com.meta.myapp.shared.ResponseDataBox 
com.meta.myapp.client.rpc.MyappService.remoteCall(com.meta.myapp.shared.RequestDataBox)'
 
threw an unexpected exception: java.lang.NullPointerException
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
at 
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
at 
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:305)
at 
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        ...........
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at 
com.meta.myapp.server.HibernateUtil.getSessionFactory(HibernateUtil.java:55)
at 
com.meta.myapp.server.SchedulerServiceServlet.remoteCall(SchedulerServiceServlet.java:49)
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 com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
... 26 more

Here was how my HibernateUtil implemented, mostly following the guide on 
http://www.gwtproject.org/articles/using_gwt_with_hibernate.html
It looks like the static segment was not invoked at all.
public class HibernateUtil {
        
        private static final SessionFactory sessionFactory;   
        private static Configuration config;
        
        static {
            try {   
                config = new Configuration();
                
                // addMapping(config);
                // Create the SessionFactory from hibernate.cfg.xml   
                sessionFactory = config.configure().buildSessionFactory();  

            } catch (Throwable ex) {   
                System.err.println("Initial SessionFactory creation 
failed.\n" + ex);   
                throw new ExceptionInInitializerError(ex);   
            }   
        }   
      
        public static SessionFactory getSessionFactory() {   
            return sessionFactory;   
        }   
               
}


Here was my server.xml of tomcat 8.0:
      <Host name="localhost"  appBase="c:/yshaoxp/workspace/Myapp"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web 
applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" 
-->
        <Valve className="org.apache.catalina.valves.AccessLogValve" 
directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
<Context path="" reloadable="true" docBase="war" debug="1"/>

      </Host>

and, here is my hibernate.cfg.xml:
<hibernate-configuration>
<session-factory>

<property 
name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

<property 
name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

<property 
name="hibernate.connection.url">jdbc:mysql://localhost:3306/myapp</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>

<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Enable Hibernate's automatic session context management -->
                <property 
name="current_session_context_class">thread</property>

                <!-- Disable the second-level cache -->
                <property 
name="cache.use_second_level_cache">false</property>
        
</session-factory>
</hibernate-configuration>

It works well when i work on devmode with eclipse. Your support is 
appreciated!

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to