Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java weblogic部署期间不注入依赖项_Java_Spring_Deployment_Dependency Injection_Weblogic - Fatal编程技术网

Java weblogic部署期间不注入依赖项

Java weblogic部署期间不注入依赖项,java,spring,deployment,dependency-injection,weblogic,Java,Spring,Deployment,Dependency Injection,Weblogic,我想在weblogic上部署我的项目,但当我部署war时,我的spring applicationContext会被加载,当它开始水合缓存时,它会崩溃,给我一个空指针异常。当我调试时,我看到我的持久性实体类(在该方法中使用)被实例化,没有依赖项,这意味着它们没有被注入 我的实体类用@Configurable标记,依赖项的getter和setter方法用@Transient标记。此外,当我运行测试时,它会在实体类中注入依赖项,而当我尝试部署到weblogic时,它似乎不会注入依赖项。我不知道从哪里

我想在weblogic上部署我的项目,但当我部署war时,我的spring applicationContext会被加载,当它开始水合缓存时,它会崩溃,给我一个空指针异常。当我调试时,我看到我的持久性实体类(在该方法中使用)被实例化,没有依赖项,这意味着它们没有被注入

我的实体类用@Configurable标记,依赖项的getter和setter方法用@Transient标记。此外,当我运行测试时,它会在实体类中注入依赖项,而当我尝试部署到weblogic时,它似乎不会注入依赖项。我不知道从哪里开始寻找问题,因此我不知道应该向您提供哪些代码

任何关于我应该在谷歌上搜索什么或在哪里搜索的提示都将不胜感激。另外,如果你想看看一些代码,只要问一下,我会添加它

谢谢你,我为缺少代码而道歉,但我不知道哪一位会真正有帮助,哪一位代码是无用的

编辑:

添加代码 实体类

@Configurable
@javax.persistence.Entity
@Table(name = "Some_Table")
public class InteractionImpl implements Interaction, Serializable {

    private Long interactionId;
    private Long initiatorEntityNr;
    private Long agentEntityNr;

    transient private BuilderB builderB;
    transient private BuilderA builderA;

    @Id
    @Column(name = "justAnotherID")
    public Long getInteractionId() {
        return interactionId;
    }

    public void setInteractionId(Long interactionId) {
        this.interactionId = interactionId;
    }

    @Column(name = "someCodeB")
    private Long getInitiatorEntityNr() {
        return initiatorEntityNr;
    }

    private void setInitiatorEntityNr(Long initiatorEntityNr) {
        this.initiatorEntityNr = initiatorEntityNr;
    }

    @Column(name = "someCodeA")
    private Long getAgentEntityNr() {
        return agentEntityNr;
    }

    private void setAgentEntityNr(Long agentEntityNr) {

        this.agentEntityNr = agentEntityNr;
    }

    @Transient
    public Agent getAgent() throws CrmEntityCreationException {
        if (getAgentEntityNr() != null)
            return builderA.buildShallowEntity(getAgentEntityNr());
        else
            throw new CrmEntityCreationException("There was no agent entity number so the entity could not be found");
}

    @Transient
    public void setAgent(Agent agentEntity) {
        setAgentEntityNr(agentEntity.getEntityNumber());
    }

    @Transient
    public Customer getInitiator() throws CrmEntityCreationException {
        if (getInitiatorEntityNr() != null) {
            return builderB.buildShallowEntity(getInitiatorEntityNr());
        } else {
            throw new CrmEntityCreationException("The interaction does not contain an initiator entity number");
        }
    }

    @Transient
    public void setInitiator(Customer initiatorEntity) {
        setInitiatorEntityNr(initiatorEntity.getEntityNumber());
    }

    @Transient
    private BuilderB getCustomerBuilder() {
        return builderB;
    }

    @Inject
    @Transient
    public void BuilderB(BuilderB builderB) {
        this.builderB = builderB;
    }

    @Transient
    private BuilderA getBuilderA() {
        return builderA;
    }

    @Inject
    @Transient
    public void setBuilderA(BuilderA builderA) {
        this.builderA = builderA;
    }



}
应用程序上下文

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jee="http://www.springframework.org/schema/jee"

       xsi:schemaLocation="
       http://www.springframework.org/schema/jee
       http://www.springframework.org/schema/jee/spring-jee.xsd
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-4.1.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">

    <context:load-time-weaver weaver-class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
    <tx:annotation-driven transaction-manager="transactionManager" mode="aspectj"/>
    <context:component-scan base-package="crm.persistence"/>
    <context:component-scan base-package="crm.services.impl"/>
    <context:annotation-config/>
    <context:spring-configured/>


    <bean id="hazelcast" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"/>

    <bean id="httpComponentMessageSender" class="org.springframework.ws.transport.http.HttpComponentsMessageSender"/>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@someConnection:1521:xe"/>
        <property name="username" value="someUsername"/>
        <property name="password" value="somePassword"/>
    </bean>

    <bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="loadTimeWeaver" ref="loadTimeWeaver"></property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="emf"/>
    </bean>

    <bean class="org.springframework.transaction.aspectj.JtaAnnotationTransactionAspect" factory-method="aspectOf">
    </bean>

    <bean id="interactionCache" class="crm.services.impl.Caching.InteractionCacheImpl">
        <property name="ammountOfInteractionToReturn" value="10"/>
    </bean>

    <bean id="interactions" class="crm.persistence.entities.InteractionImpl" scope="prototype"/>

    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject" ref="interactionCache"/>
        <property name="targetMethod" value="rehydrateAllCaches"/>
    </bean>

    <bean id="agentCache" class="crm.services.impl.Caching.AgentCacheImpl"/>

    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject" ref="agentCache"/>
        <property name="targetMethod" value="rehydrateAll"/>
    </bean>

    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject" ref="alertCache"/>
        <property name="targetMethod" value="rehydrateAll"/>
    </bean>
 </beans>

然后是我的SpringWebService servlet

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:sws="http://www.springframework.org/schema/web-services"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <import resource="classpath:applicationContext.xml"/>

    <!--scans for spring-ws annotation-->
   <sws:annotation-driven/>

</beans>

My web.xml

    <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

    <servlet>
        <servlet-name>spring-ws</servlet-name>
        <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    </servlet>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <servlet-mapping>
        <servlet-name>spring-ws</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

春季天气预报
org.springframework.ws.transport.http.MessageDispatcherServlet
上下文配置位置
类路径:applicationContext.xml
org.springframework.web.context.ContextLoaderListener
春季天气预报
/*
然后是我的weblogic.xml

    <?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">

    <context-root>/CrmService</context-root>
    <container-descriptor>
        <prefer-application-packages>
        <package-name>org.jboss.logging.*</package-name>
        </prefer-application-packages>
    </container-descriptor>
</weblogic-web-app>

/CRM服务
org.jboss.logging*
正如在我的应用程序上下文中所看到的,我有两个重新水化的缓存。水合物方法调用DAO以查找相关交互(实体类)的列表,然后调用
getAgent()
getInitiator()
方法。由于
builderA
builderB
未被注入,因此会抛出空指针异常


只是提醒您,它在我的集成测试中注入了这些类,而不是在我尝试将其部署到weblogic时。我不使用tomcat

您的项目是使用tomcat还是只使用weblogic?你有没有找到相关的线索?如果我们知道去哪里找的话,我有IntelliJ IDE open随时准备帮助你。也许你可以有一个可以工作的引用项目,并将其增量更改为你的项目,然后查看异常发生在哪个更改中。我使用intellij,只与weblogic一起工作,我不相信堆栈跟踪会有多大帮助,因为它只指示空指针被抛出的点。我将为实体类、应用程序上下文以及SpringWebServiceServlet添加代码。我用spring安装好后再给你回复。如果你不使用弹簧靴(?)不,你看到的就是你得到的。这似乎很直截了当。首先,我在部署它时遇到了问题。我必须得到hibernate验证器cdi依赖项,因为我一直得到AbstractMethodError。您的项目是使用tomcat还是仅使用weblogic?你有没有找到相关的线索?如果我们知道去哪里找的话,我有IntelliJ IDE open随时准备帮助你。也许你可以有一个可以工作的引用项目,并将其增量更改为你的项目,然后查看异常发生在哪个更改中。我使用intellij,只与weblogic一起工作,我不相信堆栈跟踪会有多大帮助,因为它只指示空指针被抛出的点。我将为实体类、应用程序上下文以及SpringWebServiceServlet添加代码。我用spring安装好后再给你回复。如果你不使用弹簧靴(?)不,你看到的就是你得到的。这似乎很直截了当。首先,我在部署它时遇到了问题。我必须得到hibernate验证程序cdi依赖项,因为我一直得到AbstractMethodError。