[CDO] Cannot connect to my repository (following some samples) [message #1015386] |
Thu, 28 February 2013 12:58 |
Marc Gil Messages: 81 Registered: July 2009 |
Member |
|
|
Hi,
I cannot connect to a CDO server running in localhost. I have followed the instructions of two examples, but no one works for me:
http://www.rcp-vision.com/?p=1285&lang=en
http://wiki.eclipse.org/CDO/Net4j_Authentication
I'm using authentication on my CDO server.
I tried the following code, using also the commented variants:
// Get and prepare the container
IPluginContainer container = IPluginContainer.INSTANCE;
// Net4jUtil.prepareContainer(container);
// TCPUtil.prepareContainer(container);
// CDONet4jUtil.prepareContainer(container);
// Create credentials
PasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(
"Administrator", "0000");
container.addPostProcessor(new ConnectorCredentialsInjector(
"127.0.0.1:2036", credentialsProvider));
// Get connector
IConnector connector;
connector = TCPUtil.getConnector(container, "127.0.0.1:2036");
// connector = (IConnector) container.getElement(
// "org.eclipse.net4j.connectors", connectionType,
// "127.0.0.1:2036");
// Create configuration
CDONet4jSessionConfiguration sessionConfiguration = CDONet4jUtil
.createNet4jSessionConfiguration();
sessionConfiguration.setConnector(connector);
sessionConfiguration.setRepositoryName(repository);
// Try to open the session
CDOSession session = sessionConfiguration.openNet4jSession();
Using as address "127.0.0.1:2036", I always get an error when getting the connector (TCPUtil.getConnector...): org.eclipse.net4j.util.lifecycle.LifecycleException: Could not activate TCPClientConnector[127.0.0.1:2,036]
Anybody can help please? I don't know what's happening. Of course, the server is running...
Thanks,
Marc
[Updated on: Thu, 28 February 2013 12:58] Report message to a moderator
|
|
|
|
Re: [CDO] Cannot connect to my repository (following some samples) [message #1015524 is a reply to message #1015386] |
Fri, 01 March 2013 05:40 |
|
Am 28.02.2013 13:58, schrieb Marc Gil:
> Hi,
>
> I cannot connect to a CDO server running in localhost. I have followed the instructions of two examples, but no one
> works for me:
> http://www.rcp-vision.com/?p=1285&lang=en
> http://wiki.eclipse.org/CDO/Net4j_Authentication
>
> I'm using authentication on my CDO server.
>
> I tried the following code, using algo the commented variants:
>
> // Get and prepare the container
> IPluginContainer container = IPluginContainer.INSTANCE;
> // Net4jUtil.prepareContainer(container);
> // TCPUtil.prepareContainer(container);
> // CDONet4jUtil.prepareContainer(container);
>
> // Create credentials
> PasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(
> "Administrator", "0000");
> container.addPostProcessor(new ConnectorCredentialsInjector(
> "127.0.0.1:2036", credentialsProvider));
>
> // Get connector
> IConnector connector;
> connector = TCPUtil.getConnector(container, "127.0.0.1:2036");
> // connector = (IConnector) container.getElement(
> // "org.eclipse.net4j.connectors", connectionType,
> // "127.0.0.1:2036");
>
> // Create configuration
> CDONet4jSessionConfiguration sessionConfiguration = CDONet4jUtil
> .createNet4jSessionConfiguration();
> sessionConfiguration.setConnector(connector);
> sessionConfiguration.setRepositoryName(repository);
>
> // Try to open the session
> CDOSession session = sessionConfiguration.openNet4jSession();
>
>
> Using as address "127.0.0.1:2036", I always get an error when getting the connector (TCPUtil.getConnector...):
> org.eclipse.net4j.util.lifecycle.LifecycleException: Could not activate TCPClientConnector[127.0.0.1:2,036]
>
> Anybody can help please? I don't know what's happening. Of course, the server is running...
That's probably because the acceptor on the server side needs to be configured with an INegotiator. There's an example
in org.eclipse.net4j.tests.TCPConnectorTest
public void testNegotiationSuccess() throws Exception
{
threadPool = Executors.newCachedThreadPool();
LifecycleUtil.activate(threadPool);
bufferPool = Net4jUtil.createBufferPool();
LifecycleUtil.activate(bufferPool);
randomizer = new Randomizer();
randomizer.activate();
userManager = new UserManager();
userManager.activate();
userManager.addUser(USER_ID, PASSWORD);
challengeNegotiator = new ChallengeNegotiator();
challengeNegotiator.setRandomizer(randomizer);
challengeNegotiator.setUserManager(userManager);
challengeNegotiator.activate();
provideTransport();
selector.activate();
acceptor.setStartSynchronously(true);
acceptor.setSynchronousStartTimeout(TIMEOUT);
acceptor.getConfig().setBufferProvider(bufferPool);
acceptor.getConfig().setReceiveExecutor(threadPool);
acceptor.getConfig().setNegotiator(challengeNegotiator);
acceptor.setSelector(selector);
acceptor.setAddress("0.0.0.0"); //$NON-NLS-1$
acceptor.setPort(PORT);
acceptor.activate();
credentialsProvider = new PasswordCredentialsProvider(CREDENTIALS);
LifecycleUtil.activate(credentialsProvider);
responseNegotiator = new ResponseNegotiator();
responseNegotiator.setCredentialsProvider(credentialsProvider);
responseNegotiator.activate();
connector.getConfig().setBufferProvider(bufferPool);
connector.getConfig().setReceiveExecutor(threadPool);
connector.getConfig().setNegotiator(responseNegotiator);
connector.setSelector(selector);
connector.setHost("localhost"); //$NON-NLS-1$
connector.setPort(PORT);
connector.activate();
connector.waitForConnection(DEFAULT_TIMEOUT);
InternalChannel clientChannel = connector.openChannel();
assertEquals(USER_ID, clientChannel.getUserID());
IConnector serverConnector = acceptor.getElements()[0];
IChannel serverChannel = serverConnector.getElements()[0];
assertEquals(USER_ID, serverChannel.getUserID());
System.out.println(serverChannel);
}
If you pull the acceptor out of an IManagedContainer you can configure it with an
org.eclipse.net4j.util.security.ResponseNegotiatorInjector.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] Cannot connect to my repository (following some samples) [message #1015526 is a reply to message #1015442] |
Fri, 01 March 2013 05:46 |
|
Am 28.02.2013 16:37, schrieb Marc Gil:
> Finally I get I by doing the following:
>
> // Enable logging and tracing
> OMPlatform.INSTANCE.setDebugging(true);
> OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
> OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
>
> // Prepare container
> IManagedContainer container = ContainerUtil.createContainer();
> Net4jUtil.prepareContainer(container); // Register Net4j factories
> TCPUtil.prepareContainer(container); // Register TCP factories
> CDONet4jUtil.prepareContainer(container); // Register CDO factories
This last call is not needed if you explicitely open your CDOSession through a CDOSessionConfiguration (and not through
the IManagedContainer).
> container.activate();
>
> // Create connector
> IConnector connector = TCPUtil.getConnector(container,
> getAddressConnection()); //$NON-NLS-1$
>
> // Create configuration
> CDONet4jSessionConfiguration configuration = CDONet4jUtil
> .createNet4jSessionConfiguration();
> configuration.setConnector(connector);
> configuration.setRepositoryName(repository); //$NON-NLS-1$
>
> // Create credentials
> PasswordCredentialsProvider credentialsProvider = new PasswordCredentialsProvider(
> user, password);
> configuration.setCredentialsProvider(credentialsProvider);
>
> // Open session
> CDOSession session = configuration.openNet4jSession();
> transaction = session.openTransaction();
> return session;
>
>
> It seems similar than the other code, but just creating the credentials after creating the connector, and assigning it
> to the session configuration instead of to the connector.
>
> Is it correct?
Yes, this CDO authentication is newer and (in some ways) more powerful for CDO applications than the older Net4j
authentication.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Powered by
FUDForum. Page generated in 0.03364 seconds