Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JndiRmiServiceExporter fails to export service on IBM j9 JDK [SPR-16670] #21211

Closed
spring-projects-issues opened this issue Mar 29, 2018 · 4 comments
Assignees
Labels
in: web type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 29, 2018

John Zimmermann opened SPR-16670 and commented

I have a service which I am attempting to export via the JndiRmiServiceExporter.

<bean id="clientAdminServiceTargetSource" class="com.mypackages.ClientAdminServiceTargetSourceImpl">
<constructor-arg ref="defaultClientAdminService" />
</bean>
<bean id="clientAdminService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces" value="com.mypackages.ClientAdminService" />
<property name="targetSource" ref="clientAdminServiceTargetSource" />
</bean>
<bean class="org.springframework.remoting.rmi.JndiRmiServiceExporter">
<property name="jndiTemplate" value="jndiTemplate" />
<property name="jndiName" value="ClientAdminService" />
<property name="service" ref="clientAdminService" />
<property name="serviceInterface" value="com.mypackages.ClientAdminService" />
</bean>

Since upgrading to Spring 5.x I've encountered the following error with the IBM j9 deployed on WebSphere 9.x. The same code is also deployed on Oracle Weblogic 12.2.1.3 with the Sun/Oracle JDK and works perfectly fine. Has anyone reported a similar issue or are there any suggestions how to go about handling this?

I have temporarily resolved this by using a customized version of Spring's JndiRmiServiceExporter to behave like the 4.x version did .. with the only notable difference is the absence of :

PortableRemoteObject.exportObject(this.exportedObject);
PortableRemoteObject.unexportObject(this.exportedObject);

With these re-added, everything behaves correctly. It seems based on github commits these lines were removed in association with JDK9 compatibility.

[3/4/18 19:26:50:041 EST] 00000065 webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.remoting.rmi.JndiRmiServiceExporter#0' defined in class path resource [com/mypackages/clientContext.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: ClientAdminService [Root exception is java.rmi.NoSuchObjectException: object not exported]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$24.0000000017529EF0.getObject(Unknown Source)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:109)
at com.mypackages.ApplicationContextHolder.<init>(ApplicationContextHolder.java:33)
at com.mypackages.ApplicationContext.getInstance(ApplicationContext.java:63)
at com.mypackages.ApplicationContextLoaderListener.contextInitialized(ApplicationContextLoaderListener.java:41)
at com.mypackages.LoggingServiceContextListener.contextInitialized(LoggingServiceContextListener.java:49)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1834)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:442)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:171)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:904)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:789)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:427)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:719)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1247)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1514)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:704)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:1096)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:799)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$5.run(ApplicationMgrImpl.java:2315)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5466)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5682)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2320)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:436)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:379)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:127)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:985)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:524)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1909)
Caused by: javax.naming.NamingException: ClientAdminService [Root exception is java.rmi.NoSuchObjectException: object not exported]
at com.ibm.ws.naming.jndicos.CNContextImpl.doRebind(CNContextImpl.java:2148)
at com.ibm.ws.naming.jndicos.CNContextImpl.rebind(CNContextImpl.java:698)
at com.ibm.ws.naming.util.WsnInitCtx.rebind(WsnInitCtx.java:233)
at com.ibm.ws.naming.util.WsnInitCtx.rebind(WsnInitCtx.java:245)
at org.apache.aries.jndi.DelegateContext.rebind(DelegateContext.java:177)
at javax.naming.InitialContext.rebind(InitialContext.java:444)
at org.springframework.jndi.JndiTemplate.lambda$rebind$2(JndiTemplate.java:213)
at org.springframework.jndi.JndiTemplate$$Lambda$142.000000001C87D5A0.doInContext(Unknown Source)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:91)
at org.springframework.jndi.JndiTemplate.rebind(JndiTemplate.java:212)
at org.springframework.remoting.rmi.JndiRmiServiceExporter.rebind(JndiRmiServiceExporter.java:132)
at org.springframework.remoting.rmi.JndiRmiServiceExporter.prepare(JndiRmiServiceExporter.java:120)
at org.springframework.remoting.rmi.JndiRmiServiceExporter.afterPropertiesSet(JndiRmiServiceExporter.java:104)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706)
... 41 more
Caused by: java.rmi.NoSuchObjectException: object not exported
at sun.rmi.transport.ObjectTable.getStub(ObjectTable.java:137)
at java.rmi.server.RemoteObject.toStub(RemoteObject.java:117)
at com.ibm.rmi.util.JDKBridge.getJRMPStub(JDKBridge.java:89)
at com.ibm.rmi.javax.rmi.PortableRemoteObject.toStub(PortableRemoteObject.java:187)
at com.ibm.CORBA.iiop.PortableRemoteObject.toStub(PortableRemoteObject.java:61)
at javax.rmi.PortableRemoteObject.toStub(PortableRemoteObject.java:127)
at com.ibm.ws.naming.util.Helpers.processRemoteObjectForBinding(Helpers.java:700)
at com.ibm.ws.naming.jndicos.CNContextImpl.doRebind(CNContextImpl.java:2061)
... 55 more


Affects: 5.0.4

Referenced from: commits 78681c6

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 29, 2018

Juergen Hoeller commented

Indeed, those PortableRemoteObject narrow calls are related to the JDK's CORBA support which is unavailable in the default set of JDK 9 modules... and to be completely removed in JDK 11. We'll see what we can do about conditionally calling it when available at runtime.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 29, 2018

John Zimmermann commented

thanks Juergen, I assume my workaround of just re-introducing those export/unexportObject calls in a custom JndiRmiServiceExporter class in the meantime is probably my best bet or do you see anything wrong with that approach?

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 29, 2018

Juergen Hoeller commented

That sounds totally fine to me.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 30, 2018

Juergen Hoeller commented

I've resolved this through reflective invocation of PortableRemoteObject.exportObject/unexportObject now which picks it up on Java 8 but nevertheless allows for building the core framework with JDK 9+ and -target 9/10/11).

@spring-projects-issues spring-projects-issues added type: bug in: web labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0.5 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web type: bug
Projects
None yet
Development

No branches or pull requests

2 participants