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.