Issue Details (XML | Word | Printable)

Key: BAM-2520
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Adrian Hempel [Atlassian]
Reporter: Adrian Hempel [Atlassian]
Votes: 0
Watchers: 0
Operations

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

Remote agents on JDK 1.5 may throw a SecurityException when running against a Bamboo server on JDK 1.6

Created: 23/Apr/08 06:26 PM   Updated: 05/May/08 12:40 AM
Component/s: Agents (Remote)
Affects Version/s: 2.0
Fix Version/s: 2.0.2

Time Tracking:
Not Specified

File Attachments: 1. Java Archive File bamboo-agent-BAM-2520.jar (692 kB)
2. Text File message.txt (22 kB)

Environment: Bamboo Remote Agent on JDK 1.5 with Bamboo Server on JDK 1.6

Participants: Adrian Hempel [Atlassian], Ajay Sridhar [Atlassian] and Koen Vereeken
Since last comment: 23 weeks, 6 days ago
Number of comments: 10
Internal Work Bucket: Investigating (dev)
Labels: classloading


 Description  « Hide
In BSP-661, there are cases of Remote Agents on JDK 1.5 throwing the following exception and exiting:
java.lang.SecurityException: Prohibited package name: java.util.concurrent.locks
	at java.lang.ClassLoader.preDefineClass(ClassLoader.java:534)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:669)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:520)
	at com.atlassian.bamboo.agent.bootstrap.AgentClassLoader.findClass(AgentClassLoader.java:113)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
	at com.atlassian.bamboo.agent.bootstrap.AgentClassLoader.loadClass(AgentClassLoader.java:233)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at org.apache.activemq.util.ClassLoading.load(ClassLoading.java:112)
	at org.apache.activemq.util.ClassLoading.loadClass(ClassLoading.java:51)
	at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.load(ClassLoadingAwareObjectInputStream.java:55)
	at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.resolveClass(ClassLoadingAwareObjectInputStream.java:37)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1552)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1552)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1552)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
	at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1634)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
	at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:479)
	at java.util.concurrent.ConcurrentHashMap.readObject(ConcurrentHashMap.java:1399)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:946)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1809)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
	at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:166)
	at org.springframework.jms.support.converter.SimpleMessageConverter.extractSerializableFromMessage(SimpleMessageConverter.java:222)
	at org.springframework.jms.support.converter.SimpleMessageConverter.fromMessage(SimpleMessageConverter.java:109)
	at org.springframework.jms.core.JmsTemplate.doConvertFromMessage(JmsTemplate.java:763)
	at org.springframework.jms.core.JmsTemplate.receiveSelectedAndConvert(JmsTemplate.java:742)
	at com.atlassian.bamboo.v2.build.queue.AgentQueueAccessorImpl.takeBuildContext(AgentQueueAccessorImpl.java:29)
	at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:65)
	at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:101)
	at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$1.run(NamedThreadFactory.java:32)
	at edu.emory.mathcs.backport.java.util.concurrent.helpers.ThreadHelpers$1.run(ThreadHelpers.java:34)
	at java.lang.Thread.run(Thread.java:613)

I suspect that the server is running on JDK 1.6 (I am seeking confirmation from the customer), and that a serialised BuildContext object graph containing a reference to a member of the java.util.concurrent.locks package that appears in JDK 1.6 but not JDK 1.5 is being sent to the remote agent.

I will use the debug logging message converter to take a look at the object graph.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Koen Vereeken added a comment - 24/Apr/08 03:40 PM
I have the same issue .. I've read something about java.security where you can grant classes to have access to other classes.. no luck..

Adrian Hempel [Atlassian] added a comment - 27/Apr/08 06:46 PM
Hi Koen.

It's not an issue related to security configuration.

The current workaround is to have the server and all remote agents running on the same JDK version.

We are currently investigating a permanent solution.

Regards,
Adrian


Adrian Hempel [Atlassian] added a comment - 28/Apr/08 01:05 AM
I have been able to reproduce this.

Koen Vereeken added a comment - 28/Apr/08 02:40 AM
Bamboo remote agents is typically a case we need for managing builds on different environments, also with different versions of Java, so it would be great to have this issue resolved.

Thanks!

Regards, Koen


Adrian Hempel [Atlassian] added a comment - 28/Apr/08 04:54 AM
Hi Koen,

You are not limited to building projects using the JDK that was used to start the remote agent. Even if you start the remote agent with JDK 1.5, it will build plans using the JDK specified in the plan's definition.

If you need further information on this, please raise a support request at http://support.atlassian.com and our support team will be happy to help.

Regards,
Adrian


Ajay Sridhar [Atlassian] added a comment - 28/Apr/08 05:52 PM - edited
Increasing the priority level, this issue was also reported in https://support.atlassian.com/browse/BSP-756

Adrian Hempel [Atlassian] added a comment - 28/Apr/08 06:51 PM
message.txt shows the object graph of the message that triggers the exception.

Adrian Hempel [Atlassian] added a comment - 28/Apr/08 08:43 PM
It looks like the problem is that java.util.concurrent.locks.AbstractOwnableSynchronizer has been introduced in JDK 1.6, and is now part of the inheritance hierarchy of java.util.concurrent.locks.ReentrantLock$NonfairSync, which appears in the object graph of com.atlassian.bamboo.v2.build.CurrentBuildResultImpl:
            com.atlassian.bamboo.v2.build.CurrentBuildResultImpl
                customBuildData = java.util.concurrent.ConcurrentHashMap@1edb0
                    java.util.concurrent.ConcurrentHashMap ** UNRECOGNISED writeObject IMPLEMENTATION **
                        segments = [Ljava.util.concurrent.ConcurrentHashMap$Segment;@10e3c8c
                            [0] = java.util.concurrent.ConcurrentHashMap$Segment@1a90deb
                                java.util.concurrent.ConcurrentHashMap$Segment
                                java.util.concurrent.locks.ReentrantLock
                                    sync = java.util.concurrent.locks.ReentrantLock$NonfairSync@7a1904
                                        java.util.concurrent.locks.ReentrantLock$NonfairSync
                                        java.util.concurrent.locks.ReentrantLock$Sync
                                        java.util.concurrent.locks.AbstractQueuedSynchronizer
                                        java.util.concurrent.locks.AbstractOwnableSynchronizer
                                        java.lang.Object
                                java.lang.Object

Looks like a serialisation versioning bug in JDK 1.6 that we'll have to work around.


Adrian Hempel [Atlassian] added a comment - 28/Apr/08 11:45 PM
I was able to successfully serialise an AbstractOwnableSynchronizer in JDK 1.6, and deserialise it in JDK 1.5, so that doesn't seem to be the problem.

I'm going to try an approach that prevents the AgentClassLoader from attempting to load classes in java.*


Adrian Hempel [Atlassian] added a comment - 29/Apr/08 01:15 AM
The fix for this issue will be delivered in Bamboo 2.0.2.

Until then, the following workaround should be used:

Instead of using the Bamboo Remote Agent JAR that can be downloaded from the Bamboo administration pages, use bamboo-agent-BAM-2520.jar. Modify the command line used to start the remote agent to refer to this JAR.