|
Re: [CDO] Starting sequence of IAppExtensions [message #960223 is a reply to message #959372] |
Sat, 27 October 2012 09:30 |
|
Hi Christoph,
I think this has been asked before but I couldn't find that thread either. The solution is to listen to IContainerEvents
from IPluginContainer.INSTANCE, if the repository/acceptor is not available there immediately. You can overwrite
ContainerEventAdapter.onAdded() to react to later container element additions. Does that help?
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 26.10.2012 19:11, schrieb Christoph Keimel:
> Hello
>
> I have created an IAppExtension for our CDO/Hibernate server. This extension uses JVM to connect to the server.
>
> My problem is: Depending on the starting order of the IAppExtensions, I sometimes get an error that the JVM acceptor
> "default:0" could not be found. I found that the acceptor is initiated with the Net4jAppExtension. So when
> Net4jAppExtension is started first everything is fine. If my new AppExtension is started first, it can't connect.
>
> The acceptor is defined in the cdo-server.xml:
>
> <cdoServer>
> <acceptor type="jvm" listenAddr="default" port="0"/>
> <acceptor type="tcp" listenAddr="0.0.0.0" port="2036"/>
>
> ...
> </cdoServer>
>
>
> This is the code that establishes the JVM session:
> private CDOSession openSession() {
> if (sessionConfiguration == null) {
> logger.info("Initialisiere CDO Configuration ...");
> initialize();
> }
> final CDONet4jSession cdoSession = sessionConfiguration.openNet4jSession();
> return cdoSession;
> }
>
> private void initialize() {
> // Prepare container
> final IManagedContainer container = ContainerUtil.createContainer();
> Net4jUtil.prepareContainer(container); // Register Net4j factories
> JVMUtil.prepareContainer(container); // Register JVM factories
> CDONet4jUtil.prepareContainer(container); // Register CDO factories
> container.activate();
>
> // Create connector
> if (connector == null) {
> logger.info("Erstelle JVMUtil Connector");
> connector = JVMUtil.getConnector(container, "default:0");
> }
>
> // Create configuration
> logger.info("Erstelle CDOSessionConfiguration zu: {}", REPO_NAME);
> sessionConfiguration = CDONet4jUtil.createNet4jSessionConfiguration();
> sessionConfiguration.setConnector(connector);
> sessionConfiguration.setRepositoryName(REPO_NAME);
> }
>
> My questions are:
> 1. Do I need to initialize the acceptor? If yes, how?
> 2. Is it possible to set the order of AppExtension execution?
>
> Any additional hints are also most welcome.
>
> Thank you!
> Christoph
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] Starting sequence of IAppExtensions [message #961501 is a reply to message #960223] |
Sun, 28 October 2012 10:26 |
Christoph Keimel Messages: 482 Registered: December 2010 Location: Germany |
Senior Member |
|
|
Hi Eike,
thanks for the Input. I'm still stuck though, so I would be gratefull if you could give me another pointer.
This is the way I am processing at the moment:
private void process() {
final IManagedContainer container = createContainer();
try {
logger.info("Erstelle JVMUtil Connector");
IConnector connector = JVMUtil.getConnector(container, ACCEPTOR_NAME);
continueProcess(connector);
} catch (IllegalStateException e) {
logger.info("Installiere ContainerListener");
IPluginContainer.INSTANCE.addListener(new ContainerEventAdapter<Object>() {
@Override
protected void onAdded(IContainer<Object> cont, Object element) {
if (element instanceof JVMAcceptor) {
JVMAcceptor acceptor = (JVMAcceptor) element;
if (acceptor.getName().equals(ACCEPTOR_NAME)) {
logger.info("Erstelle JVMUtil Connector");
//JVMUtil.getAcceptor(container, ACCEPTOR_NAME);
IConnector connector = JVMUtil.getConnector(container, ACCEPTOR_NAME);
//IConnector connector = JVMUtil.getConnector(IPluginContainer.INSTANCE, ACCEPTOR_NAME);
continueProcess(connector);
}
IPluginContainer.INSTANCE.removeListener(this);
}
}
});
}
}
I am waiting for the Acceptor to be added before I continue with the processing. This still leads to the same error because the Acceptor is still not available in my container and passing IPluginContainer.INSTANCE to JVMUtil.getConnector produces the same result.
If I manually add the Acceptor with JVMUtil.getAcceptor, I get a different exception:
org.eclipse.net4j.channel.ChannelException: org.eclipse.net4j.util.container.FactoryNotFoundException: Factory not found: org.eclipse.net4j.serverProtocols[cdo]
at org.eclipse.net4j.internal.jvm.JVMConnector.registerChannelWithPeer(JVMConnector.java:135)
...
Which I don't realy understand since this factory is contributed by the plug-in org.eclipse.emf.cdo.server.net4j which is part of my product configuration and it should be activated, since the listener is triggered by code in the Net4jAppExtension contributed by the same plug-in.
I was looking for an event signalling the end of the startup process, but couldn't see anything in CdoServerApp. Starting the IAppExtension(s) is the last thing that happens, so I am not sure what I am missing.
Greetings
Christoph
|
|
|
Re: [CDO] Starting sequence of IAppExtensions [message #961515 is a reply to message #961501] |
Sun, 28 October 2012 10:38 |
|
Hi Christophe,
It's probably easier to not depend on other IAppExtensions at all. You could create the JVMAcceptor/JVMCOnnector pair in
your own extension.
More comments below...
Am 28.10.2012 11:26, schrieb Christoph Keimel:
> Hi Eike,
>
> thanks for the Input. I'm still stuck though, so I would be gratefull if you could give me another pointer.
>
> This is the way I am processing at the moment:
> private void process() {
> final IManagedContainer container = createContainer();
> try {
> logger.info("Erstelle JVMUtil Connector");
> IConnector connector = JVMUtil.getConnector(container, ACCEPTOR_NAME);
> continueProcess(connector);
> } catch (IllegalStateException e) {
> logger.info("Installiere ContainerListener");
> IPluginContainer.INSTANCE.addListener(new ContainerEventAdapter<Object>() {
> @Override
> protected void onAdded(IContainer<Object> cont, Object element) {
> if (element instanceof JVMAcceptor) {
> JVMAcceptor acceptor = (JVMAcceptor) element;
> if (acceptor.getName().equals(ACCEPTOR_NAME)) {
> logger.info("Erstelle JVMUtil Connector");
> //JVMUtil.getAcceptor(container, ACCEPTOR_NAME);
> IConnector connector = JVMUtil.getConnector(container, ACCEPTOR_NAME);
> //IConnector connector = JVMUtil.getConnector(IPluginContainer.INSTANCE, ACCEPTOR_NAME);
> continueProcess(connector);
> }
> IPluginContainer.INSTANCE.removeListener(this);
> }
> }
> });
> }
> }
> I am waiting for the Acceptor to be added before I continue with the processing. This still leads to the same error
> because the Acceptor is still not available in my container and passing IPluginContainer.INSTANCE to
> JVMUtil.getConnector produces the same result.
>
> If I manually add the Acceptor with JVMUtil.getAcceptor, I get a different exception:
> org.eclipse.net4j.channel.ChannelException: org.eclipse.net4j.util.container.FactoryNotFoundException: Factory not
> found: org.eclipse.net4j.serverProtocols[cdo]
> at org.eclipse.net4j.internal.jvm.JVMConnector.registerChannelWithPeer(JVMConnector.java:135)
> ...
>
> Which I don't realy understand since this factory is contributed by the plug-in org.eclipse.emf.cdo.server.net4j which
> is part of my product configuration and it should be activated,
And is it? You can check on the OSGi console with "ss".
> since the listener is triggered by code in the Net4jAppExtension contributed by the same plug-in.
>
> I was looking for an event signalling the end of the startup process, but couldn't see anything in CdoServerApp.
> Starting the IAppExtension(s) is the last thing that happens, so I am not sure what I am missing.
These things are so dependent on your deployment. Can you provide me with a small and executable example?
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] Starting sequence of IAppExtensions [message #961767 is a reply to message #961613] |
Sun, 28 October 2012 15:27 |
|
Am 28.10.2012 13:32, schrieb Christoph Keimel:
> Hi Everybody,
>
> I found the solution to the problem. Instead of creating my own container, I need to use IPluginContainer.INSTANCE
> from the beginning.
Oh, I overlooked this in your first post:
// Prepare container
final IManagedContainer container = ContainerUtil.createContainer();
> I also removed the acceptor from cdo-server.xml. The acceptor is now manually created with:
> JVMUtil.getAcceptor(IPluginContainer.INSTANCE, ACCEPTOR_NAME).
>
> So it's actually very simple to start a JMV connection independent from the Net4jAppExtension:
> public void start(File configFile) throws Exception {
> IManagedContainer container = IPluginContainer.INSTANCE;
> JVMUtil.getAcceptor(container, ACCEPTOR_NAME);
Yes, that's basically the same what happens in the Net4jAppExtension.
> IConnector connector = JVMUtil.getConnector(container, ACCEPTOR_NAME);
>
> sessionConfiguration = CDONet4jUtil.createNet4jSessionConfiguration();
> sessionConfiguration.setConnector(connector);
> sessionConfiguration.setRepositoryName(REPO_NAME);
>
> CDOSession session = sessionConfiguration.openNet4jSession();
> ...
> }
>
> Thanks for the help.
Good that you figured out how to do it ;-)
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.03302 seconds