hi ,

i got  in project i call the ejb this way

  | 
  |                 Properties props  = new Properties();
  |    
props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  |    props.setProperty("java.naming.provider.url", "jnp://192.168.0.10: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);
  | 
  |    TraxManager TraxManager = 
(TraxManager)context.lookup("TraxService/remote");     
  | 

the problem is that i got this line:


  |    TraxManager TraxManager = 
(TraxManager)context.lookup("TraxService/remote");
  | 

instanciated in each of my managed bean .... (i'm using jsf) , it's not optimal 
like solution 

so i have created a generic class :



  | package com.voipover.utils;
  | 
  | import java.util.Properties;
  | 
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | 
  | public class EJBHomeFactory {
  |     
  |     
  |     
  |     public static Object lookup(String jndiName) {
  |                     Context context = null;
  |                     try {
  |                             Properties props  = new Properties();
  |                                
props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  |                                
props.setProperty("java.naming.provider.url", "jnp://192.168.0.10:1099");
  |                                
props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
  |                                props.setProperty("jnp.socket.Factory", 
"org.jnp.interfaces.TimedSocketFactory");
  |                                  context = new InitialContext(props);
  |                         //context = new InitialContext();
  |                         return context.lookup(jndiName);
  |                     } catch (NamingException ex) {
  |                         throw new IllegalStateException("Cannot connect to 
bean: " + jndiName + " Reason: " + ex, ex.getCause());
  |                     } finally {
  |                         try {
  |                             context.close();
  |                         } catch (NamingException ex) {
  |                             throw new IllegalStateException("Cannot close 
InitialContext. Reason: " + ex, ex.getCause());
  |                         }
  |                     }
  |                 }
  | 
  | }
  | 



so now i'm trying to call my service like that :


  |  TraxManager TraxManager = (TraxManager) 
EJBHomeFactory.lookup("TraxService/remote");
  | 

but when i test  receive the following error : 


  | Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad 
version number in .class file
  |     at java.lang.ClassLoader.defineClass1(Native Method)
  |     at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
  |     at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
  |     at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
  |     at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
  |     at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
  |     at java.security.AccessController.doPrivileged(Native Method)
  |     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
  |     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
  |     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
  |     at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
  |     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
  |     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
  |     at java.lang.Class.forName0(Native Method)
  |     at java.lang.Class.forName(Class.java:242)
  |     at 
org.jboss.remoting.loading.RemotingClassLoader.loadClassDelegate(RemotingClassLoader.java:106)
  |     at 
org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:80)
  |     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
  |     at java.lang.Class.forName0(Native Method)
  |     at java.lang.Class.forName(Class.java:242)
  |     at 
org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveProxyClass(ObjectInputStreamWithClassLoader.java:250)
  |     at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1500)
  |     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1463)
  |     at 
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
  |     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
  |     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
  |     at 
org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:119)
  |     at 
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1755)
  |     at 
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1717)
  |     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
  |     at 
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
  |     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
  |     at 
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
  |     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
  |     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
  |     at 
org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:238)
  |     at 
org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:138)
  |     at 
org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:123)
  |     at 
org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedRead(MicroSocketClientInvoker.java:1215)
  |     at 
org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:845)
  |     at 
org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:160)
  |     at org.jboss.remoting.Client.invoke(Client.java:1708)
  |     at org.jboss.remoting.Client.invoke(Client.java:612)
  |     at 
org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)
  |     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  |     at 
org.jboss.ejb3.proxy.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)
  |     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  |     at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
  |     at $Proxy0.createProxyBusiness(Unknown Source)
  |     at 
org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:129)
  |     at 
org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
  |     at 
org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:156)
  |     at 
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
  |     at 
org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1447)
  |     at 
org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1464)
  |     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:818)
  |     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
  |     at javax.naming.InitialContext.lookup(InitialContext.java:351)
  |     at com.voipover.utils.EJBHomeFactory.lookup(EJBHomeFactory.java:23)
  |     at com.voipover.utils.vtraxClientTest.main(vtraxClientTest.java:35)
  | 
  | 
  | 

 any idea? 

and thanks a lot

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

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

Reply via email to