Hi,

I'm getting an error of:
java.lang.IllegalStateException: BeanFactory not initialized or already closed 
- call 'refresh' before accessing beans via the ApplicationContext
when my application context is created for the second time.

The basics of the class are below.
When test1 is being run it works completely, but when test2 starts the line:
Select5ThingyStuffService service = new Select5ThingyStuffService();
throws the exception above.

Is there a solution for this?

Thanks
Jim


public class ThingyProcessorTest extends CamelSpringTestSupport
{
    private static final Logger log = LoggerFactory.getLogger( 
ThingyProcessorTest.class );
    private static final String TARGET_URL = 
"http://localhost:9000/Select/Thingy/Stuff";;
    private static Select5ThingyStuffPortType client;
    
    @Override
    protected AbstractApplicationContext createApplicationContext() {
        FileSystemXmlApplicationContext localContext = new 
FileSystemXmlApplicationContext( new String[] { 
"target/generated-resources/xml/xslt/Select5ThingyStuff-1.1.0.xml" }, true );
        return localContext;
    }

    @Override
    public void doPreSetup() throws Exception {
        super.doPreSetup();
        
        Select5ThingyStuffService service = new Select5ThingyStuffService();
        
        service.addPort( Select5ThingyStuffService.Select5ThingyStuffPort, 
SOAPBinding.SOAP11HTTP_BINDING, TARGET_URL );
        client = service.getPort( Select5ThingyStuffPortType.class );
        BindingProvider binder = ( BindingProvider ) client;
        binder.getRequestContext().put( 
BindingProvider.ENDPOINT_ADDRESS_PROPERTY, TARGET_URL );
        
        Client cl = ClientProxy.getClient(client);
        HTTPConduit http = (HTTPConduit) cl.getConduit();
        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        httpClientPolicy.setReceiveTimeout(0);
        http.setClient(httpClientPolicy);
    }

    @Test
    public void test1() {
    }

    @Test
    public void test2() {
    }
}

Reply via email to