Discussion:
Regression in PicoContainer 2.4 and above?
Tim Cleaver
2008-11-10 08:26:28 UTC
Permalink
PicoContainer devs,

I have just moved onto PicoContainer 2.6 in the hope of using the ENABLE_CIRCULAR characteristic.
However, in doing so I am coming across the following problem that was not present in PicoContainer 2.4 and
prior (It also fails in PicoContainer 2.5).

java.lang.IllegalArgumentException: Unable to get collection type from I
at org.picocontainer.parameters.CollectionComponentParameter.getCollectionType(CollectionComponentParameter.java:180)
at org.picocontainer.parameters.CollectionComponentParameter.isResolvable(CollectionComponentParameter.java:166)
at org.picocontainer.parameters.ComponentParameter.isResolvable(ComponentParameter.java:139)
at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:123)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:173)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:284)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:218)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:574)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:535)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:547)
at TestCase.main(TestCase.java:22)

The code is as follows:

import org.picocontainer.DefaultPicoContainer;

class TestCase {
interface Interface {
}

public class Generic {
public Generic(final I iface) {
}
}

public class Implementation implements Interface {
}

public static void main(final String[] args) {
DefaultPicoContainer container = new DefaultPicoContainer();
try {
container.addComponent(Implementation.class);
container.addComponent(Generic.class);
container.getComponent(Generic.class);
} catch (final Exception exception) {
exception.printStackTrace();
}
}
}

I must admit my surprise at the inclusion of CollectionComponentParameter in the stack trace
considering no collections are used. Any assistance in resolving this issue (be it with my code or
picocontainer) is greatly appreciated. To ensure that hotmail does not mangle the code I am also
attaching it as a file.

regards,
Tim Cleaver

_________________________________________________________________
Net yourself a bargain. Find great deals on eBay.
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Frover%2Eebay%2Ecom%2Frover%2F1%2F705%2D10129%2D5668%2D323%2F4%3Fid%3D10&_t=763807330&_r=hotmailTAGLINES&_m=EXT
Paul Hammant
2008-11-10 14:33:31 UTC
Permalink
Tim,

We'll look into it. Pico's < 2.6 could also do circular deps via the
ImplementationHiding behavior. It was just not well known. The
ENABLE_CIRCULAR is more or less a synonym for that.

Regards,

- Paul
Post by Tim Cleaver
PicoContainer devs,
I have just moved onto PicoContainer 2.6 in the hope of using the
ENABLE_CIRCULAR characteristic.
However, in doing so I am coming across the following problem that
was not present in PicoContainer 2.4 and
prior (It also fails in PicoContainer 2.5).
java.lang.IllegalArgumentException: Unable to get collection type from I
at
org
.picocontainer
.parameters
.CollectionComponentParameter
.getCollectionType(CollectionComponentParameter.java:180)
at
org
.picocontainer
.parameters
.CollectionComponentParameter
.isResolvable(CollectionComponentParameter.java:166)
at
org
.picocontainer
139)
at
org
.picocontainer
.injectors
.ConstructorInjector
.getGreediestSatisfiableConstructor(ConstructorInjector.java:123)
at org.picocontainer.injectors.ConstructorInjector
$1.run(ConstructorInjector.java:173)
at org.picocontainer.injectors.AbstractInjector
$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:284)
at
org
.picocontainer
.injectors
218)
at
org
.picocontainer
.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:574)
at
org
.picocontainer
.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:535)
at
org
.picocontainer
.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:547)
at TestCase.main(TestCase.java:22)
import org.picocontainer.DefaultPicoContainer;
class TestCase {
interface Interface {
}
public class Generic {
public Generic(final I iface) {
}
}
public class Implementation implements Interface {
}
public static void main(final String[] args) {
DefaultPicoContainer container = new
DefaultPicoContainer();
try {
container.addComponent(Implementation.class);
container.addComponent(Generic.class);
container.getComponent(Generic.class);
} catch (final Exception exception) {
exception.printStackTrace();
}
}
}
I must admit my surprise at the inclusion of
CollectionComponentParameter in the stack trace
considering no collections are used. Any assistance in resolving
this issue (be it with my code or
picocontainer) is greatly appreciated. To ensure that hotmail does
not mangle the code I am also
attaching it as a file.
regards,
Tim Cleaver
_________________________________________________________________
Net yourself a bargain. Find great deals on eBay.
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Frover%2Eebay%2Ecom%2Frover%2F1%2F705%2D10129%2D5668%2D323%2F4%3Fid%3D10&_t=763807330&_r=hotmailTAGLINES&_m=EXT
<
TestCase
.java
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2008-11-10 15:47:44 UTC
Permalink
Tim,

I think I'm doing something wrong, when I make a testcase out of your
code. I fixed one typo ... you had and I reference which i guesses
should have been Interface. Also I inserted the word static for the
inner classes.

Can you take a look :

package org.picocontainer.defaults.issues;

import static org.junit.Assert.fail;
import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.picocontainer.DefaultPicoContainer;
import org.picocontainer.MutablePicoContainer;
import org.picocontainer.injectors.AbstractInjector;

public final class IssueXxxxTestCase {

interface Interface {
}

public static class Generic {
private final Interface iface;

public Generic(final Interface iface) {
this.iface = iface;
}
}

public static class Implementation implements Interface {
}


@Test
public void testTheBug() {
DefaultPicoContainer container = new DefaultPicoContainer();
container.addComponent(Implementation.class);
container.addComponent(Generic.class);
Generic gen = container.getComponent(Generic.class);
assertNotNull(gen);
assertNotNull(gen.iface);
}

- Paul

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Tim Cleaver
2008-11-11 04:10:19 UTC
Permalink
Paul,

Looks like I did get bitten by hotmails html formatting rubbish :S. I want to pass in
some declared subtype of interface which could be interface or something that extends
or implements it. Hopefully the attached file will make it more clear.

regards,
Tim



_________________________________________________________________
Take a summer road trip with Windows Live Hotmail. Multiple prizes and the ultimate dream beach house!
http://www.ninemsn.com.au/hotmailroadtrip
Paul Hammant
2008-11-11 04:36:03 UTC
Permalink
Yup, I can certainly reproduce that.

Regards,

- Paul
Post by Tim Cleaver
Paul,
Looks like I did get bitten by hotmails html formatting rubbish :S. I want to pass in
some declared subtype of interface which could be interface or
something that extends
or implements it. Hopefully the attached file will make it more clear.
regards,
Tim
_________________________________________________________________
Take a summer road trip with Windows Live Hotmail. Multiple prizes
and the ultimate dream beach house!
http://www.ninemsn.com.au/
hotmailroadtrip
<
TestCase
.java
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2008-11-11 06:09:03 UTC
Permalink
Chg 5056 maybe fixed this. Let me know Tim :)

Regards,

- Paul
Post by Paul Hammant
Yup, I can certainly reproduce that.
Regards,
- Paul
Post by Tim Cleaver
Paul,
Looks like I did get bitten by hotmails html formatting rubbish :S. I want to pass in
some declared subtype of interface which could be interface or something that extends
or implements it. Hopefully the attached file will make it more clear.
regards,
Tim
_________________________________________________________________
Take a summer road trip with Windows Live Hotmail. Multiple prizes
and the ultimate dream beach house!
http://www.ninemsn.com.au/
hotmailroadtrip
<
TestCase
.java
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Tim Cleaver
2008-11-11 06:29:10 UTC
Permalink
Paul,

Yep, that did it for me also. The snapshot you sent fixed the problem. Thank you very much.

regards,
Tim
Date: Mon, 10 Nov 2008 22:09:03 -0800
Subject: Re: [picocontainer-user] Regression in PicoContainer 2.4 and above?
Chg 5056 maybe fixed this. Let me know Tim :)
Regards,
- Paul
Post by Paul Hammant
Yup, I can certainly reproduce that.
Regards,
- Paul
Post by Tim Cleaver
Paul,
Looks like I did get bitten by hotmails html formatting rubbish :S. I want to pass in
some declared subtype of interface which could be interface or something that extends
or implements it. Hopefully the attached file will make it more clear.
regards,
Tim
_________________________________________________________________
Take a summer road trip with Windows Live Hotmail. Multiple prizes
and the ultimate dream beach house!
http://www.ninemsn.com.au/
hotmailroadtrip
<
TestCase
.java
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
_________________________________________________________________
Take a summer road trip with Windows Live Hotmail. Multiple prizes and the ultimate dream beach house!
http://www.ninemsn.com.au/hotmailroadtrip

Nick Drew
2008-11-11 05:01:18 UTC
Permalink
Hi all

Why does the Stored behaviour have state? It seems to keep hold of
whether the component has been started or stopped (which will be
scoped to a container), but this seems painful, since the underlying
reference is thread local (and therefore scoped to a request).

This means we get unnecessary "already disposed" errors, and prevents
adding lifecycle aware components at the request level.

Any hints to get around the issue?

Cheers

Nick Drew

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Paul Hammant
2008-11-11 06:08:22 UTC
Permalink
Nick,

If you're talking about for a web app leveraging app/session/request
containers as in PicoContainer-Web, then the momentary component
lifecycle states are supposed to be stored in the session alongside
the component adapters themselves.

Explain more please :-)

Regards,

- Paul
Post by Nick Drew
Hi all
Why does the Stored behaviour have state? It seems to keep hold of
whether the component has been started or stopped (which will be
scoped to a container), but this seems painful, since the underlying
reference is thread local (and therefore scoped to a request).
This means we get unnecessary "already disposed" errors, and
prevents adding lifecycle aware components at the request level.
Any hints to get around the issue?
Cheers
Nick Drew
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Loading...