我有一个Web应用程序,它在一个独立的线程中运行Spring Integration逻辑.问题是,在某些时候,我的Spring Integration逻辑尝试使用请求范围的bean,然后我得到以下错误:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.tenantContext': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still …Run Code Online (Sandbox Code Playgroud) 我有一个使用FreeMarker的大型Web应用程序.当我最近更新到Spring 3.2.4并通过jetty或tomcat运行web应用程序时,我得到以下异常:java.lang.ClassNotFoundException:org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.
我知道Spring-webmvc中有FreeMarkerConfigurationFactory类,所以我的POM中包含依赖项.我不知道为什么我得到例外.我已经包含了我的POM和我的弹簧servlet.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>WhiteSwan-Web</artifactId>
<groupId>com.millad.whiteswan.web</groupId>
<version>1.5</version>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.12.v20130726</version>
</plugin>
</plugins>
</build>
<properties>
<org.springframework.version>3.2.4.RELEASE</org.springframework.version>
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
<junit.version>4.11</junit.version>
<joda.time.version>2.2</joda.time.version>
<mockito.version>1.9.5</mockito.version>
<freemarker.version>2.3.20</freemarker.version>
</properties>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta8</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta8</version>
</dependency>
<dependency>
<groupId>com.foursquare</groupId>
<artifactId>fongo</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.5</version>
</dependency>
<!-- …Run Code Online (Sandbox Code Playgroud) 在开始之前:我知道子节点从父节点继承命名空间,这就是我的问题发生的原因.不幸的是,我发送XML的Web服务不接受没有命名空间的子节点,并且因为它是一个政府实体,所以它们的部分变化是不太可能的.
话虽这么说,我使用Spring-WS在我的应用程序和Web服务之间进行通信,因此框架使用变换器以一种方式使用转换器将我的有效负载源解析为框架的有效负载结果:
transformer.transform(Source, Result);
Run Code Online (Sandbox Code Playgroud)
在进行转换之前,我的XML有这两个节点,如下所示:
<enviNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10">
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
Run Code Online (Sandbox Code Playgroud)
转换后,第二个命名空间被删除(正如我之前所说,我知道原因):
<enviNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10">
<NFe>
Run Code Online (Sandbox Code Playgroud)
我也知道我可以使用marshallers来实现相同的结果并自己编写解析代码.使用这种方法也是可以接受的,但我不知道使用除上面列出的方法之外的其他方法来实现相同的事情(转换javax.xml.transform.Source为javax.xml.transform.Result).
那我有两个问题:
1 - 我可以避免使用默认方法(不使用marshallers)的行为吗?
2 - 是否还有其他工具可以进行相同的转换?
我正在使用部署在JBoss 7.1.1上的DeltaSpike 1.7.1和CDI 1.0(Weld 1.1.5).这是一个遗留项目,我无法改变我们正在使用的技术.
当我部署多个WAR文件(我知道CDI有问题只发生/曾与一个EAR内的多个WAR文件有问题,但我没有找到一个EAR文件之外的JBOSS实例的多个WAR文件什么.
请注意,每次部署项目时都不会发生问题,通常情况下,当我要求Jenkins同时构建和部署多个项目时,我会收到以下错误消息:
WELD-001318 Cannot resolve an ambiguous dependency between [Managed Bean [class org.apache.deltaspike.core.impl.scope.window.DefaultWindowContextQuotaHandler] with qualifiers [@Any @Default], Managed Bean [class org.apache.deltaspike.jsf.impl.scope.window.JsfWindowContextQuotaHandler] with qualifiers [@Any @Default]]
我试图摆脱DeltaSpike,但项目严重依赖于@ViewAccessScoped注释,这将浪费大量时间来改变它.
我周围挖找到一个解决方案,以使用Oracle,我能找到这样的唯一的事情是远远方法这个问题NEXTVAL从com.mysema.query.sql.SQLExpression了,但我不太清楚如何使用它甚至在文档中也找不到任何东西.
是否有人不得不使用它并且还想出来了?
java ×4
spring ×2
cdi ×1
deltaspike ×1
freemarker ×1
jboss7.x ×1
jetty ×1
querydsl ×1
spring-aop ×1
spring-mvc ×1
spring-ws ×1
xml ×1
xml-parsing ×1