hi , i have deployed a  jar  a machine aunder jboss 5 , configure it it run 
just fine, now i exported my ejb project as jar to use it in my web project , i 
added a test class in my web project like :



  | package com.vox.utils;
  | 
  | 
  | import java.util.List;
  | import java.util.Properties;
  | 
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | 
  | import com.vox.core.services.VoxManager;
  | import com.vox.core.persistence.model.Cdr;
  | 
  | 
  | public class voxClientTest {        
  |      public static void main(String [] args) {
  |              
  |              try {
  |             
  |          
  |               Properties props  = new Properties();
  |                 
props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  |                 props.setProperty("java.naming.provider.url", 
"jnp://192.168.1.201:1099");
  |                 props.setProperty("java.naming.factory.url.pkgs", 
"org.jboss.naming");
  |                 props.setProperty("jnp.socket.Factory", 
"org.jnp.interfaces.TimedSocketFactory");
  | 
  |                 Context context = new InitialContext(props);
  |                     
  |                 try {
  |                         VoxManager VoxManager = (VoxManager) 
context.lookup("VoxService/remote");
  |     
  |                                List<Cdr>  cdr = (List<Cdr>) 
VoxManager.findAllCdr();
  |                                     for(Cdr  o:cdr)
  |                                     {
  |                                     System.out.println("***"+o.getClid());
  |                                             
  |                                     }
  |                                            
  |                             } catch (NamingException e) {
  |                                     e.printStackTrace();
  |                             }
  |                      
  |                      int e=23;
  |         } catch (Exception ex) {
  |             ex.printStackTrace();
  |         }
  |              
  | }
  |      private static Context getInitialContext() throws NamingException {
  |                    return new InitialContext();
  |         }
  |             
  | }
  | 

in my backend bean who is used to display a datatable in a jsp , backend bean 
code:




  | package com.vox.bean.view;
  | 
  | import java.util.ArrayList;
  | import java.util.List;
  | import java.util.Properties;
  | 
  | import javax.annotation.PostConstruct;
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | 
  | import javax.naming.NamingException;
  | 
  | import com.vox.core.persistence.model.Cdr;
  | import com.vox.core.services.VoxManager;
  | 
  | 
  | 
  | public class ShowCdrsView {
  | 
  |     List cdrs = new ArrayList();
  | 
  |      public ShowCdrsView() {
  | 
  |                       Properties props  = new Properties();
  |                         
props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  |                         props.setProperty("java.naming.provider.url", 
"jnp://192.168.1.201:1099");
  |                         props.setProperty("java.naming.factory.url.pkgs", 
"org.jboss.naming");
  |                         props.setProperty("jnp.socket.Factory", 
"org.jnp.interfaces.TimedSocketFactory");
  | 
  |                             
  |                         try {
  |                             System.out.println("111");
  |                                 Context context = new InitialContext(props);
  |                                 System.out.println("22");
  |                                 VoxManager VoxManager = (VoxManager) 
context.lookup("VoxService/remote");
  |             
  |                                        List<Cdr>  cdr = (List<Cdr>) 
VoxManager.findAllCdr();
  |                                             for(Cdr  o:cdr)
  |                                             {
  |                                             
System.out.println("***"+o.getClid());                                  
  |                                             }
  |                             
  |                                     } catch (NamingException e) {
  |                                             e.printStackTrace();
  |                                     }
  |             
  |      }
  |      
  |     public List getCdrs() {
  |             return cdrs;
  |     }
  | 
  |     public void setCdrs(List cdrs) {
  |             this.cdrs = cdrs;
  |     }       
  |     
  |      private static Context getInitialContext() throws NamingException {
  | 
  |             return new InitialContext();
  |         }
  |      
  |     
  | }
  | 
  | 

but it was giving me the error :


  | 111
  | javax.naming.NoInitialContextException: Cannot instantiate class: 
org.jnp.interfaces.NamingContextFactory [Root exception is 
java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
  |     at 
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
  |     at 
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
  |     at javax.naming.InitialContext.init(InitialContext.java:223)
  |     at javax.naming.InitialContext.<init>(InitialContext.java:197)
  |     at com.vox.bean.view.ShowCdrsView.init(ShowCdrsView.java:38)
  |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |     at java.lang.reflect.Method.invoke(Method.java:597)
  |     at 
org.apache.catalina.util.DefaultAnnotationProcessor.postConstruct(DefaultAnnotationProcessor.java:79)
  |     at 
com.sun.faces.vendor.Tomcat6InjectionProvider.invokePostConstruct(Tomcat6InjectionProvider.java:82)
  |     at 
com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:327)
  |     at 
com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:551)
  |     at 
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
  |     at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
  |     at 
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
  |     at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
  |     at 
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
  |     at 
com.sun.faces.config.ManagedBeanFactoryImpl.evaluateValueExpressionGet(ManagedBeanFactoryImpl.java:1003)
  |     at 
com.sun.faces.config.ManagedBeanFactoryImpl.setPropertiesIntoBean(ManagedBeanFactoryImpl.java:636)
  |     at 
com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:317)
  |     at 
com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:551)
  |     at 
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
  |     at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
  |     at 
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
  |     at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
  |     at org.apache.el.parser.AstValue.getValue(AstValue.java:86)
  |     at 
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
  |     at 
com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
  |     at javax.faces.component.UIData.getValue(UIData.java:582)
  |     at 
org.ajax4jsf.component.UIDataAdaptor.getValue(UIDataAdaptor.java:1640)
  |     at 
org.ajax4jsf.component.SequenceDataAdaptor.getDataModel(SequenceDataAdaptor.java:48)
  |     at 
org.ajax4jsf.component.SequenceDataAdaptor.createDataModel(SequenceDataAdaptor.java:42)
  |     at 
org.richfaces.component.UIDataTable.createDataModel(UIDataTable.java:122)
  |     at 
org.ajax4jsf.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:621)
  |     at 
org.ajax4jsf.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:339)
  |     at 
org.richfaces.renderkit.AbstractTableRenderer.encodeTableStructure(AbstractTableRenderer.java:121)
  |     at 
org.richfaces.renderkit.html.DataTableRenderer.doEncodeBegin(DataTableRenderer.java:206)
  |     at 
org.richfaces.renderkit.html.DataTableRenderer.doEncodeBegin(DataTableRenderer.java:194)
  |     at 
org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:101)
  |     at 
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:785)
  |     at javax.faces.component.UIData.encodeBegin(UIData.java:879)
  |     at 
org.ajax4jsf.component.UIDataAdaptor.encodeBegin(UIDataAdaptor.java:1220)
  |     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
  |     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
  |     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
  |     at 
com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
  |     at 
org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
  |     at 
org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
  |     at 
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
  |     at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
  |     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
  |     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  |     at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
  |     at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
  |     at 
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
  |     at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  |     at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
  |     at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  |     at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
  |     at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
  |     at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  |     at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
  |     at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
  |     at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
  |     at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  |     at java.lang.Thread.run(Thread.java:619)
  | Caused by: java.lang.ClassNotFoundException: 
org.jnp.interfaces.NamingContextFactory
  |     at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
  |     at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
  |     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
  |     at java.lang.Class.forName0(Native Method)
  |     at java.lang.Class.forName(Class.java:247)
  |     at 
com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
  |     at 
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
  |     ... 70 more
  | 

which primarly suggest , that i don;t have  jbossclient.jar !! , but the test 
client class is in the same project and she is working just fine,

after a little googling i add PostContruct to my backing bean:


  | 
  | import java.util.ArrayList;
  | import java.util.List;
  | import java.util.Properties;
  | 
  | import javax.annotation.PostConstruct;
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | 
  | import javax.naming.NamingException;
  | 
  | import com.vox.core.persistence.model.Cdr;
  | import com.vox.core.services.VoxManager;
  | 
  | 
  | 
  | public class ShowCdrsView {
  | 
  |     List cdrs = new ArrayList();
  |     
  |     
  |      @PostConstruct
  |      public void init() {   
  |              
  |                       Properties props  = new Properties();
  |                         
props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  |                         props.setProperty("java.naming.provider.url", 
"jnp://192.168.1.201:1099");
  |                         props.setProperty("java.naming.factory.url.pkgs", 
"org.jboss.naming");
  |                         props.setProperty("jnp.socket.Factory", 
"org.jnp.interfaces.TimedSocketFactory");
  | 
  |                             
  |                         try {
  |                             System.out.println("111");
  |                                 Context context = new InitialContext(props);
  |                                 System.out.println("22");
  |                                 VoxManager VoxManager = (VoxManager) 
context.lookup("VoxService/remote");
  |             
  |                                        List<Cdr>  cdr = (List<Cdr>) 
VoxManager.findAllCdr();
  |                                             for(Cdr  o:cdr)
  |                                             {
  |                                             
System.out.println("***"+o.getClid());
  |                                                     
  |                                             }
  |                                        
  |                                       
  |                                 
  |                                     } catch (NamingException e) {
  |                                             e.printStackTrace();
  |                                     }
  |     }
  | 
  |      public ShowCdrsView() {
  |             
  |      }
  |      
  |     public List getCdrs() {
  |             return cdrs;
  |     }
  | 
  |     public void setCdrs(List cdrs) {
  |             //init();
  |             this.cdrs = cdrs;
  |     }       
  |     
  |      private static Context getInitialContext() throws NamingException {
  | 
  |             return new InitialContext();
  |         }
  |      
  |     
  | }
  | 
  | 

but still same issue .
any idea how to call my ejb remotly  in my backing bean constructor?

and thanks a lot 

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

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241853
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to