I can post the major parts .. 

The Interface:

  | package com.ist.beans.interfaces.local;
  | 
  | import java.io.Serializable;
  | import javax.ejb.Local;
  | 
  | 
  | @Local
  | public interface Notification {
  |  ...
  |     public Object getNotification(String topic, String user, int timeOut);
  |  ...
  | }
  | 

The bean:  

  | package com.ist.beans.session;
  | 
  | import java.io.Serializable;
  | import java.sql.Connection;
  | import java.sql.ResultSet;
  | import java.sql.SQLException;
  | import java.sql.Statement;
  | import java.util.ArrayList;
  | import java.util.List;
  | 
  | import javax.ejb.Local;
  | import javax.ejb.Remote;
  | import javax.ejb.Stateless;
  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | import javax.sql.DataSource;
  | 
  | import org.jboss.annotation.ejb.LocalBinding;
  | import org.jboss.annotation.ejb.RemoteBinding;
  | 
  | @Stateless
  | 
  | @Local ({com.ist.beans.interfaces.local.Notification.class})
  | @LocalBinding (jndiBinding="ejb/local-notification")
  | 
  | @Remote ({com.ist.beans.interfaces.remote.Notification.class})
  | @RemoteBinding (jndiBinding="ejb/notification")
  | public class NotificationBean implements 
com.ist.beans.interfaces.remote.Notification,
  |                                          
com.ist.beans.interfaces.local.Notification { 
  |     private static final String NULL = "NULL";
  |     
  |  ...        
  |     public Object getNotification(String topic, int timeOut) {
  |             return getObjectFromTopic(topic, timeOut);
  |     }
  |  ...        
  |     private Object getObjectFromTopic(String topic, int timeOut) {
  |             Object value = null;
  | 
  |                //*Internal Processing  ... database access ... blah ... blah
  |             
  |             return value;
  |     }
  |     
  | }
  | 

Finally the client ... in this case the client is a web service ... if I use 
the same lookup code snippet in a client on my workstation ... works picture 
perfect ... However as a servlet it never makes it past construction.


  | package com.ist.webservice;
  | 
  | import javax.naming.InitialContext;
  | import com.ist.beans.interfaces.local.Notification;
  | 
  | public class NotificationWebService implements NotificationService {
  |     private Notification notification;
  | 
  |     public NotificationWebService() {
  |             super();
  |             try {
  |                     InitialContext context = new InitialContext();
  |                     
  |                     Object objRef = 
context.lookup("ejb/local-notification");
  |                     
  |                     Class c = objRef.getClass();
  |                     Class[] interfaces = c.getInterfaces();
  |                     for (int i=0; i<interfaces.length; i++) {
  |                             System.out.println(i + " : " + interfaces);
  |                     }
  |                     
  |                     notification = (Notification)objRef;
  |             }
  |             catch (Throwable t) {
  |                     throw new RuntimeException(t);
  |             }
  |     }
  | 
  |  ...
  | }
  | 
  | 

Just incase ... web.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <web-app version="2.5" 
  |     xmlns="http://java.sun.com/xml/ns/javaee"; 
  |     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
  |     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";>
  |     <display-name>Notification Service</display-name>
  |     <description>Notification Web Service Interaface</description>
  |     <servlet>
  |             <servlet-name>NotificationServlet</servlet-name>
  |             
<servlet-class>com.ist.webservice.NotificationWebService</servlet-class>
  |     </servlet>
  |     <servlet-mapping>
  |             <servlet-name>NotificationServiceServlet</servlet-name>
  |             <url-pattern>/NotificationServlet</url-pattern>
  |     </servlet-mapping>
  |     <session-config>
  |             <session-timeout>10</session-timeout>
  |     </session-config>
  | </web-app>
  | 

and the webservices.xml

  | <webservices xmlns="http://java.sun.com/xml/ns/j2ee";
  |      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  |      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd";
  |      version="1.1">
  | 
  |     <webservice-description>
  |         
<webservice-description-name>NotificationWebService</webservice-description-name>
  |         <wsdl-file>WEB-INF/wsdl/Notification.wsdl</wsdl-file>
  |         
<jaxrpc-mapping-file>WEB-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
  |             <port-component>
  |                     
<port-component-name>NotificationServiceComponent</port-component-name>
  |                     <wsdl-port 
xmlns:ns="http://ist.com/services/ws/notification/";>ns:NotificationSOAP</wsdl-port>
  |                     
<service-endpoint-interface>com.ist.NotificationService</service-endpoint-interface>
  |                     <service-impl-bean>
  |                             <servlet-link>NotificationServlet</servlet-link>
  |                     </service-impl-bean>
  |             </port-component>
  |     </webservice-description>
  | </webservices>
  | 

I am puzzled how someting can indicate it implements an interface when querying 
it through reflection, and then throw the ClassCastException when I try to do 
it.

To make some people happy here I have unfortunatly been forced to muck up these 
so pardon my fat-fingeredness if I missed something.

Thanks.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3937797#3937797

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3937797


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to