我目前正在阅读类加载器及其层次结构功能。如果我调用下面的代码 -
ClassA a= Class.forName("com.test.ClassA")
Run Code Online (Sandbox Code Playgroud)
根据我的理解,现在它将在应用程序类加载器的帮助下初始化并加载到内存中。我有以下问题:
我的EJB-JBOSS配置目前面临着“ JBAS014516:未能在5分钟内获得许可”的问题。下面是我的配置-
<subsystem xmlns="urn:jboss:domain:ejb3:1.4">
<session-bean>
<stateless>
<bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
</stateless>
<stateful default-access-timeout="5000" cache-ref="simple"/>
<singleton default-access-timeout="5000"/>
</session-bean>
<mdb>
<resource-adapter-ref resource-adapter-name="hornetq-ra"/>
<bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb>
<pools>
<bean-instance-pools>
<strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
<strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
</bean-instance-pools>
</pools>
<caches>
<cache name="simple" aliases="NoPassivationCache"/>
<cache name="passivating" passivation-store-ref="file" aliases="SimpleStatefulCache"/>
<cache name="clustered" passivation-store-ref="abc" aliases="StatefulTreeCache"/>
</caches>
<async thread-pool-name="default"/>
<timer-service thread-pool-name="default">
<data-store path="timer-service-data" relative-to="jboss.server.data.dir"/>
</timer-service>
<remote connector-ref="remoting-connector" thread-pool-name="default"/>
<thread-pools>
<thread-pool name="default">
<max-threads count="10"/>
<keepalive-time time="100" unit="milliseconds"/>
</thread-pool>
</thread-pools>
<iiop enable-by-default="false" use-qualified-name="false"/>
<default-security-domain value="other"/>
<default-missing-method-permissions-deny-access value="true"/>
</subsystem>
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,我应该将“ strict-max-pool”增加到一个更高的值或增加线程池的大小。
我目前正在使用 Spring boot test 测试我的一项服务。该服务导出所有用户数据并在成功完成后生成 CSV 或 PDF。在浏览器中下载文件。
以下是我在测试类中编写的代码
MvcResult result = MockMvc.perform(post("/api/user-accounts/export").param("query","id=='123'")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_PDF_VALUE)
.content(TestUtil.convertObjectToJsonBytes(userObjectDTO)))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_PDF_VALUE))
.andReturn();
String content = result.getResponse().getContentAsString(); // verify the response string.
Run Code Online (Sandbox Code Playgroud)
下面是我的资源类代码(调用到这个地方)-
@PostMapping("/user-accounts/export")
@Timed
public ResponseEntity<byte[]> exportAllUsers(@RequestParam Optional<String> query, @ApiParam Pageable pageable,
@RequestBody UserObjectDTO userObjectDTO) {
HttpHeaders headers = new HttpHeaders();
.
.
.
return new ResponseEntity<>(outputContents, headers, HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
当我调试我的服务并在退出之前放置调试时,我得到的内容类型为“应用程序/pdf”,状态为 200。我试图在我的测试用例中复制相同的内容类型。不知何故,它在执行过程中总是抛出以下错误 -
java.lang.AssertionError: Status
Expected :200
Actual :406
Run Code Online (Sandbox Code Playgroud)
我想知道,我应该如何检查我的响应(ResponseEntity)。还有什么应该是响应所需的内容类型。
class ×1
classloader ×1
ejb ×1
ejb-3.1 ×1
java ×1
jboss6.x ×1
junit ×1
spring ×1
spring-boot ×1
testcase ×1
threadpool ×1