logging - Why does slf4j w/ Wildfly ActiveMQ cause ObjectMessage.getMessage () to throw JMSException? -
i’m resurrecting old application worked wildfly 8 / hornetmq / log4j. remote java gui client swaped jms objectmessages.
so far works again when reconfigured wildfly 10 / activemq / slf4j, except 1 thing:
after mdb receives objectmessage (whose object arraylist) throws jmsexception error when mdb calls getobject() on message. jmsexcetion. e.getmessage() returns:
org.slf4j.log4j12.log4jloggeradapter [module "org.apache.activemq.artemis:main" local module loader @1c2c22f3 (finder: local module finder @18e8568 (roots: c:\programfilesgeo\wildfly\wildfly-10.1.0.final\modules, c:\programfilesgeo\wildfly\wildfly-10.1.0.final\modules\system\layers\base)
but if remove slf4j logging entityparent instances in arraylist works correctly … except can’t log entityparent subclass mdb extracts objectmessage.
here’s know far:
it's issue slf4j , guess serialization. because otherwise, slf4j works fine on server side. mean message above written wf log logger code in mdb:
import org.slf4j.logger; import org.slf4j.loggerfactory; final logger logger = logger.getlogger(gomsgbean.class.getname());
my mdb confirms message arrives as: activemqobjectmessage
before transmitting objectmessage tested instance of entityparent , arraylist serialization – ability with:
new objectoutputstream(new bytearrayoutputstream()).writeobject(each of above objects separately);
a web search brings 1 match issue – getobject() throwing jmsexception. marked not answered. , posted wrapped in discussion of proxy servers , class loaders unhelpful.
i found other discussions related problem log4j logger. suggested annotating logger @transient. claimed switching slf4j “solved” problem without making @transient. both switched slf4j , marked @transient. no loggers in subclasses of entityparent in arraylist used:
@transient final logger logger = loggerfactory.getlogger(loggedin.class);
the slf4j website discusses other problems, seem involve cases application tries retain log4j logging. not case anymore.
so hope can help, because i’m not sure else … real job deal data base once mdb can extract entities.
in case it’s of use, here’s activemq subsystem of standalone-full.xml
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0"> <server name="default"> <security enabled="false"/> <security-setting name="#"> <role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/> </security-setting> <address-setting name="#" dead-letter-address="jms.queue.dlq" expiry-address="jms.queue.expiryqueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/> <http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/> <http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput"> <param name="batch-delay" value="50"/> </http-connector> <in-vm-connector name="in-vm" server-id="0"/> <http-acceptor name="http-acceptor" http-listener="default"/> <http-acceptor name="http-acceptor-throughput" http-listener="default"> <param name="batch-delay" value="50"/> <param name="direct-deliver" value="false"/> </http-acceptor> <in-vm-acceptor name="in-vm" server-id="0"/> <jms-queue name="expiryqueue" entries="java:/jms/queue/expiryqueue"/> <jms-queue name="dlq" entries="java:/jms/queue/dlq"/> <jms-queue name="sendtoserverqueue" entries="java:jboss/exported/jms/queue/sendtoserverqueue java:/jms/queue/sendtoserverqueue"/> <jms-queue name="sendtoclientqueue2" entries="java:jboss/exported/jms/queue/sendtoclientqueue2"/> <connection-factory name="invmconnectionfactory" entries="java:/connectionfactory" connectors="in-vm"/> <connection-factory name="remoteconnectionfactory" entries="java:jboss/exported/jms/remoteconnectionfactory" connectors="http-connector"/> <pooled-connection-factory name="activemq-ra" entries="java:/jmsxa java:jboss/defaultjmsconnectionfactory" connectors="in-vm" transaction="xa"/> </server> </subsystem>
this added bounty: copy of current jpa entity (pojo) class. works w/ logging commented out. fails error above when slf4j logger added in. though slf4j loggers work fine mdb, , session beans, deploy ear package.
package org.america3.gotest.shared.jpa; //import org.slf4j.logger; //import org.slf4j.loggerfactory; import java.io.serializable; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.id; import javax.persistence.namedqueries; import javax.persistence.namedquery; import javax.persistence.table; import javax.persistence.transient; import org.america3.gotest.shared.interfaces.dataitemkeyvalues; import org.america3.gotest.shared.tools.utility; @namedqueries( {@namedquery(name="loggedin.findloggedinbyid", query = "select li " + "from loggedin li " + "where li.memberid = :memberidp"), @namedquery(name="findloggedinbyall", query = "delete loggedin li " + "where li.memberid = :memberidp " + "and li.memberpw = :memberpwp " + "and li.clienthash = clienthashp") }) @entity(name="loggedin") @table(name="loggedins") public class loggedin extends entityparent implements serializable, dataitemkeyvalues { /* see entityparent explanation of 9 fields * subclass persists memberid, memberpw, , clienthash */ //@transient //final logger logger = loggerfactory.getlogger(loggedin.class); //constructors public loggedin() { this.setmemberid(not_applicable); this.setmemberpw(not_applicable); this.setclienthash(not_applicable); this.setclientuserid(not_applicable); this.setclientuserpw(not_applicable); this.setownerid(not_applicable); this.setownerpw(not_applicable); this.setopponentid(not_applicable); this.setopponentpw(not_applicable); }; public loggedin(string hash, string id, string pw) { this(); if (id != null && pw !=null && hash != null) { this.setmemberid(id); this.setmemberpw(pw); this.setclienthash(hash); } else { //logger.error("log in attempted with: id \"" + id + "\" pw \"" + hash + "\""); string iamm = utility.getiamm(thread.currentthread().getstacktrace()); system.err.println(iamm + "log in attempted with: id \"" + id + "\" pw \"" + hash + "\""); } } public loggedin(entityparent loggedin) { this(); this.memberid = loggedin.getmemberid(); this.memberpw = loggedin.getmemberpw(); this.clienthash = loggedin.getclienthash(); } // persisted fields @id @column(name="pk") @generatedvalue(strategy=generationtype.identity) private integer pk; @column(name="mbr_id") private string memberid; @column(name="mbr_pw") private string memberpw; @column(name="hash") private string clienthash; // transient fields @transient private string clientuserid; @transient private string clientuserpw; @transient private string ownerid; @transient private string ownerpw; @transient private string opponentid; @transient private string opponentpw; private static final long serialversionuid = 1l; // set methods public integer getpk () {return this.pk;} public void setpk (integer pk) {this.pk = pk;} public string getmemberid () {return memberid;} public void setmemberid (string memberid) {this.memberid = (memberid == null? "" : memberid);} public string getmemberpw () {return this.memberpw;} public void setmemberpw (string memberpw) {this.memberpw = (memberpw == null? "" : memberpw);} public string getclienthash () {return clienthash;} public void setclienthash (string clienthash) {this.clienthash = (clienthash == null? "" : clienthash);} public boolean equals (loggedin otherloggedin) { if (otherloggedin == null) return false; if (this.pk == otherloggedin.getpk()) { return true; } else { return false; } } // other methods @transient public string getclientuserid () {return this.clientuserid;} public void setclientuserid (string clientuserid) {this.clientuserid = (clientuserid == null? "" : clientuserid);} @transient public string getclientuserpw () {return this.clientuserpw;} public void setclientuserpw (string clientuserpw) {this.clientuserpw = (clientuserpw == null? "" : clientuserpw);} @transient public string getownerid () {return this.ownerid;} public void setownerid (string ownerid) {this.ownerid = (ownerid == null? "" : ownerid);} @transient public string getownerpw () {return ownerpw;} public void setownerpw (string ownerpw) {this.ownerpw = (ownerpw == null? "" : ownerpw);} @transient public string getopponentid () {return opponentid;} public void setopponentid (string opponentid) {this.opponentid = (opponentid == null? "" : opponentid);} @transient public string getopponentpw () {return opponentpw;} public void setopponentpw (string opponentpw) {this.opponentpw = (opponentpw == null? "" : opponentpw);} public void writeentity () { //string iams = utility.getiams(thread.currentthread().getstacktrace()); //logger.info(iams + this.getclass().getsimplename() + " contains these values"); //logger.info(iams + " pk (pk) : " + this.pk); //logger.info(iams + " mbr_id (memberid) : " + this.memberid); //logger.info(iams + " mbr_pw (memberpw) : " + this.memberpw); //logger.info(iams + " hash (clienthash) : " + this.clienthash); //logger.info(iams + " trans (clientuserid): " + this.clientuserid); //logger.info(iams + " trans (clientuserpw): " + this.clientuserpw); } }
Comments
Post a Comment