[CDO] Starting sequence of IAppExtensions [message #959372] |
Fri, 26 October 2012 13:11  |
Eclipse User |
|
|
|
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
|
|
|
|
Re: [CDO] Starting sequence of IAppExtensions [message #961501 is a reply to message #960223] |
Sun, 28 October 2012 06:26   |
Eclipse User |
|
|
|
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 06:38   |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07331 seconds