2012-02-01 3 views
1

원격 및 로컬 인터페이스로 EJB를 만들었습니다.원격 EJB에 액세스 할 수 없습니다.

점 대신 몇 가지 방법이 있습니다 (이 경우 중요하지 않음).

그런 다음 glassfish에 배포하십시오. 3.1. 내 클라이언트 웹 응용 프로그램 (동일한 서버에 전쟁으로 배포 됨)에서 액세스 할 수 있으며 정상적으로 작동합니다. 하지만 내 통합 테스트에서 액세스 할 수 없습니다.

나는 내가 글래스 피쉬 server.log에이 빈의 JNDI 이름을보고 받는다는 2로 실행하도록되어 통합 테스트 작성 :

java:global/<my business module name>/VendorBean!<package>.VendorBeanRemote 

및 테스트를 썼다. 그러나 나는 항상 조회에 예외를 얻을 :

javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0] 
    at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:61) 
    at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:501) 
    at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:540) 
    at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:518) 
    at javax.naming.InitialContext.lookup(InitialContext.java:409) 
    at com.widewebtech.mercury.core.test.ejb.VendorBeanIntegrationTest.manageVendor(VendorBeanIntegrationTest.java:126) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:616) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) 
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) 
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236) 
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) 
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) 
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) 
    at org.apache.maven.surefire.Surefire.run(Surefire.java:177) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:616) 
    at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) 
    at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009) 
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0 
    at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72) 
    at org.omg.CosNaming._NamingContextExtStub.resolve(_NamingContextExtStub.java:406) 
    at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:487) 
    ... 33 more 

테스트의 코드 :

Properties p = new Properties(); 
p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); 
p.setProperty("org.omg.CORBA.ORBInitialHost", "localhost"); 
p.setProperty("org.omg.CORBA.ORBInitialPort", "3700"); 
Context context = new InitialContext(p); 

Object o = context.lookup("java:global/<my business module name>/VendorBean!<package>.VendorBeanRemote"); 

내가 혼란 스러워요. 나는 많은 기사를 읽었고, 많은 제안을 시도했지만 아무런 효과가 없었다.

NamingEnumeration<NameClassPair> list = context.list(""); 
while (list.hasMore()) { 
    NameClassPair ncPair = (NameClassPair) list.next(); 
    System.out.print(ncPair.getName() + " (type "); 
    System.out.println(ncPair.getClassName() + ")"); 
} 

결과 :

<package>.VendorBeanRemote__3_x_Internal_RemoteBusinessHome__ (type com.sun.corba.se.impl.corba.CORBAObjectImpl) 
SerialContextProvider (type com.sun.corba.se.impl.corba.CORBAObjectImpl) 
java:global (type com.sun.jndi.cosnaming.CNCtx) 
INITIAL_GIS (type com.sun.corba.se.impl.corba.CORBAObjectImpl) 

그래서, 상황에 맞는 콩과 같은

는 또한 테스트에서 컨텍스트를 나열하는 시도했습니다.

내가 뭘 잘못 했니? 도와주세요!

답변

1

결국이 문제를 해결할 수있었습니다. 따라서 코드는 다음과 같습니다 :

Properties p = new Properties(); 
p.setProperty(Context.PROVIDER_URL, "corbaname:iiop:localhost:3700"); 
context = new InitialContext(p); 

VendorBeanRemote vendorBean = (VendorBeanRemote) context.lookup("java:global/<my business module name>/VendorBean!<package>.VendorBeanRemote"); 

중요 사항 : gf-client.jar은 클래스 경로에 있어야합니다. glassfish lib 디렉토리 에서 가져올 수 있습니다.

+2

어쨌든 기본값으로 언급 했으므로 속성을 제공하지 않고도 작동합니다. –

+1

응용 프로그램 클라이언트 컨테이너 (appclient)를 사용하거나 Java Web Start를 활용하면이 사용 사례에 유용 할 수 있습니다. – vkraemer

0

누군가가 glassfish에서 2 개의 다른 호스트 사이에서 원격 EJB 호출을 사용하여 strugling하는 경우 예외 : orb-listener-1 네트워크 주소를 IP로 설정하십시오. (config의 ORB/IIOP 리스너 섹션)

관련 문제