- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 Payara 4.x 和 5.x、Glassfish 4.x 和 5.x 以及 WildFly 11.0.0.Final 上,将 EJB 注入(inject)多模块 Maven Java EE 7 项目中的 JSF 托管 Bean 中均失败这让我认为这不是我最初认为的 Payara/Glassfish bug [1]。
WAR 模块中的简单 JSF 支持 bean
@Named
@ApplicationScoped
@Eager
public class Init {
@EJB
private InitService initService;
public Init() {
}
@PostConstruct
public void init() {
initService.init();
}
}
在 JAR 模块中使用 EJB 接口(interface)
@Local
public interface InitService {
void init();
}
以及EJB模块中的实现
@Stateless
public class DefaultInitService implements InitService {
@PersistenceContext
private EntityManager entityManager;
@Override
public void init() {
Long id = 1L;
MyEntity myEntity0 = entityManager.find(MyEntity.class, id);
if(myEntity0 == null) {
myEntity0 = new MyEntity(Long.MIN_VALUE, "myProperty");
entityManager.persist(myEntity0);
}
}
}
在 Payara 4.1.2.174 上失败的原因是
WARN: WELD-000718: No EEModuleDescriptor defined for bean archive with ID: payara-classloading-proxy-issue-web-1.0-SNAPSHOT_war.war. @Initialized and @Destroyed events for ApplicationScoped may be fired twice.
WARNUNG: Could not instantiate eager application scoped beans. Possibly the CDI application scope is not active. This is known to be the case in certain Tomcat and Jetty based configurations.
java.lang.IllegalStateException: Exception attempting to inject Local ejb-ref name=richtercloud.payara.classloading.proxy.issue.jar.Init/initService,Local 3.x interface =richtercloud.payara.classloading.proxy.issue.jar.InitService resolved to intra-app EJB DefaultInitService in module payara-classloading-proxy-issue-ejb-1.0-SNAPSHOT.jar,ejb-link=payara-classloading-proxy-issue-ejb-1.0-SNAPSHOT.jar#DefaultInitService,lookup=,mappedName=,jndi-name=,refType=Session into class richtercloud.payara.classloading.proxy.issue.jar.Init: Can not set richtercloud.payara.classloading.proxy.issue.jar.InitService field richtercloud.payara.classloading.proxy.issue.jar.Init.initService to com.sun.proxy.$Proxy254
at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:185)
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)
at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:72)
at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:159)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.bean.ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy.get(ContextualInstanceStrategy.java:140)
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:125)
at richtercloud.payara.classloading.proxy.issue.jar.Init$Proxy$_$$_WeldClientProxy.toString(Unknown Source)
at org.omnifaces.cdi.eager.EagerBeansRepository.instantiateBeans(EagerBeansRepository.java:135)
at org.omnifaces.cdi.eager.EagerBeansRepository.instantiateApplicationScoped(EagerBeansRepository.java:105)
at org.omnifaces.cdi.eager.EagerBeansRepository$Proxy$_$$_WeldClientProxy.instantiateApplicationScoped(Unknown Source)
at org.omnifaces.cdi.eager.EagerBeansRepository.instantiateApplicationScopedAndRegisterListenerIfNecessary(EagerBeansRepository.java:79)
at org.omnifaces.ApplicationListener.contextInitialized(ApplicationListener.java:83)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4991)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:574)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5560)
at com.sun.enterprise.web.WebModule.start(WebModule.java:522)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:956)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:939)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2099)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1745)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:294)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:357)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:501)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:220)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:508)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:544)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:540)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:570)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:562)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:561)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1469)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:111)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1851)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1727)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:483)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Local ejb-ref name=richtercloud.payara.classloading.proxy.issue.jar.Init/initService,Local 3.x interface =richtercloud.payara.classloading.proxy.issue.jar.InitService resolved to intra-app EJB DefaultInitService in module payara-classloading-proxy-issue-ejb-1.0-SNAPSHOT.jar,ejb-link=payara-classloading-proxy-issue-ejb-1.0-SNAPSHOT.jar#DefaultInitService,lookup=,mappedName=,jndi-name=,refType=Session into class richtercloud.payara.classloading.proxy.issue.jar.Init: Can not set richtercloud.payara.classloading.proxy.issue.jar.InitService field richtercloud.payara.classloading.proxy.issue.jar.Init.initService to com.sun.proxy.$Proxy254
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:740)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:507)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:170)
at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:175)
... 68 more
Caused by: java.lang.IllegalArgumentException: Can not set richtercloud.payara.classloading.proxy.issue.jar.InitService field richtercloud.payara.classloading.proxy.issue.jar.Init.initService to com.sun.proxy.$Proxy254
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:764)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:688)
... 71 more
在 WildFly 上由于
04:52:16,873 WARNING [org.omnifaces.cdi.eager.EagerBeansRepository] (ServerService Thread Pool -- 81) Could not instantiate eager application scoped beans. Possibly the CDI application scope is not active. This is known to be the case in certain Tomcat and Jetty based configurations.: java.lang.IllegalArgumentException: Can not set richtercloud.payara.classloading.proxy.issue.jar.InitService field richtercloud.payara.classloading.proxy.issue.jar.Init.initService to richtercloud.payara.classloading.proxy.issue.jar.InitService$$$view3
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:764)
at org.jboss.weld.injection.FieldResourceInjection.injectMember(FieldResourceInjection.java:62)
at org.jboss.weld.injection.AbstractResourceInjection.injectResourceReference(AbstractResourceInjection.java:63)
at org.jboss.weld.util.Beans.injectEEFields(Beans.java:331)
at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:69)
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:72)
at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:159)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.bean.ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy.get(ContextualInstanceStrategy.java:140)
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:125)
at richtercloud.payara.classloading.proxy.issue.jar.Init$Proxy$_$$_WeldClientProxy.toString(Unknown Source)
at org.omnifaces.cdi.eager.EagerBeansRepository.instantiateBeans(EagerBeansRepository.java:135)
at org.omnifaces.cdi.eager.EagerBeansRepository.instantiateApplicationScoped(EagerBeansRepository.java:105)
at org.omnifaces.cdi.eager.EagerBeansRepository$Proxy$_$$_WeldClientProxy.instantiateApplicationScoped(Unknown Source)
at org.omnifaces.cdi.eager.EagerBeansRepository.instantiateApplicationScopedAndRegisterListenerIfNecessary(EagerBeansRepository.java:79)
at org.omnifaces.ApplicationListener.contextInitialized(ApplicationListener.java:83)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:205)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:174)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:239)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:99)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
WAR项目的Maven依赖项是
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.1</version>
</dependency>
<dependency>
<groupId>richtercloud</groupId>
<artifactId>payara-classloading-proxy-issue-jar</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.6.7</version>
</dependency>
和 JAR
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.14.1.0</version>
</dependency>
这是 How to use OmniFaces @Eager annotation with PrimeFaces? 的前面,但与 https://github.com/payara/Payara/issues/2237 不同,因为在该问题中,即使正确配置了日志记录,我也没有收到任何异常或其他反馈。
通过引用的问题可以轻松找到在普通 Docker 镜像上重现问题的示例项目和 GitLab CI 输出(不同分支上的不同 AS 以及相应 CI 管道部分上的输出)
<小时/>[1] 在 https://github.com/javaee/glassfish/issues/22401 和 ojit_a 上报告了一个更简化的示例,该示例也与代理类转换异常相关,但堆栈中没有涉及焊接。
最佳答案
...Proxy
类强制转换异常问题是由 JAR 模块的 Maven compile
范围引起的(包含位于 WEB 和 EJB 模块旁边的实体和 EJB 接口(interface),其中包含EJB 实现)在 WEB 模块中。这会导致 EJB 接口(interface)类由不同的类加载器加载(这在此 Java EE 设置中是正确的),以便根据类加载器工作方式的定义将它们视为不同的类。
可以通过在 WEB 模块中将范围更改为 provided
来避免此问题,且没有任何缺点。
应用程序服务器(GlassFish 和 WildFly 以及可能的其他)的反馈与许多(Java EE)技术一样可怕,我建议改进,尽管我明白黄金法则是,如果您的应用程序正常工作,那么您'已经完成了 20% 的工作,现在您需要处理剩余 80% 的工作,以便在所有可能的情况下获得有用的反馈,这需要一些时间(意味着几十年)才能实现。
关于jsf - "IllegalArgumentException: Can not set [EJB interface] field [managed bean field] to com.sun.proxy.$Proxy[some number]"与 OmniFaces 的@Eager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48256783/
编写一个仅用于集中其他接口(interface)的接口(interface)是好的做法还是坏的做法? interface InterfaceA : InterfaceB, InterfaceC { }
有没有一种方法可以确定具体类型从任意接口(interface)列表?我知道类型转换,但我想知道所有满意的接口(interface)。 例如,给定: type Mover interface { Mo
我正在尝试制作斐波那契堆。 (在我正在上的算法课中多次提到它们,我想检查一下。)我希望堆使用任何类型的节点,所以我定义了一个 Node 接口(interface): package node type
这是我的代码: type IA interface { FB() IB } type IB interface { Bar() string } type A struct {
示例 A: // pseudo code interface IFoo { void bar(); } class FooPlatformA : IFoo { void bar() {
合并它编译的 leppies 反馈 - 但 IMO 有一些缺点,我希望编译器强制每个子类定义它们自己的 Uri 属性。现在的代码: [] type UriUserControl() = inh
我正在构建一个项目,该项目从用户那里获取一个术语,然后执行谷歌搜索并返回一个 json 格式的标题列表。 我正在使用 serpwow API 来执行谷歌搜索并试图解析响应。 但是我收到的错误是: pa
我只想在其他接口(interface)中实现某些接口(interface),我不希望它们能够被类直接继承。 提前致谢! 最佳答案 您不能在 C# 中执行此操作 - 任何类都可以实现它有权访问的任何接口
我是 Go 的新手,还有一些我还没有掌握的技巧 例如,我有一个可以这样调用的函数: myVar.InitOperation("foo",Operator.EQUAL,"bar") myVar.Init
我有一个通用接口(interface)来描述对输出流的访问,如下所示: interface IOutput { function writeInteger(aValue:Int):Void;
我正在做一个项目,我想通过某种接口(interface)(最好是 USB)将光电探测器电路安装到计算机上。但是,由于我是新手,所以我不知道应该朝哪个方向处理这个问题。假设我有一个带有 USB 连接的光
背景 我正在尝试创建一个简单的应用程序,以真正理解DDD + TDD + etc的整个堆栈。我的目标是在运行时动态注入DAL存储库类。这让我 域和应用程序服务层可测试。我打算用“穷人的DI”来完成 现
在 Java 中,接口(interface)扩展接口(interface)是完全合法的。 UML 中的这种关系看起来像“扩展”关系(实线、闭合、未填充的箭头)还是“实现”关系(虚线、闭合、未填充的箭头
我想创建一个具有相等和比较函数默认实现的接口(interface)。 如果我从类型 IKeyable 中删除所有内容除了Key成员,只要我不添加默认实现,它就是一个有效的接口(interface)。从
COM 中的双接口(interface)是能够通过 DispInterface 或 VTable 方法访问的接口(interface)。 现在有人可以告诉我这两种方法之间到底有什么区别吗? 我认为 V
我有一个类方法,它返回一个可以迭代的员工列表。返回列表的最佳方式是什么?通常我只返回一个 ArrayList。然而,据我了解,界面更适合这种类型的操作。哪个是最好使用的界面?另外,为什么返回接口(in
我想从包装类外部实例化一个内部非静态接口(interface)。 这可能吗? 考虑以下代码: shared class AOuterClass() { Integer val = 3; shared
我为一个类编写了一个接口(interface),如下所示: public interface IGenericMultipleRepository { Lazy> addresses { ge
我是 UML 的初学者,现在我正在创建一个序列图,问题是我想根据用户输入实现 DAO 接口(interface)。如何在时序图中正确绘制以实现接口(interface)。 最佳答案 您不会在 SD 上
要使用 jsr 303 验证创建有条件验证的组,请将接口(interface)类传递给注释,如下所示: @NotEmpty (groups={UpdateValue.class}) 我有很多不同的接口
我是一名优秀的程序员,十分优秀!