WFLYEJB0054: Failed to marshal EJB parameters - java

The error on the title is because of no serialization, I know it because I had that error before and solved it thanks to this source: https://developer.jboss.org/thread/279558
But now I have a bigger issue with it, while debugging I found out I had a class called "MessageProvider" that wasn't implementing Serializable so I made it implement it but then the error persisted, checking more carefully I found out that this class has attributes that are of type ResourceBundle and guess what ResourceBundle doesn't implement Serializable so im stuck there because I can't edit it since it is from java "root" package.
This is some code of the class MessageProvider:
#Dependent
public class MessageProvider implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/** The message provider. */
public static MessageProvider messageProvider = new MessageProvider();
/** The etiquetas msg. */
private ResourceBundle etiquetasMsg;
/** The sistema msg. */
private ResourceBundle sistemaMsg;
This is the error I get when debugging:
Caused by: java.io.NotSerializableException: java.util.PropertyResourceBundle
09:51:12,621 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:256)
09:51:12,622 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:130)
09:51:12,622 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:391)
09:51:12,622 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:311)
09:51:12,622 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:254)
09:51:12,622 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:130)
09:51:12,623 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:391)
09:51:12,623 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:311)
09:51:12,623 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:254)
09:51:12,623 ERROR [stderr] (default task-1) at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:130)
09:51:12,623 ERROR [stderr] (default task-1) at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:378)
09:51:12,624 ERROR [stderr] (default task-1) ... 101 more
What I have tried with no success:
How to inject a non-serializable class (like java.util.ResourceBundle) with Weld
I tried using the "transient" on the attributes like so:
private transient ResourceBundle etiquetasMsg but it didn't work and after that tried
#PostConstruct
#PostActivate
public void getResourceBundle() {
bundle = ResourceBundle.getBundle("/messages", locale );
}
But it didn't work also :/, not sure where to look at, if you guys need more details to be able to help me just tell me.
Context:
Im doing all this for a REST service, testing it with POSTMAN, when a validation doesn't work I throw an exception that is from a class defined here in the company, lets call it CompanyExceptions, this class Extends from Exception, so this class CompanyExceptions uses MessageProvider class that is the one using ResourceBundle.
If I replace CompanyExceptions for just Exception I don't get the error from the title.
So for example if I throw an exception like this "throw new CompanyException("Failed to validate user password");" it gives me the error, but if I use throw new Exception("Failed to validate user password"); it works.

Related

JBoss 7.2 upgrade with JSF - No active contexts for scope type javax.enterprise.context.SessionScoped

I am trying to upgrade our Jboss EAP from version 6.4.21 to 7.2.
We are using JSF with myfaces implementation – version 2.3.7
The Jboss server starts successfully but as I try to browse to the application, I am getting the following exception:
2020-12-02 09:36:53,903 ERROR (default task-3) [undertow.request] UT005023: Exception handling request to /archcommon/login.faces: org.jboss.weld.contexts.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.SessionScoped
at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:647)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:89)
at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:164)
at org.jboss.weld.bean.ContextualInstance.getIfExists(ContextualInstance.java:63)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:87)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:131)
at org.apache.myfaces.cdi.view.ViewScopeBeanHolder$Proxy$_$$_WeldClientProxy.generateUniqueViewScopeId(Unknown Source)
at org.apache.myfaces.cdi.impl.CDIManagedBeanHandlerImpl.generateViewScopeId(CDIManagedBeanHandlerImpl.java:92)
at org.apache.myfaces.view.ViewScopeProxyMap.getWrapped(ViewScopeProxyMap.java:79)
at org.apache.myfaces.view.ViewScopeProxyMap.isEmpty(ViewScopeProxyMap.java:104)
at org.apache.myfaces.renderkit.ErrorPageWriter._writeVariables(ErrorPageWriter.java:792)
at org.apache.myfaces.renderkit.ErrorPageWriter._writeVariables(ErrorPageWriter.java:770)
at org.apache.myfaces.renderkit.ErrorPageWriter.debugHtml(ErrorPageWriter.java:357)
at org.apache.myfaces.renderkit.ErrorPageWriter.handle(ErrorPageWriter.java:471)
at org.apache.myfaces.context.MyFacesExceptionHandlerWrapperImpl.handle(MyFacesExceptionHandlerWrapperImpl.java:301)
at javax.faces.context.ExceptionHandlerWrapper.handle(ExceptionHandlerWrapper.java:61)
Didn’t find the root cause for the “No active contexts for scope type javax.enterprise.context.SessionScoped”
Any way I can inject this scope? Make it setup and available?
looking into class ViewScopeBeanHolder, I can see it is annotated with the required SessionScoped.
However, when Jboss weld tries to get it from the context map it holds, using scopeType = SessionScoped, it fails as it holds no active contexts of this type.
This is what it holds (from debug):
org.jboss.weld.contexts.bound.BoundSessionContextImpl#6ecf7900
org.jboss.weld.module.web.context.http.HttpSessionContextImpl#2cdba234
org.jboss.weld.module.web.context.http.HttpSessionDestructionContext#1ff70377
These are the related loggings, regarding the ViewScopeBeanHolder (when lowering the log level):
On jboss startup:
TRACE (Weld Thread Pool -- 6) [weld.Bean] WELD-000002: Exactly one constructor ([EnhancedAnnotatedConstructorImpl] public org.apache.myfaces.cdi.view.ViewScopeBeanHolder()) defined, using it as the bean constructor for [EnhancedAnnotatedTypeImpl] public #SessionScoped class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 6) [weld.Bean] WELD-000002: Exactly one constructor ([EnhancedAnnotatedConstructorImpl] public org.apache.myfaces.cdi.view.ViewScopeBeanHolder()) defined, using it as the bean constructor for [EnhancedAnnotatedTypeImpl] public #SessionScoped class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 6) [weld.Bean] WELD-000004: Exactly one post construct method ([EnhancedAnnotatedMethodImpl] #PostConstruct public org.apache.myfaces.cdi.view.ViewScopeBeanHolder.init()) for [EnhancedAnnotatedTypeImpl] public #SessionScoped class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 6) [weld.Bean] WELD-000004: Exactly one post construct method ([EnhancedAnnotatedMethodImpl] #PostConstruct public org.apache.myfaces.cdi.view.ViewScopeBeanHolder.init()) for [EnhancedAnnotatedTypeImpl] public #SessionScoped class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 6) [weld.Bean] WELD-000006: Exactly one pre destroy method ([EnhancedAnnotatedMethodImpl] #PreDestroy public org.apache.myfaces.cdi.view.ViewScopeBeanHolder.destroyBeansOnPreDestroy()) for [EnhancedAnnotatedTypeImpl] public #SessionScoped class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 6) [weld.Bean] WELD-000006: Exactly one pre destroy method ([EnhancedAnnotatedMethodImpl] #PreDestroy public org.apache.myfaces.cdi.view.ViewScopeBeanHolder.destroyBeansOnPreDestroy()) for [EnhancedAnnotatedTypeImpl] public #SessionScoped class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 6) [weld.Bean] WELD-001536: Found [] constructors annotated with #Inject for [EnhancedAnnotatedTypeImpl] public #SessionScoped class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 6) [weld.Bean] WELD-000002: Exactly one constructor ([EnhancedAnnotatedConstructorImpl] public org.apache.myfaces.cdi.view.ViewScopeBeanHolder()) defined, using it as the bean constructor for [EnhancedAnnotatedTypeImpl] public #SessionScoped class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 6) [weld.Bean] WELD-000002: Exactly one constructor ([EnhancedAnnotatedConstructorImpl] public org.apache.myfaces.cdi.view.ViewScopeBeanHolder()) defined, using it as the bean constructor for [EnhancedAnnotatedTypeImpl] public #SessionScoped class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 3) [weld.Bean] WELD-000012: Building bean metadata for class org.apache.myfaces.cdi.view.ViewScopeBeanHolder
TRACE (Weld Thread Pool -- 3) [weld.Bean] WELD-000010: Using qualifiers [#javax.enterprise.inject.Any(), #javax.enterprise.inject.Default()] for Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default]
TRACE (Weld Thread Pool -- 3) [weld.Bean] WELD-000014: Using name null for Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default]
TRACE (Weld Thread Pool -- 3) [weld.Bean] WELD-000016: Using scope interface javax.enterprise.context.SessionScoped for Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default]
DEBUG (MSC service thread 1-2) [weld.Bootstrap] WELD-000106: Bean: Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default]
0: WELD%ManagedBean%DeutscheBankEar.ear|deployment.DeutscheBankEar.ear.additionalClasses|org.apache.myfaces.cdi.view.ViewScopeBeanHolder||0
When browsing the UI:
TRACE (default task-2) [weld.Bean] WELD-001538: Created context instance for bean Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default] identified as WELD%ManagedBean%DeutscheBankEar.ear|deployment.DeutscheBankEar.ear.additionalClasses|org.apache.myfaces.cdi.view.ViewScopeBeanHolder||0
TRACE (default task-2) [weld.Bean] WELD-001538: Created context instance for bean Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default] identified as WELD%ManagedBean%DeutscheBankEar.ear|deployment.DeutscheBankEar.ear.additionalClasses|org.apache.myfaces.cdi.view.ViewScopeBeanHolder||0
TRACE (default task-2) [weld.Bean] WELD-001542: Retrieving/generating proxy class org.apache.myfaces.cdi.view.ViewScopeBeanHolder$Proxy$_$$_WeldClientProxy
TRACE (default task-2) [weld.Bean] WELD-001541: Adding method to proxy: public void org.apache.myfaces.cdi.view.ViewScopeBeanHolder.init()
TRACE (default task-2) [weld.Bean] WELD-001541: Adding method to proxy: public org.apache.myfaces.cdi.view.ViewScopeContextualStorage org.apache.myfaces.cdi.view.ViewScopeBeanHolder.getContextualStorage(javax.enterprise.inject.spi.BeanManager,java.lang.String)
TRACE (default task-2) [weld.Bean] WELD-001541: Adding method to proxy: public java.lang.String org.apache.myfaces.cdi.view.ViewScopeBeanHolder.generateUniqueViewScopeId()
TRACE (default task-2) [weld.Bean] WELD-001541: Adding method to proxy: public void org.apache.myfaces.cdi.view.ViewScopeBeanHolder.destroyBeansOnPreDestroy()
TRACE (default task-2) [weld.Bean] WELD-001541: Adding method to proxy: public java.util.Map org.apache.myfaces.cdi.view.ViewScopeBeanHolder.forceNewStorage()
TRACE (default task-2) [weld.Bean] WELD-001541: Adding method to proxy: public java.util.Map org.apache.myfaces.cdi.view.ViewScopeBeanHolder.getStorageMap()
TRACE (default task-2) [weld.Bean] WELD-001541: Adding method to proxy: public void org.apache.myfaces.cdi.view.ViewScopeBeanHolder.destroyBeans()
TRACE (default task-2) [weld.Bean] WELD-001541: Adding method to proxy: public void org.apache.myfaces.cdi.view.ViewScopeBeanHolder.destroyBeans(java.lang.String)
TRACE (default task-2) [weld.Bean] WELD-001543: Created Proxy class of type class org.apache.myfaces.cdi.view.ViewScopeBeanHolder$Proxy$_$$_WeldClientProxy supporting interfaces [interface java.io.Serializable, interface org.jboss.weld.proxy.WeldConstruct, interface org.jboss.weld.interceptor.util.proxy.TargetInstanceProxy, interface org.jboss.weld.proxy.WeldClientProxy, interface org.jboss.weld.interceptor.proxy.LifecycleMixin, interface org.jboss.weld.bean.proxy.ProxyObject]
TRACE (default task-2) [weld.Bean] WELD-001506: Created new client proxy of type class org.apache.myfaces.cdi.view.ViewScopeBeanHolder$Proxy$_$$_WeldClientProxy for bean Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default] with ID WELD%ManagedBean%DeutscheBankEar.ear|deployment.DeutscheBankEar.ear.additionalClasses|org.apache.myfaces.cdi.view.ViewScopeBeanHolder||0
TRACE (default task-2) [weld.Bean] WELD-001506: Created new client proxy of type class org.apache.myfaces.cdi.view.ViewScopeBeanHolder$Proxy$_$$_WeldClientProxy for bean Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default] with ID WELD%ManagedBean%DeutscheBankEar.ear|deployment.DeutscheBankEar.ear.additionalClasses|org.apache.myfaces.cdi.view.ViewScopeBeanHolder||0
TRACE (default task-2) [weld.Bean] WELD-001506: Created new client proxy of type class org.apache.myfaces.cdi.view.ViewScopeBeanHolder$Proxy$_$$_WeldClientProxy for bean Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default] with ID WELD%ManagedBean%DeutscheBankEar.ear|deployment.DeutscheBankEar.ear.additionalClasses|org.apache.myfaces.cdi.view.ViewScopeBeanHolder||0
TRACE (default task-2) [weld.Bean] WELD-001507: Located client proxy of type class org.apache.myfaces.cdi.view.ViewScopeBeanHolder$Proxy$_$$_WeldClientProxy for bean Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default]
TRACE (default task-2) [weld.Bean] WELD-001507: Located client proxy of type class org.apache.myfaces.cdi.view.ViewScopeBeanHolder$Proxy$_$$_WeldClientProxy for bean Managed Bean [class org.apache.myfaces.cdi.view.ViewScopeBeanHolder] with qualifiers [#Any #Default]

Injecting JOOQ Context using CDI and JNDI

I try to use jooq on an PostgreSQL Database. The Web-App is built on the JSF Framework using CDI for dependency injection. The server is WildFly 11.
I use the jooq codegen to generate pojos and daos.
Following the instructions on http://awolski.com/integrating-jooq-easy/
I should be able to inject the DSLContext into any class. When I try to inject it into a controller bean which looks like
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
#Named
#RequestScoped
public class FooView implements Serializable {
private #Inject DSLContext jooq;
...
it simply doesn't work. The framework just doesn't instantiate the Foo.
What am I missing?
The server.log reads as follows:
WARN [org.jboss.modules] (Weld Thread Pool -- 4) Failed to define class model.tables.FooDao in Module "deployment.project.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link model/tables/Foo (Module "deployment.project.war" from Service Module Loader): org/jooq/impl/TableImpl
...
INFO [org.jboss.as.server] (management-handler-thread - 2) WFLYSRV0010: Deployed "project.war" (runtime-name : "project.war")
...
WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-22) /project/Foo.xhtml #9,91 value="#{FooView.attr}": Target Unreachable, identifier 'FooView' resolved to null: javax.el.PropertyNotFoundException: /project/Foo.xhtml #9,91 value="#{FooView.attr}": Target Unreachable, identifier 'FooView' resolved to null
...
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'FooView' resolved to null
...
ERROR [io.undertow.request] (default task-22) UT005023: Exception handling request to /project/project/Foo.xhtml: javax.servlet.ServletException: /project/Foo.xhtml #9,91 value="#{FooView.attr}": Target Unreachable, identifier 'FooView' resolved to null
...
Caused by: javax.el.PropertyNotFoundException: /project/Foo.xhtml #9,91 value="#{FooView.attr}": Target Unreachable, identifier 'FooView' resolved to null
...
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'FooView' resolved to null
As soon as I remove the injected attribute from FooView, no errors show up, despite that warning.

HibernateSearch ClassBridge - sorting and faceting not working with HS 5.5.1

I posted this a while ago in the hibernate search forum and got no response, so trying again in stackoverflow...
Since migrating from HS 4.5.1 to HS 5.5.1 we have problems with sorting and faceting.
All our indexing is done using a class bridge which calls a CDI-Bean to do the actual indexing. In our system the configuration which fields are indexed is dynamic and can change at runtime, so we cannot use HS-annotations.
Sorting: we would like to take advantage of lucene's new sorting features using docvalues. We tried to add interface MetadataProvidingFieldBridge to the class bridge to provide the information which fields are sort fields, but at the time when the class bridge is initalized (when jboss is booting) the CDI-bean is not yet available.
Question 1: Is there a way to re-initialize the HS-SearchIntegrator at a later time, when the CDI-bean is available or when our index configuration has changed?
For the time being HS falls back to using the UninvertingReader for dealing with the sort fields without docvalues.
Question 2: Is this going to be supported in the future? How "bad" is it performancewise to use UninvertingReader?
With faceting we face a similar problem, we cannot use #Facet-annotation because the configuration is dynamic. For the time being we use lucene's faceting API directly.
Question 3: Is there a plan in HS to add faceting-information via a class bridge in the near future, similar to MetadataProvidingFieldBridge? Is the class bridge going to be supported by Hibernate Search in the future?
Code of the ClassBridge:
public class FtiClassBridgeCE implements FieldBridge, MetadataProvidingFieldBridge
{
#Override
public void set(String fieldName, Object value, Document document, LuceneOptions options)
{
if( !(value instanceof ComplexEntity))
return; // ignore
ComplexEntity object = (ComplexEntity)value;
// FtiService does the actual indexing by adding fields to given document
Configuration.service( FtiService.class).setIndexData( object, new FtiDocumentHS( document, options));
}
/*
* This method is called in startup process of JBoss (Wildfly10) when initializing the persistence context. At that
* time the CDI-Beans are not yet available resulting in a NullPointerException.
*
* #see org.hibernate.search.bridge.MetadataProvidingFieldBridge#configureFieldMetadata(java.lang.String,
* org.hibernate.search.bridge.spi.FieldMetadataBuilder)
*/
public void configureFieldMetadata(String name, FieldMetadataBuilder builder)
{
try
{
// FtiService is a CDI bean which is obtained from BeanManager via our Configuration-class
// FtiSearchConfig stores information which fields should be added to lucene index and how they map to
// ComplexEntity's data
for( FtiSearchConfig config : Configuration.service( FtiService.class).getAllConfigurations())
{
for( FtiSearchField ftiSearchField : config.getSortFields())
{
builder.field( ftiSearchField.getNameForSort( null), hsSortType( ftiSearchField.getFieldDataType())).sortable( true);
}
}
}
catch( Exception ex)
{
ex.printStackTrace();
// catch the NPE thrown at JBoss boot time
}
}
private FieldType hsSortType(FtiFieldDataType fieldDataType)
{
switch( fieldDataType)
{
case DATE:
return FieldType.LONG;
case NUMERIC:
return FieldType.INTEGER;
case PRICE:
return FieldType.DOUBLE;
default:
return FieldType.STRING;
}
}
In the #PostConstruct-Method of the CDI-Bean I tried to reinitialized the HS SearchIntegrator like this but it did not call again the method FtiClassBridgeCE.configureFieldMetadata(String name, FieldMetadataBuilder builder).
#PostConstruct
protected void initialize() throws ConfigurationException
{
initSearchConfig();
initializeHSSearch();
}
private void initializeHSSearch()
{
FullTextEntityManager ftEM = ftidx().getFullTextEM();
SearchIntegrator si = ftEM.getSearchFactory().unwrap( SearchIntegrator.class);
SearchIntegratorBuilder sb = new SearchIntegratorBuilder().currentSearchIntegrator( si);
sb.buildSearchIntegrator();
}
Which is the right way to do this or is there no way to reinitialize the SearchIntegrator?
Stacktrace of the Exception that is thrown at JBoss boot time when initializing HS SearchIntegrator:
13:33:12,656 INFO [jpa] (ServerService Thread) WFLYJPA0010: Starting Persistence Unit (phase 2 of 2) Service 'mc.ear/web.war#mc'
13:33:16,219 INFO [Dialect] (ServerService Thread) HHH000400: Using dialect: mc.core.system.util.db.SQLServerDialect
13:33:16,996 INFO [EnversServiceImpl] (ServerService Thread) Envers integration enabled? : true
13:33:23,864 INFO [UpdateTimestampsCache] (ServerService Thread) HHH000250: Starting update timestamps cache at region: mc.ear/web.war#mc.org.hibernate.cache.spi.UpdateTimestampsCache
13:33:25,675 INFO [StandardQueryCache] (ServerService Thread) HHH000248: Starting query cache at region: mc.ear/web.war#mc.org.hibernate.cache.internal.StandardQueryCache
13:33:27,529 INFO [Version] (ServerService Thread) HSEARCH000034: Hibernate Search 5.5.1.Final
babysitten13:34:45,462 ERROR [stderr] (ServerService Thread) java.lang.NullPointerException
13:34:45,463 ERROR [stderr] (ServerService Thread) at org.jboss.weld.bean.builtin.BeanManagerProxy.<init>(BeanManagerProxy.java:74)
13:34:45,463 ERROR [stderr] (ServerService Thread) at org.jboss.as.weld.WeldProvider$CdiImpl.getBeanManager(WeldProvider.java:95)
13:34:45,463 ERROR [stderr] (ServerService Thread) at org.jboss.as.weld.WeldProvider$CdiImpl.getBeanManager(WeldProvider.java:73)
13:34:45,463 ERROR [stderr] (ServerService Thread) at mc.core.service.configuration.WorkerFactory.lookupBM(WorkerFactory.java:42)
13:34:45,464 ERROR [stderr] (ServerService Thread) at mc.core.service.configuration.WorkerFactory.createService(WorkerFactory.java:28)
13:34:45,464 ERROR [stderr] (ServerService Thread) at mc.core.service.configuration.Configuration.service(Configuration.java:27)
13:34:45,464 ERROR [stderr] (ServerService Thread) at mc.core.service.ftindex.hs.FtiClassBridgeCE.configureFieldMetadata(FtiClassBridgeCE.java:63)
13:34:45,464 ERROR [stderr] (ServerService Thread) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getSortableFieldNames(AnnotationMetadataProvider.java:1751)
13:34:45,464 ERROR [stderr] (ServerService Thread) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.bindClassBridgeAnnotation(AnnotationMetadataProvider.java:621)
13:34:45,464 ERROR [stderr] (ServerService Thread) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.bindClassBridgeAnnotation(AnnotationMetadataProvider.java:593)
13:34:45,465 ERROR [stderr] (ServerService Thread) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClassLevelAnnotations(AnnotationMetadataProvider.java:546)
13:34:45,465 ERROR [stderr] (ServerService Thread) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass(AnnotationMetadataProvider.java:430)
13:34:45,465 ERROR [stderr] (ServerService Thread) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor(AnnotationMetadataProvider.java:130)
13:34:45,465 ERROR [stderr] (ServerService Thread) at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchIntegratorBuilder.java:373)
13:34:45,466 ERROR [stderr] (ServerService Thread) at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:199)
13:34:45,466 ERROR [stderr] (ServerService Thread) at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator(SearchIntegratorBuilder.java:117)
13:34:45,467 ERROR [stderr] (ServerService Thread) at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:75)
13:34:45,473 ERROR [stderr] (ServerService Thread) at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)
13:34:45,473 ERROR [stderr] (ServerService Thread) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:530)
13:34:45,473 ERROR [stderr] (ServerService Thread) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.__build(SessionFactoryBuilderImpl.java:444)
13:34:45,474 ERROR [stderr] (ServerService Thread) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java)
13:34:45,474 ERROR [stderr] (ServerService Thread) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
13:34:45,474 ERROR [stderr] (ServerService Thread) at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.__build(TwoPhaseBootstrapImpl.java:44)
13:34:45,474 ERROR [stderr] (ServerService Thread) at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java)
13:34:45,474 ERROR [stderr] (ServerService Thread) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154)

log4j configuration with jboss7 issue

java code
public static synchronized void init(String log4jXMLPath) //throws ServletException
{
try
{
if (!initialized) // set the global RepositorySelector
{
defaultRepository = LogManager.getLoggerRepository();
RepositorySelector theSelector = new AppRepositorySelector();
**LogManager.setRepositorySelector(theSelector, guard);**
initialized = true;
}
Hierarchy hierarchy = new Hierarchy(new RootLogger(Level.DEBUG));
//loadLog4JConfig(servletContext, hierarchy);
loadLog4JConfig(hierarchy, log4jXMLPath);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
repositories.put(loader, hierarchy);
}
catch (Exception e)
{
e.printStackTrace();
}
}
LogManager.setRepositorySelector(theSelector, guard); this line in java code throwing an error
stacktrace
18:17:11,189 ERROR [stderr] (MSC service thread 1-2) java.lang.IllegalArgumentException: Attempted to reset the LoggerFactory without possessing the guard.
18:17:11,190 ERROR [stderr] (MSC service thread 1-2) at org.apache.log4j.LogManager.setRepositorySelector(LogManager.java:164)
18:17:11,191 ERROR [stderr] (MSC service thread 1-2) at com.mportal.logger.api.AppRepositorySelector.init(AppRepositorySelector.java:73)
18:17:11,192 ERROR [stderr] (MSC service thread 1-2) at com.mportal.logger.api.MPLoggerImpl.loadLogInstance(MPLoggerImpl.java:64)
18:17:11,192 ERROR [stderr] (MSC service thread 1-2) at com.mportal.logger.api.MPLoggerImpl.<init>(MPLoggerImpl.java:38)
18:17:11,192 ERROR [stderr] (MSC service thread 1-2) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
18:17:11,193 ERROR [stderr] (MSC service thread 1-2) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
18:17:11,194 ERROR [stderr] (MSC service thread 1-2) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
18:17:11,194 ERROR [stderr] (MSC service thread 1-2) at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
How to solve this one? Please give solutions.
LogManager.setRepositorySelector(theSelector, guard);
You can only use one guard, using different guard objects will result in the observerd error:
java.lang.IllegalArgumentException: Attempted to reset the LoggerFactory without possessing the guard.
It should be possible to pass null as a parameter to the function. Or simply hold a reference to the initial set guard.
The documentation states:
Initally the guard is null. If the guard is null, then invoking this method sets the logger factory and the guard. Following invocations will throw a IllegalArgumentException, unless the previously set guard is passed as the second parameter.

java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute

I have inherited some code and am getting an error when I try to run it. The error is below:
10:08:32,093 ERROR [MyServlet]:260 - Servlet.service() for servlet MyServlet threw exception
java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1270)
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1248)
at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:130)
at uk.co.my.servlet.MyServlet.doPost(MyServlet.java:121)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.my.ddi.security.SecurityContextServletFilter.doFilter(SecurityContextServletFilter.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:835)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)
at java.lang.Thread.run(Unknown Source)
I imagine that the main problem is where it is hitting my code at uk.co.my.servlet.MyServlet.doPost(MyServlet.java:172). Line 121 of MyServlet is
session.setAttribute("LISTENER", myListener);
This myListener object is from the following class:
public class myListener {
static Log log = LogFactory.getLog(TerminationListener.class.getName());
private boolean shouldCancel = false;
How would I go about getting rid of this error? Would I need to use the transient keyword?
If you want an instance of myListener to be placed in a session, you need to make it serializable. That might involve making some fields transient, but then those fields won't be saved in the session. You'll also need to make the class implement Serializable.
I suggest you look at the documentation for Serializable, which goes into a fair amount of detail about serialization.

Categories