This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 305330 - EclipseLink JPA tests failed On JBOSS EAP 5.0.0 GA JNDI lookup failure of EJB Proxy Factory
Summary: EclipseLink JPA tests failed On JBOSS EAP 5.0.0 GA JNDI lookup failure of EJB...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL: http://wiki.eclipse.org/EclipseLink/B...
Whiteboard:
Keywords:
Depends on: 305331
Blocks: 306441 327937
  Show dependency tree
 
Reported: 2010-03-10 09:43 EST by Yiping Zhao CLA
Modified: 2022-06-09 10:26 EDT (History)
2 users (show)

See Also:


Attachments
EAR with container managed PU on @Remote SSB for SE client testing (41.35 KB, application/x-zip-compressed)
2010-03-16 19:03 EDT, Michael OBrien CLA
no flags Details
SE client for testing @Remote stateless session bean injected with JTA TX persistence unit - results are positive with no proxy factory error (11.32 KB, application/x-zip-compressed)
2010-03-16 19:07 EDT, Michael OBrien CLA
no flags Details
this patch is for fix of bug 305330 and 305331 (6.15 KB, patch)
2010-03-19 16:16 EDT, Yiping Zhao CLA
no flags Details | Diff
this patch is for fix of bug 305330 and 305331 (6.16 KB, patch)
2010-03-19 16:17 EDT, Yiping Zhao CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yiping Zhao CLA 2010-03-10 09:43:46 EST
This is the first time we run JPA tests on EAP version of JBOSS, we get following error during run tests:

 <error message="Could not dereference object" type="javax.naming.NamingException">javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: Exception while trying to locate proxy factory in JNDI, at key ProxyFactory/eclipselink-advanced-field-access-model/TestRunner/TestRunner]
	at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1504)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
	at javax.naming.InitialContext.lookup(InitialContext.java:392)
	at org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBareClient(JUnitTestCase.java:480)
	at org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBare(JUnitTestCase.java:455)
Caused by: java.lang.RuntimeException: Exception while trying to locate proxy factory in JNDI, at key ProxyFactory/eclipselink-advanced-field-access-model/TestRunner/TestRunner
	at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getProxyFactoryFromJNDI(ProxyObjectFactory.java:235)
	at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:153)
	at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
	at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1479)
	at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1496)
Caused by: javax.naming.NameNotFoundException: ProxyFactory not bound
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
	at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
	at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
	at org.jnp.server.NamingServer.lookup(NamingServer.java:399)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
	at sun.rmi.transport.Transport$1.run(Transport.java:159)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:619)
	at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
	at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
	at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
	at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
	at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getProxyFactoryFromJNDI(ProxyObjectFactory.java:226)
</error>

Note: after investigation, it looks like that it's related four classes changes in jboss-ejb3-proxy-impl-client.jar located under JBOSS_HOME/client, the tests won't have problem if we replace this jar with that from JBOSS 5.1.0 GA community version, so it seems that it's a issue of JBOSS. The changed classes in jboss-ejb3-proxy-impl-client.jar comparing to community version are:

org.jboss.ejb3.proxy.impl.factory.ProxyFactoryBase
org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandleBase
org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory
org.jboss.ejb3.proxy.impl.remoting.IsLocalProxyFactoryInterceptor
Comment 1 Michael OBrien CLA 2010-03-11 09:31:44 EST
>Installing the EAP server and starting investigation
Comment 2 Michael OBrien CLA 2010-03-12 11:43:48 EST
>Yiping is investigating in parallel with the bug# 305331 options.
Comment 3 Michael OBrien CLA 2010-03-16 19:03:13 EDT
Created attachment 162224 [details]
EAR with container managed PU on @Remote SSB for SE client testing
Comment 4 Michael OBrien CLA 2010-03-16 19:07:03 EDT
Created attachment 162225 [details]
SE client for testing @Remote stateless session bean injected with JTA TX persistence unit - results are positive with no proxy factory error

>Logs on server are from local SE client
2010-03-16 15:27:18,685 INFO  [STDOUT] (WorkerThread#0[127.0.0.1:59179]) [EL Finer]: 2010-03-16 15:27:18.685--UnitOfWork(23465267)--Thread(WorkerThread#0[127.0.0.1:59179])--end unit of work commit


>Remote interface from SE client
public class EJBClient {

    public static final String APPLICATION_SERVICE_JNDI_NAME = "org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR/ApplicationService/remote";
    public ApplicationServiceRemote applicationService;
    public ApplicationServiceRemote getApplicationService(boolean viaJNDILookup) {
        if(null == applicationService && viaJNDILookup) {
            try {
                Hashtable<String, String> env = new Hashtable<String, String>();     
                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");    
                env.put(Context.PROVIDER_URL, "jnp://localhost:1099/");     
                env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );   
                InitialContext anInitialContext = new InitialContext(env);
                System.out.println("FrontController.getApplicationService() JNDI lookup of " + APPLICATION_SERVICE_JNDI_NAME);
                Object aRemoteReference = anInitialContext.lookup(APPLICATION_SERVICE_JNDI_NAME);
                return (ApplicationServiceRemote) PortableRemoteObject.narrow(aRemoteReference, ApplicationServiceRemote.class);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException("JNDI lookup of Stateless Session bean failed", e);
            }
        } else {
            return applicationService;
        }
    }

>Deployment of @Remote and @Local SSB via ejb.jar in EAR on JBoss
2010-03-16 15:15:52,496 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main) installing bean: jboss.j2ee:ear=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear,jar=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar,name=ApplicationService,service=EJB3
2010-03-16 15:15:52,496 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)     jndi:org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR/ApplicationService/local
2010-03-16 15:15:52,496 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)     jndi:org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR/ApplicationService/local-org.eclipse.persistence.example.jpa.server.business.ApplicationServiceLocal
2010-03-16 15:15:52,496 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)     jndi:org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR/ApplicationService/remote-org.eclipse.persistence.example.jpa.server.business.ApplicationServiceRemote
2010-03-16 15:15:52,496 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)     Class:org.eclipse.persistence.example.jpa.server.business.ApplicationServiceLocal
2010-03-16 15:15:52,496 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)     jndi:org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR/ApplicationService/remote
2010-03-16 15:15:52,496 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)     Class:org.eclipse.persistence.example.jpa.server.business.ApplicationServiceRemote
2010-03-16 15:15:52,506 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main) Added bean(jboss.j2ee:ear=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear,jar=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar,name=ApplicationService,service=EJB3) to KernelDeployment of: org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar

>SE client output
FrontController.getApplicationService() JNDI lookup of org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR/ApplicationService/remote
10 Entities in storage: <br/>


>Check difference in ejb name
>me: ear_name/bean_name/remote
>testing: ear_name/remote-bean_name
Comment 5 Michael OBrien CLA 2010-03-18 11:11:50 EDT
>Note 1: Proxy in this bug means the EJB ProxyFactory - as in the factory that returns a proxy to a @Remote session bean like $ProxyNN
>Not the HTTP Proxy configuration

>Note 2: The different JNDI format for the Remote bean is not significant - I pass with either format in Eclipse
>Could not reproduce using a similar EAR/SE remote client config in Eclipse - we pass with the following EJB $Proxy2 to the bean
NamingReference: Proxy to
jboss.j2ee:ear=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear,jar=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar,name=ApplicationService,service=EJB3
implementing [interface
org.eclipse.persistence.example.jpa.server.business.ApplicationServiceRemote]
aRemoteReference    $Proxy2  (id=31)    
    h    SessionRemoteProxyInvocationHandler  (id=36)    
        businessInterfaceType   
"org.eclipse.persistence.example.jpa.server.business.ApplicationServiceRemote"
(id=46)    
        containerGuid   
"jboss.j2ee:ear=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear,jar=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar,name=ApplicationService,service=EJB3,VMID=43ab55e9078af33b:-436adabe:1276d45d840:-7ffd"
(id=50)    
        containerName   
"jboss.j2ee:ear=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR.ear,jar=org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB.jar,name=ApplicationService,service=EJB3"
(id=51)    
        interceptors    Interceptor[4]  (id=52)    
        target    null    
        url    "socket://127.0.0.1:3873/" (id=55)    

@Stateless(name="ApplicationService", mappedName="ApplicationService")
@Remote(ApplicationServiceRemote.class)
ApplicationServiceRemote  {
public class ApplicationService implements ApplicationServiceRemote  {...}
public class EJBClient {
    public ApplicationServiceRemote getApplicationService(boolean
viaJNDILookup) {
                env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");     
                env.put(Context.PROVIDER_URL, "jnp://localhost:1099/");      
                env.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces" );    
                InitialContext anInitialContext = new InitialContext(env);
                System.out.println("NamingReference: " + aRemoteReference);
                ApplicationServiceRemote aService =
(ApplicationServiceRemote)aRemoteReference;
                return (ApplicationServiceRemote)
PortableRemoteObject.narrow(aRemoteReference, ApplicationServiceRemote.class);
}}

>However, I reeproduced the same EJB proxy issue in JBoss testing framework outside eclipse via ant using the instructions at
http://wiki.eclipse.org/EclipseLink/Development/Testing/JPA#Test_Execution

Exception while trying to locate proxy factory in JNDI, at key
ProxyFactory/eclipselink-advanced-field-access-model/TestRunner/TestRunner] at
org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1504)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822) at
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686) at
javax.naming.InitialContext.lookup(InitialContext.java:392) 

>currently narrowing down whether it is a config issue by also testing
1) eclipse deployed EAR with ANT client
2) ant deployed EAR with eclipse client
Comment 6 Michael OBrien CLA 2010-03-18 11:27:26 EDT
>The key name prefixed to the bean is normal for the jndi Reference.toString)() - we can ignore the "ProxyFactory"
- however the 2nd "TestRunner" should be the qualified name of the bean

Exception while trying to locate proxy factory in JNDI, at key ProxyFactory/eclipselink-advanced-field-access-model/TestRunner/TestRunner

>when the test EAR is deployed - the following JNDI name for the remote bean is registered in the format [EAR/short_name/remote-qualified_name]

eclipselink-advanced-field-access-model/TestRunner/remote-org.eclipse.persistence.testing.framework.server.TestRunner - EJB3.x Remote Business Interface

>therefore I would expect the message
Exception while trying to locate proxy factory in JNDI, at key eclipselink-advanced-field-access-model/TestRunner/remote-org.eclipse.persistence.testing.framework.server.TestRunner
Comment 7 Michael OBrien CLA 2010-03-18 11:27:50 EDT
>see also
http://community.jboss.org/message/531496
Comment 8 Michael OBrien CLA 2010-03-18 15:44:06 EDT
>A Remote EJB client lookup and narrow runs fine in the Eclipse 3.5 IDE against the testing EAR (the ant test script must be truncated to not undeploy the test EAR)

  // Lookup TestRunner bean
  Object aRemoteReferenceTestRunner = anInitialContext.lookup("eclipselink-advanced-field-access-model/TestRunner/remote-org.eclipse.persistence.testing.framework.server.TestRunner");
  TestRunner aTestRunner = (TestRunner)PortableRemoteObject.narrow(aRemoteReferenceTestRunner, TestRunner.class);
  System.out.println("NamingReference for TestRunner: " + aRemoteReferenceTestRunner);
  System.out.println("Narrowed TestRunner: " + aTestRunner);

>yields the log
NamingReference for TestRunner: Proxy to jboss.j2ee:ear=eclipselink-advanced-field-access-model.ear,jar=eclipselink-advanced-field-access-model_ejb.jar,name=TestRunner,service=EJB3 implementing [interface org.eclipse.persistence.testing.framework.server.TestRunner]
Narrowed TestRunner: Proxy to jboss.j2ee:ear=eclipselink-advanced-field-access-model.ear,jar=eclipselink-advanced-field-access-model_ejb.jar,name=TestRunner,service=EJB3 implementing [interface org.eclipse.persistence.testing.framework.server.TestRunner]

>and the debug output
"Proxy to jboss.j2ee:ear=eclipselink-advanced-field-access-model.ear,jar=eclipselink-advanced-field-access-model_ejb.jar,name=TestRunner,service=EJB3 implementing [interface org.eclipse.persistence.testing.framework.server.TestRunner]"

aRemoteReferenceTestRunner	$Proxy4  (id=56)	
	h	SessionRemoteProxyInvocationHandler  (id=61)	
		businessInterfaceType	"org.eclipse.persistence.testing.framework.server.TestRunner" (id=63)	
		containerGuid	"jboss.j2ee:ear=eclipselink-advanced-field-access-model.ear,jar=eclipselink-advanced-field-access-model_ejb.jar,name=TestRunner,service=EJB3,VMID=43ab55e9078af33b:1b522b99:12772c8543f:-7ffd" (id=64)	
		containerName	"jboss.j2ee:ear=eclipselink-advanced-field-access-model.ear,jar=eclipselink-advanced-field-access-model_ejb.jar,name=TestRunner,service=EJB3" (id=65)	
		interceptors	Interceptor[4]  (id=66)	
		target	null	
		url	"socket://127.0.0.1:3873/" (id=67)	

>therefore the ejb-jar.xml descriptor is not an issue
Comment 9 Michael OBrien CLA 2010-03-18 16:50:19 EDT
>Solved: the issue is that EAP requires that the EAR (application) name be prepended to the JNDI lookup
in JUnitTestCase.runBareClient() testrunner

>not working with truncated JNDI lookup that is missing the EAR name
        //testrunner = "eclipselink-advanced-field-access-model/TestRunner/remote-org.eclipse.persistence.testing.framework.server.TestRunner";

  [junit] _lookup: TestRunner/remote-org.eclipse.persistence.testing.framework.server.TestRunner

>working with (progresses past lookup and narrow - failing now on java.lang.reflect.UndeclaredThrowableException at $Proxy2.runTest)

testrunner = "eclipselink-advanced-field-access-model/TestRunner/remote-org.eclipse.persistence.testing.framework.server.TestRunner";
    [junit] _lookup: eclipselink-advanced-field-access-model/TestRunner/remote-org.eclipse.persistence.testing.framework.server.TestRunner
    [junit] _reference:Proxy to jboss.j2ee:ear=eclipselink-advanced-field-access-model.ear,jar=eclipselink-advanced-fiel
d-access-model_ejb.jar,name=TestRunner,service=EJB3 implementing [interface org.eclipse.persistence.testing.framework.server.TestRunner]
    [junit] _narrowed:Proxy to jboss.j2ee:ear=eclipselink-advanced-field-access-model.ear,jar=eclipselink-advanced-field
-access-model_ejb.jar,name=TestRunner,service=EJB3 implementing [interface org.eclipse.persistence.testing.framework.server.TestRunner]

>summary: the fix is to follow the more strict format of 
ear_name/ejb_name/remote-qualified_ejb_name
instead of
ejb_name/remote-qualified_ejb_name
Comment 10 Michael OBrien CLA 2010-03-18 17:07:27 EDT
>The server was inadvertently halted by a selection on the cmd window
>we are working now and getting other various errors like
    [junit] Tests run: 215, Failures: 9, Errors: 119, Time elapsed: 81.39 sec

testcase
classname="org.eclipse.persistence.testing.tests.jpa.fieldaccess.advanced.AdvancedJPAJunitTest"
name="testCreateNewEquipment" time="0.05" /> 
  <testcase
classname="org.eclipse.persistence.testing.tests.jpa.fieldaccess.advanced.AdvancedJPAJunitTest"
name="testAddNewEquipmentToDepartment" time="0.05" /> 
  <testcase
classname="org.eclipse.persistence.testing.tests.jpa.fieldaccess.advanced.AdvancedJPAJunitTest"
name="testRemoveDepartmentWithPrivateOwnedEquipment" time="0.08" /> 
- <testcase
classname="org.eclipse.persistence.testing.tests.jpa.fieldaccess.advanced.AdvancedJPAJunitTest"
name="testUpdateReadOnlyEquipmentCode" time="0.03">
  <error message="getSingleResult() did not retrieve any entities."
type="javax.persistence.NoResultException">javax.persistence.NoResultException:
getSingleResult() did not retrieve any entities. at 

- <testcase
classname="org.eclipse.persistence.testing.tests.jpa.fieldaccess.advanced.AdvancedJPAJunitTest"
name="testGiveFredAnObjectTypeConverterChange" time="0.02">
  <error message="Application error: BMT stateless bean TestRunner should
complete transactions before returning (ejb1.1 spec, 11.6.1)"
type="javax.ejb.EJBException">javax.ejb.EJBException: Application error: BMT
stateless bean TestRunner should complete transactions before returning (ejb1.1
spec, 11.6.1) at org.jboss.ejb3.tx.StatelessBMTInterceptor.checkStatelessDone

>TODO:
>The application name needs to be prepended to the JNDI lookup string retrieved from jboss.properties
server.testrunner=TestRunner/remote-org.eclipse.persistence.testing.framework.server.TestRunner

>This bug can then be closed
Comment 11 Yiping Zhao CLA 2010-03-19 16:16:37 EDT
Created attachment 162562 [details]
this patch is for fix of bug 305330 and 305331

fix for main branch
Comment 12 Yiping Zhao CLA 2010-03-19 16:17:38 EDT
Created attachment 162564 [details]
this patch is for fix of bug 305330 and 305331

fix of EclipseLink 2.0
Comment 13 Yiping Zhao CLA 2010-03-19 16:22:58 EDT
The changes are:

1. remove MODEL_NAME from value of "server.url" when running tests on JBOSS
2. copy eclipselink persistence 2.0 jar to JBOSS_HOME/server/default/lib to overwrite jboss's signed ejb3_persistence.jar to resolve the signed issue between signed ejb3_persistence.jar and unsigned eclipselink.jar when running tests on JBOSS EAP 5.0.0

checked in the patches to Main and 2.0 as revisions 6854 and 6856. 

code is reviewed by Michale Obrien.
Comment 14 Eclipse Webmaster CLA 2022-06-09 10:26:31 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink