我有一个使用Spring Batch的批处理应用程序,我也使用Spring Boot。此应用程序需要执行远程EJB查找以从应用程序服务器加载一些信息。 到目前为止,我们使用的是JBoss EAP 6.1。我的pom.xml包含一个特定于JBoss的配置文件,我使用了以下依赖项:
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
<version>7.2.0.Final</version>
<type>pom</type>
</dependency>
现在我们需要将此应用程序迁移到WebSphere 8.5.5。我在我的pom.xml中创建了一个新的maven配置文件,其中包含WebSphere上的远程EJB查找的以下依赖项。
<dependency>
<groupId>com.ibm.ws</groupId>
<artifactId>com.ibm.ws.ejb.thinclient</artifactId>
<version>8.5.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.ibm.ws</groupId>
<artifactId>com.ibm.ws.orb</artifactId>
<version>8.5.0</version>
<type>pom</type>
</dependency>
当然,我已经在我的maven本地存储库中安装了这个jar。
在配置所有JNDI属性后,尝试再次执行批处理,初始上下文工厂指向&#34; com.ibm.websphere.naming.WsnInitialContextFactory&#34;和提供者URL到&#34; corbaloc:iiop:localhost:2817&#34;,我得到以下例外:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [br.com.cpqd.components.security.api.user.SecurityUser]: Factory method 'securityUserEjb' threw exception; nested exception is javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory [Root exception is java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 27 common frames omitted
Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at org.springframework.jndi.JndiTemplate.createInitialContext(JndiTemplate.java:136)
at org.springframework.jndi.JndiTemplate.getContext(JndiTemplate.java:103)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:231)
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:217)
at br.com.batch.common.BatchCommonConfig.securityUserEjb(BatchCommonConfig.java:101)
at br.com.batch.common.BatchCommonConfig$$EnhancerBySpringCGLIB$$e2167a67.CGLIB$securityUserEjb$4(<generated>)
at br.com.cpqd.saf.events.batch.common.BatchCommonConfig$$EnhancerBySpringCGLIB$$e2167a67$$FastClassBySpringCGLIB$$30b25502.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
at br.com.batch.common.BatchCommonConfig$$EnhancerBySpringCGLIB$$e2167a67.securityUserEjb(<generated>)
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:606)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 28 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:63)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:671)
... 51 common frames omitted
好的,这个班还没找到。试图弄清楚问题,我已经改变了来自&#34; pom&#34;的WebSphere库的依赖类型。 to&#34; jar&#34;。
现在,我收到以下异常:
(抱歉这个葡萄牙语文本,但错误代码可能有帮助)
**NMSV0307E**: Um nome de URL java: foi utilizado, mas a Nomenclatura não foi configurada para manipular nomes de URL java:. A causa provável é um erro do usuário ao tentar especificar um nome de URL java: em um cliente não J2EE ou no ambiente do servidor. Emitindo ConfigurationException.
2016-06-06 14:43:18.952 WARN 18856 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor': Invocation of init method failed; nested exception is javax.validation.ValidationException: Could not create Configuration.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:199)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at br.com.cpqd.saf.events.batch.BatchProcessingBootstrap.main(BatchProcessingBootstrap.java:62)
Caused by: javax.validation.ValidationException: Could not create Configuration.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:175)
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:223)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor$Jsr303ValidatorFactory.run(ConfigurationPropertiesBindingPostProcessor.java:381)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.afterPropertiesSet(ConfigurationPropertiesBindingPostProcessor.java:174)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
... 12 common frames omitted
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:173)
... 17 common frames omitted
搜索错误消息并阅读大量网站,我认为由于某种原因,Spring Boot不允许com.ibm.ws.ejb.thinclient jar提供的可嵌入EJB容器启动,但是我是不确定。
有没有人试图这样做?
答案 0 :(得分:0)
IndexOutOfBoundsException
是javax.validation.Validation在类路径上可用的API(可能是com.ibm.ws.ejb.thinclient JAR)时抛出的(差)异常,但实现提供程序不是。根据{{3}},ConfigurationPropertiesBindingPostProcessor
类在类路径上可用时会尝试使用javax.validation API。
我不太了解Spring Boot,知道是否有办法禁用你的行为,所以我最好的建议是在你的类路径中包含一个javax.validation实现。例如,您还可以包含com.ibm.ws.jpa.thinclient JAR。