2015-01-26 2 views
0

제 클라이언트 응용 프로그램을 JBoss 7.1.1에 연결하려고합니다. MHSessionBeanRemote이 제 서버 측 bean 클래스입니다. 내 수업의java.lang.ClassNotFoundException : org.jboss.naming.remote.client.InitialContextFactory 오류

코드

import java.util.Properties; 
import javax.naming.Context; 
import javax.naming.InitialContext; 
import javax.naming.NamingException; 
public class MHSessionBeanClient { 
    public static void main(String[] args) throws NamingException { 
     Context context = MHSessionBeanClient.getInitialContext(); 
     MHSessionBeanRemote mhSessionBean = (MHSessionBeanRemote)context.lookup("MHSessionBean/remote"); 
     mhSessionBean.mhSessionBeanMethod(); 
    } 
    public static Context getInitialContext() throws NamingException { 
     Properties properties = new Properties(); 
     properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); 
     properties.put(Context.PROVIDER_URL,"remote://127.0.0.1:4447"); 
     properties.put(Context.SECURITY_PRINCIPAL, "user"); 
     properties.put(Context.SECURITY_CREDENTIALS, "password"); 
     properties.put("jboss.naming.client.ejb.context", true); 
     return new InitialContext(properties); 
    } 
} 

및 오류 : 내가 잘못

Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jboss.naming.remote.client.InitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory] 
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) 
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) 
at javax.naming.InitialContext.init(Unknown Source) 
at javax.naming.InitialContext.<init>(Unknown Source) 
at MHSessionBeanClient.getInitialContext(MHSessionBeanClient.java:25) 
at MHSessionBeanClient.main(MHSessionBeanClient.java:12) 
Caused by: java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory 
at java.net.URLClassLoader$1.run(Unknown Source) 
at java.net.URLClassLoader$1.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.net.URLClassLoader.findClass(Unknown Source) 
at java.lang.ClassLoader.loadClass(Unknown Source) 
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) 
at java.lang.ClassLoader.loadClass(Unknown Source) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Unknown Source) 
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source) 
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source) 
... 6 more 

을 뭐하는 거지?

+1

확인 http://stackoverflow.com/questions/21213693/jndi-cannot-instantiate-class-org- jboss-naming-remote-client-initialcontextfac – Rao

+0

@Rao 감사합니다. 그것은 그 문제를 해결했습니다. –

답변

0

참고로, 경우에 당신은 제이보스JMS 추가, 사용 제이보스 - JMS 클라이언트-BOM 당신의 치어에;

당신이 게시물에 따라 클래스 패스에 JBoss에 client.jar가 추가 한 경우
<dependency> 
     <groupId>org.wildfly</groupId> 
     <artifactId>wildfly-jms-client-bom</artifactId> 
     <version>10.0.0.Final</version> 
     <type>pom</type> 
    </dependency> 
관련 문제