Неверное определение компонента с именем 'java: / TDS', определенным в среде JNDI - PullRequest
0 голосов
/ 22 апреля 2020

В настоящее время я использую Spring Boot и пытаюсь включить библиотечный класс, который в настоящее время используется в контексте Java EE. В этом filename.jar есть реализация файла EJB, который имеет @Resource(mappedName="java:/TDS" инъекцию в качестве источника данных. Этот источник данных был сконфигурирован в постоянстве. xml как показано ниже:

persisten c. xml

<persistence-unit name="defaultTDSoft">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <jta-data-source>java:/TDS</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.InformixDialect"/>
    </properties>
</persistence-unit>

EJB-файл

@Stateless
@Remote({ContactenManagerRemote.class})
public class ContactenManager implements ContactenManagerRemote {
        private transient Logger logger = Logger.getLogger(this.getClass().getName());
        @PersistenceContext
        private EntityManager manager;
        @Resource( mappedName = "java:/TDS" )
        private DataSource mydb;

        public ContactenManager() {
        }
    }

Я пытаюсь вставить этот EJB в пружинную загрузку через BeanConfiguration.java, как показано ниже:

@Configuration
@EntityScan(basePackageClasses = {de.mavin.model.entities.AfingEntity.class, de.mavin.model.session.impl.contactenManage.class, OntEntityIntern.class})
public class TDSoftBeanConfiguration {
    @Bean
    public ContactenManager contactenManager(){
        return new ContactenManager();
    }
}

Ошибка:

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'java:/TDS' defined in JNDI environment: JNDI lookup failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at org.springframework.jndi.support.SimpleJndiBeanFactory.getBean(SimpleJndiBeanFactory.java:129) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:504) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:653) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:224) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116) ~[spring-beans-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:334) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    ... 22 common frames omitted
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662) ~[na:1.8.0_252]
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313) ~[na:1.8.0_252]
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350) ~[na:1.8.0_252]
    at javax.naming.InitialContext.lookup(InitialContext.java:417) ~[na:1.8.0_252]
    at org.springframework.jndi.JndiTemplate.lambda$lookup$0(JndiTemplate.java:157) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:92) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:157) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179) ~[spring-context-5.2.0.RELEASE.jar:5.2.0.RELEASE]

Я использую последнюю версию spring-boot с java 8, JEE 8.

Любое решение этой проблемы приветствуется?

...