I have a interface:
public interface SealQueryService {

        public boolean isSealExist(String domainName) throws Exception;
                
}

and implemented as follow:

public class SealQueryServiceImpl extends HibernateGenericDao implements
SealQueryService {

        public boolean isSealExist(String domainName) throws Exception {
                String sealByDomainHQL = "from Seal seal where 
seal.domainName1=? or
seal.domainName2 = ?";
                List sealByDomainList = this.find(sealByDomainHQL, domainName, 
domainName);
                return sealByDomainList != null && sealByDomainList.size() > 0;
        }
        }

seal-servlet.xml configuration:

         <bean id="sealQuery"
                class="cn.cnnic.seal.service.SealQueryServiceImpl" />
         <bean name="/seal.service"
                
class="org.springframework.remoting.caucho.HessianServiceExporter">
                <property name="service">
                        <ref bean="sealQuery" />
                </property>
                <property name="serviceInterface">
                        <value>cn.cnnic.seal.service.SealQueryService</value>
                </property>
        </bean>

web.xml configuration:

        <servlet>
                <servlet-name>seal</servlet-name>
                
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

                <load-on-startup>1</load-on-startup>
        </servlet>
        
        <servlet-mapping>
                <servlet-name>seal</servlet-name>
                <url-pattern>/seal.service</url-pattern>
        </servlet-mapping>

when I test from the following code:

public class SealQueryTest {

        public static void main(String[] args) throws Exception

        {
                String url = "http://218.241.108.134:8088/seal/seal.service";;
                HessianProxyFactory factory = new HessianProxyFactory();
                factory.setDebug(true);
                SealQueryService s = (SealQueryService) factory.create(
                                SealQueryService.class, url);
                System.out.println("call Hessian service: " +
s.isSealExist("www.sina.com.cn"));
        }
}

I get error:

Exception in thread "main" com.caucho.hessian.client.HessianRuntimeException:
com.caucho.hessian.io.HessianProtocolException: 500: java.io.IOException: Server
returned HTTP response code: 500 for URL: 
http://218.241.108.134:8088/seal/seal.service
        at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java)
        at $Proxy0.isSealExist(Unknown Source)
        at cn.cnnic.seal.test.service.SealQueryTest.main(SealQueryTest.java:37)
Caused by: com.caucho.hessian.io.HessianProtocolException: 500:
java.io.IOException: Server returned HTTP response code: 500 for URL: 
http://218.241.108.134:8088/seal/seal.service
        ... 3 more
Caused by: java.io.IOException: Server returned HTTP response code: 500 for 
URL: http://218.241.108.134:8088/seal/seal.service
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImp
l.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAcc
essorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at
sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1202)
        at java.security.AccessController.doPrivileged(Native Method)
        at
sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.
java:1196)
        at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:
885)
        ... 3 more
Caused by: java.io.IOException: Server returned HTTP response code: 500 for 
URL: http://218.241.108.134:8088/seal/seal.service
        at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:
1149)
        at 
java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:367)
        ... 3 more

and server side report error:

2007-11-08 12:59:27,479 DEBUG 
[org.springframework.web.servlet.DispatcherServlet]
- <Could not complete request>
org.springframework.web.util.NestedServletException: Hessian skeleton invocation
failed; nested exception is java.lang.NoSuchMethodError: setSerializerFactory
Caused by:
java.lang.NoSuchMethodError: setSerializerFactory
        at
org.springframework.remoting.caucho.Hessian2SkeletonInvoker.invoke(Hessian2Skeleto
nInvoker.java:64)
        at
org.springframework.remoting.caucho.HessianServiceExporter.handleRequest(HessianSe
rviceExporter.java:147)
        at
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHa
ndlerAdapter.java:49)
        at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.jav
a:839)
        at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java
:774)
        at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.j
ava:460)
        at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:425)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
        at
com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
        at com.caucho.server.http.Invocation.service(Invocation.java:315)
        at
com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
        at 
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:253)
        at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:170)
        at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
        at java.lang.Thread.run(Thread.java:595)


I cannot figure out what's wrong. I write another service implementation with 
pure
jdbc as follows:

public class SealQueryServiceJdbcImpl implements SealQueryService {

        private static final Logger log =
Logger.getLogger(SealQueryServiceJdbcImpl.class);
        
        public boolean isSealExist(String domainName) throws Exception {
                InputStream in =
this.getClass().getResourceAsStream("/jdbc/jdbc-sl-registry.properties");
                Properties prop = new Properties();
                Connection conn = null;
                PreparedStatement cstmt = null;
                ResultSet rs = null;
                try {
                        prop.load(in);
                        
Class.forName(prop.getProperty("jdbc.sl.driverClassName"));
                        conn = 
DriverManager.getConnection(prop.getProperty("jdbc.sl.url"),
prop.getProperty("jdbc.sl.username"), prop.getProperty("jdbc.sl.password"));
                        String sql = "select * from sl_reg_seal s where 
s.domainName1=? or
s.domainName2 = ?";
                        cstmt = conn.prepareStatement(sql);
                        cstmt.setString(1, domainName);
                        cstmt.setString(2, domainName);
                        rs = cstmt.executeQuery();
                        if(rs.next()) return true;
                } catch (IOException e) {
                        log.error("load jdbc properties error!", e);
                } catch (ClassNotFoundException e) {
                        log.error("load jdbc driver error!", e);
                } catch (SQLException e) {
                        log.error("exec procedure error",e);
                } finally {
                        try {
                        if(cstmt != null) {
                                cstmt.close();
                        }
                        if(conn != null) {
                                conn.close();
                        }
                        }catch(SQLException e) {
                                log.error("sql error",e);
                        }
                }
                return false;
        }
}

then the test code works. So I guess hessian cannot work well with hibernate.
Any help is appreciated:)






_______________________________________________
hessian-interest mailing list
[email protected]
http://maillist.caucho.com/mailman/listinfo/hessian-interest

Reply via email to