How to use OmniFaces @Eager annotation with PrimeFaces?

本小妞迷上赌 提交于 2020-03-04 07:08:19

问题


PrimeFaces and OmniFaces can be used together in a JSF project. My project is using PrimeFaces 6.1 and works fine. However simply declaring the Maven dependency for OmniFaces

<dependency>
    <groupId>org.omnifaces</groupId>
    <artifactId>omnifaces</artifactId>
    <version>2.6.7</version>
</dependency>

doesn't cause the @Eager annotation an application scoped bean injected with @Named to have any effect.

Afaik instructions for CombinedResourceHandler don't solve this problem because it's an injection problem.

A typical deployment looks like this in the server log:

WARN:   WELD-000718: No EEModuleDescriptor defined for bean archive with ID: project1-web-1.0-SNAPSHOT_war.war. @Initialized and @Destroyed events for ApplicationScoped may be fired twice.
INFORMATION:   file:/home/richter/project1-aggregator/project1/project1-ear/target/gfdeploy/project1-ear/lib/project1-jar-1.0-SNAPSHOT.jar_richtercloud_project1-ifaces_jar_1.0-SNAPSHOTPU logout successful
WARNUNG:   Input stream has been finalized or forced closed without being explicitly closed; stream instantiation reported in following stack trace
java.lang.Throwable
    at com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream.<init>(ASURLClassLoader.java:1284)
    at com.sun.enterprise.loader.ASURLClassLoader$InternalJarURLConnection.getInputStream(ASURLClassLoader.java:1392)
    at java.net.URL.openStream(URL.java:1045)
    at org.javamoney.moneta.spi.MonetaryConfig.<init>(MonetaryConfig.java:52)
    at org.javamoney.moneta.spi.MonetaryConfig.<clinit>(MonetaryConfig.java:39)
    at org.javamoney.moneta.internal.DefaultMonetaryCurrenciesSingletonSpi.getDefaultProviderChain(DefaultMonetaryCurrenciesSingletonSpi.java:99)
    at org.javamoney.moneta.internal.DefaultMonetaryCurrenciesSingletonSpi.collectProviders(DefaultMonetaryCurrenciesSingletonSpi.java:69)
    at org.javamoney.moneta.internal.DefaultMonetaryCurrenciesSingletonSpi.getCurrencies(DefaultMonetaryCurrenciesSingletonSpi.java:42)
    at javax.money.spi.MonetaryCurrenciesSingletonSpi.getCurrency(MonetaryCurrenciesSingletonSpi.java:72)
    at javax.money.Monetary.getCurrency(Monetary.java:422)
    at richtercloud.project1.jar.entities.offer.AbstractOffer.<init>(AbstractOffer.java:205)
    at richtercloud.project1.jar.entities.offer.OfferEdit.<init>(OfferEdit.java:77)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.eclipse.persistence.descriptors.ClassDescriptor.preInitialize(ClassDescriptor.java:3982)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:649)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:632)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:568)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:799)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:743)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527)
    at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:358)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:207)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:114)
    at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:225)
    at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:525)
    at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:240)
    at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:170)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:926)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:435)
    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)

INFORMATION:   EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd
INFORMATION:   file:/home/richter/project1-aggregator/project1/project1-ear/target/gfdeploy/project1-ear/lib/project1-jar-1.0-SNAPSHOT.jar_richtercloud_project1-ifaces_jar_1.0-SNAPSHOTPU login successful
INFORMATION:   Portable JNDI names for EJB DefaultAppDataService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultAppDataService!richtercloud.project1.jar.controller.AppDataService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultAppDataService]
INFORMATION:   [FileBackingStore::initialize] Successfully Created and initialized store. Working dir: /home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultReviewService-99309011086253301; Configuration: BackingStoreConfiguration{clusterName='null', instanceName='null', storeName='DefaultReviewService-99309011086253301-BackingStore', shortUniqueName='99309011086253301', storeType='file', maxIdleTimeInSeconds=-1, relaxVersionCheck='null', maxLoadWaitTimeInSeconds=0, baseDirectoryName='/home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultReviewService-99309011086253301', keyClazz=interface java.io.Serializable, valueClazz=class org.glassfish.ha.store.util.SimpleMetadata, synchronousSave=false, typicalPayloadSizeInKiloBytes=0, vendorSpecificSettings={value.class.is.thread.safe=true, async.replication=true, start.gms=false, local.caching=true, broadcast.remove.expired=false, key.transformer=com.sun.ejb.base.sfsb.util.SimpleKeyGenerator@7e1b1d92}}
INFORMATION:   StatefulContainerbuilder instantiated store: org.glassfish.ha.store.adapter.file.FileBackingStore@5d2b6144, with ha-enabled [false], and backing store configuration: BackingStoreConfiguration{clusterName='null', instanceName='null', storeName='DefaultReviewService-99309011086253301-BackingStore', shortUniqueName='99309011086253301', storeType='file', maxIdleTimeInSeconds=-1, relaxVersionCheck='null', maxLoadWaitTimeInSeconds=0, baseDirectoryName='/home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultReviewService-99309011086253301', keyClazz=interface java.io.Serializable, valueClazz=class org.glassfish.ha.store.util.SimpleMetadata, synchronousSave=false, typicalPayloadSizeInKiloBytes=0, vendorSpecificSettings={value.class.is.thread.safe=true, async.replication=true, start.gms=false, local.caching=true, broadcast.remove.expired=false, key.transformer=com.sun.ejb.base.sfsb.util.SimpleKeyGenerator@7e1b1d92}}
INFORMATION:   Portable JNDI names for EJB DefaultReviewService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultReviewService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultReviewService!richtercloud.project1.jar.controller.ReviewService]
INFORMATION:   [FileBackingStore::initialize] Successfully Created and initialized store. Working dir: /home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultOfferService-99309011086226578; Configuration: BackingStoreConfiguration{clusterName='null', instanceName='null', storeName='DefaultOfferService-99309011086226578-BackingStore', shortUniqueName='99309011086226578', storeType='file', maxIdleTimeInSeconds=-1, relaxVersionCheck='null', maxLoadWaitTimeInSeconds=0, baseDirectoryName='/home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultOfferService-99309011086226578', keyClazz=interface java.io.Serializable, valueClazz=class org.glassfish.ha.store.util.SimpleMetadata, synchronousSave=false, typicalPayloadSizeInKiloBytes=0, vendorSpecificSettings={value.class.is.thread.safe=true, async.replication=true, start.gms=false, local.caching=true, broadcast.remove.expired=false, key.transformer=com.sun.ejb.base.sfsb.util.SimpleKeyGenerator@657d1a8b}}
INFORMATION:   StatefulContainerbuilder instantiated store: org.glassfish.ha.store.adapter.file.FileBackingStore@6a9b2d3b, with ha-enabled [false], and backing store configuration: BackingStoreConfiguration{clusterName='null', instanceName='null', storeName='DefaultOfferService-99309011086226578-BackingStore', shortUniqueName='99309011086226578', storeType='file', maxIdleTimeInSeconds=-1, relaxVersionCheck='null', maxLoadWaitTimeInSeconds=0, baseDirectoryName='/home/richter/payara-4.1.2.174/glassfish/domains/payaradomain/session-store/DefaultOfferService-99309011086226578', keyClazz=interface java.io.Serializable, valueClazz=class org.glassfish.ha.store.util.SimpleMetadata, synchronousSave=false, typicalPayloadSizeInKiloBytes=0, vendorSpecificSettings={value.class.is.thread.safe=true, async.replication=true, start.gms=false, local.caching=true, broadcast.remove.expired=false, key.transformer=com.sun.ejb.base.sfsb.util.SimpleKeyGenerator@657d1a8b}}
INFORMATION:   Portable JNDI names for EJB DefaultOfferService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultOfferService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultOfferService!richtercloud.project1.jar.controller.OfferService]
INFORMATION:   Portable JNDI names for EJB DefaultInitService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultInitService!richtercloud.project1.jar.controller.InitService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DefaultInitService]
INFORMATION:   Portable JNDI names for EJB DatabaseUserService: [java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DatabaseUserService!richtercloud.project1.jar.controller.UserService, java:global/project1-ear/project1-ejb-1.0-SNAPSHOT/DatabaseUserService!richtercloud.project1.ejb.DatabaseUserService]
INFORMATION:   Portable JNDI names for EJB Offer: [java:global/project1-ear/project1-web-1.0-SNAPSHOT/Offer!richtercloud.project1.web.rest.Offer, java:global/project1-ear/project1-web-1.0-SNAPSHOT/Offer]
INFORMATION:   Portable JNDI names for EJB User: [java:global/project1-ear/project1-web-1.0-SNAPSHOT/User!richtercloud.project1.web.rest.User, java:global/project1-ear/project1-web-1.0-SNAPSHOT/User]
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Information:   WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
WARNUNG:   The following warnings have been detected: WARNING: Parameter interceptedBean of type javax.enterprise.inject.spi.Bean<?> from private javax.enterprise.inject.spi.Bean<?> org.glassfish.soteria.cdi.RememberMeInterceptor.interceptedBean is not resolvable to a concrete type.

WARNUNG:   The following warnings have been detected: WARNING: Parameter interceptedBean of type javax.enterprise.inject.spi.Bean<?> from private javax.enterprise.inject.spi.Bean<?> org.glassfish.soteria.cdi.LoginToContinueInterceptor.interceptedBean is not resolvable to a concrete type.

INFORMATION:   Registering WebSocket filter for url pattern /*
INFORMATION:   Using OmniFaces version 2.6.7
INFORMATION:   Initializing Soteria 1.0 for context '/project1-web'
INFORMATION:   Mojarra 2.2.14 (-SNAPSHOT 20170628-1326 unable to get svn info) für Kontext '/project1-web' wird initialisiert.
INFORMATION:   Running on PrimeFaces 6.1
WARN:   WELD-000718: No EEModuleDescriptor defined for bean archive with ID: project1-web-1.0-SNAPSHOT_war.war. @Initialized and @Destroyed events for ApplicationScoped may be fired twice.
INFORMATION:   Loading application [project1-ear#project1-web-1.0-SNAPSHOT.war] at [/project1-web]
INFORMATION:   project1-ear was successfully deployed in 18.172 milliseconds.

where the exception in Moneta has been there forever (I think it's a bug or an unintuitive configuration error feedback) and didn't cause any trouble so far.

I'm using OmniFaces 2.6.7 and Payara 4.1.2.174.

来源:https://stackoverflow.com/questions/48074073/how-to-use-omnifaces-eager-annotation-with-primefaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!