Issue Details (XML | Word | Printable)

Key: AMQ-765
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Rob Davies
Reporter: Chris Conrad
Votes: 2
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
ActiveMQ

ActiveMQ RA serialization issue on Glassfish

Created: 20/Jun/06 05:09 PM   Updated: 28/Apr/08 09:56 AM
Return to search
Component/s: Connector
Affects Version/s: 4.0, 4.0.1
Fix Version/s: 5.1.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File finest-log.txt 2007-11-07 07:29 AM michal kozakiewicz 7 kB
Text File log.txt 2007-11-06 03:35 PM michal kozakiewicz 4 kB
Text File Licensed for inclusion in ASF works RA.patch 2008-01-14 07:50 AM Kai Hudalla 54 kB
Environment: Glassfish
Issue Links:
Related
 


 Description  « Hide
I've been trying to work through an issue with a NullPointerException run using the JCA 1.5 resource adapter on Glassfish. In the course of debugging, Siva from the Glassfish team provided this information:

"Thanks for trying out GlassFish. Since I have only the trace snippet above, I tried to debug this problem by going through ActiveMQ RA's source available at https://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/

This is what I understand happens. Please correct me if there are errors. When ActiveMQConnectionFactory https://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionFactory.java is created at the createConnectionFactory method of https://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java, the ConnectionManager is initialized to a transient variable "manager". Since ConnectionFactory instances can be serialized/deserialized while publishing to JNDI (as is the case in Project GlassFish), the connectionManager reference is lost and hence the NPE. The fix ideally should be in the ActiveMQRA's code. You could copy me [sivakumart AT sun DOT com] while you are discussing this with ActiveMQ, if you wish. If you still have any issues, please provide a copy of your domain.xml [connector connection pool, resource configuratin information] and the entire trace in server.log."



 All   Comments   Work Log   Change History   Subversion Commits   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Chris Conrad added a comment - 20/Jun/06 05:10 PM
The mailing list discussion related to this issue can be found at: http://www.nabble.com/NullPointerException-with-RA-on-Glassfish-t1814940.html#a4959128

Michael Hutt added a comment - 06/Oct/06 11:32 AM
The same thing happens on oracle (oc4j) 10.1.3, except that I am using ActiveMQTopicConnectionFactory, instead of the managed connection factory.
Same error, same line.

Details:
-I deploy the resource adapter exactly as it comes packaged in v4.0.1
-I'm using an external broker, running on the same machine.
-I create one topic connection factory
-I create one topic

In the code, the context lookups for the topics go through just fine (the objects are found), but upon calling factory.createTopicConnection(), I get the NPE. Setting UseInboundSession to true lets this go through just fine, but I'm not writing a message driven bean, so this doesn't help me out very much.


James Strachan added a comment - 12/Jun/07 07:51 AM
Does anyone know if this is still an issue with 4.1.1 or 5.0.0?

Rob Davies made changes - 19/Aug/07 10:37 PM
Field Original Value New Value
Fix Version/s 5.2.0 [ 11841 ]
michal kozakiewicz added a comment - 06/Nov/07 03:31 PM
It is still an issue in 4.1.1.

michal kozakiewicz added a comment - 06/Nov/07 03:35 PM
The exception log I get on ActiveMQ 4.1.1 with
Sun Java System Application Server 9.1 (build b58g-fcs)

michal kozakiewicz made changes - 06/Nov/07 03:35 PM
Attachment log.txt [ 15876 ]
michal kozakiewicz added a comment - 07/Nov/07 07:29 AM
After further investigation :

In version 4.1.1 the manager is not transient and not null, but I think I am getting the same error with the transient managed connection factory.

Everything starts here:

@Resource(mappedName = "jms/UserUpdateConnectionFactory")
private ConnectionFactory jmsConnectionFactory;

@PostConstruct
public void jmsConfigure()
{

{....}
jmsConnection = jmsConnectionFactory.createConnection(); //at this point the jmsConnectionFactory is of class ActiveMQConnectionFactory but it's managed connection factory is null
{....}

}

Iam not sure if this because I didnt configure something or because of the fact that managed connection factory is transient.

after calling ActiveMQConnectionFactory.createConnection the null mcf is passed to ConnectionManagerImpl.allocateConnection.
(http://fisheye5.cenqua.com/browse/glassfish/appserv-core/src/java/com/sun/enterprise/connectors/ConnectionManagerImpl.java?r=1.6#l231)

in this method there is a check:

if(_logger.isLoggable(Level.INFO)){
if (! freshMCF.equals(mcf)) { _logger.info("conmgr.mcf_not_equal"); }
}

the fresh mcf retrieved from pool meta data PoolMetaData pmd = registry.getPoolMetaData( poolName ); ManagedConnectionFactory freshMCF = pmd.getMCF(); is a proper activemq mcf but the value is used only for logging purposes:

this conmgr.mcf_not_equal translates to The mcf being used to allocate the connection and the MCF in the pool are not equal. in the attached log-finest.txt log file.

Finally when ConnectorAllocator.createResource method is called the mcf is null :
http://fisheye5.cenqua.com/browse/glassfish/appserv-core/src/java/com/sun/enterprise/resource/ConnectorAllocator.java?r=1.6#l136


michal kozakiewicz made changes - 07/Nov/07 07:29 AM
Attachment finest-log.txt [ 15878 ]
Kai Hudalla added a comment - 24/Dec/07 08:33 AM
I have tried to work around the problem described by Michal by simply declaring the factory property of ActiveMQConnectionFactory to not be transient. However, after running my test driver for accessing a ConnectionFactory managed by the ActiveMQ RA, I ran into the following problem:

Caused by: java.lang.RuntimeException: Cant copy Serializable object:
at com.sun.enterprise.naming.NamingUtils.makeCopyOfObject(NamingUtils.java:82)
at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:842)
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
... 66 more
Caused by: java.io.NotSerializableException: com.sun.enterprise.connectors.BootstrapContextImpl
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at com.sun.enterprise.naming.NamingUtils.makeCopyOfObject(NamingUtils.java:64)
... 68 more

After having spent some time looking at the RA source code of version 5.0.0 my feeling is that the ActiveMQManagedConnectionFactory violates the javax.resource.spi.ManagedConnectionFactory contract because it is not Serializable.

ActiveMQManagedConnectionFactory has a property of type org.apache.activemq.ra.MessageResourceAdapter which extends the javax.resource.spi.ResourceAdapter interface which itself does NOT extend Serializable, i.e. implementors are not required to be serializable. The ActiveMQResourceAdapter implementing the MessageResourceAdapter interface, however, claims to be serializable but does have a property of type javax.resource.spi.BootstrapContext. But BootstrapContext implementations are not required to be Serializable. In case of glassfish the passed in com.sun.enterprise.connectors.BootstrapContextImpl class is NOT serializable.

Therefore, declaring the factory property to NOT be transient is not working because ActiveMQManagedConnectionFactory is not serializable as mandated by the JCA spec.

Any thoughts?

Kai


Kai Hudalla added a comment - 14/Jan/08 07:49 AM
Hi,

I have spent some time fixing the Resource Adapter's serialization issue in order to make it work in glassfish v2. Therefore I made some changes to ActiveMQConnectionFactory, ActiveMQManagedConnectionFactory and ActiveMQResourceAdapter. I have also created additional test cases and updated the existing ones to reflect my changes. I have successfully tested it in my local environment using glassfish v2 and v2 UR1 on JDK 1.5.0_14. I have also attached a patch for the 5.1 SNAPSHOT code in SVN. Could someone test it against Geronimo in order to see if it's still working there?

Regards,
Kai


Kai Hudalla added a comment - 14/Jan/08 07:50 AM
Patch to fix serialization issue on glassfish.

Kai Hudalla made changes - 14/Jan/08 07:50 AM
Attachment RA.patch [ 16039 ]
Kai Hudalla made changes - 28/Jan/08 08:44 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Kai Hudalla added a comment - 12/Feb/08 05:09 AM
Already fixed in 5.1 instead of 5.2

Kai Hudalla made changes - 12/Feb/08 05:09 AM
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Kai Hudalla added a comment - 12/Feb/08 05:10 AM
Resource Adapter has been fixed to support serialization of RA components as performed by glasfish.

Kai Hudalla made changes - 12/Feb/08 05:10 AM
Resolution Fixed [ 1 ]
Fix Version/s 5.2.0 [ 11841 ]
Fix Version/s 5.1.0 [ 11802 ]
Status Reopened [ 4 ] Resolved [ 5 ]
George Daswani added a comment - 01/Apr/08 12:59 AM
Is this problem really fixed on the latest 5.1 snapshots? I tried the 03/29/08 5.1-SNAPSHOT but I'm still running into the following error

---------------------- CUT -------------------
javax.jms.JMSException: Error in allocating a connection. Cause: null
at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:98)
at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:64)
---------------------- CUT -------------------

when trying to use outbound connections


Rob Davies made changes - 16/Apr/08 08:43 AM
Assignee Rob Davies [ rajdavies ]
Rob Davies added a comment - 16/Apr/08 08:46 AM
Applied patch to trunk - in SVN Committed revision 648727

Rob Davies made changes - 16/Apr/08 08:46 AM
Fix Version/s 5.1.0 [ 11802 ]
Fix Version/s 5.2.0 [ 11841 ]
Repository Revision Date User Message
AMQ #648727 Wed Apr 16 08:47:24 PDT 2008 rajdavies Apply patch for https://issues.apache.org/activemq/browse/AMQ-765
Files Changed
ADD /activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQConnectionFactoryTest.java
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/MessageResourceAdapter.java
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnectionFactory.java
MODIFY /activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ManagedConnectionFactoryTest.java
MODIFY /activemq/trunk/activemq-ra/src/test/java/org/apache/activemq/ra/ManagedConnectionTest.java
MODIFY /activemq/trunk/activemq-ra/pom.xml
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java
ADD /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionSupport.java
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java
MODIFY /activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionFactory.java

Hiram Chirino made changes - 22/Apr/08 10:21 AM
Fix Version/s 5.2.0 [ 11841 ]
Fix Version/s 5.1.0 [ 11802 ]
Hiram Chirino made changes - 28/Apr/08 09:56 AM
Link This issue is related to AMQ-1696 [ AMQ-1696 ]
Create crucible review for this changeset in