use of org.omg.CosNaming.NamingContextPackage.NotFound in project ACS by ACS-Community.
the class HelperTest method setUp.
protected void setUp() throws Exception {
System.out.println("------------------------- " + getName() + " -------------------------");
super.setUp();
nctx = NamingContextHelper.narrow(m_acsManagerProxy.get_service(NAMING_SERVICE_NAME.value, false));
String factoryMonitorRegName = "MC_NotifyEventChannelFactory";
try {
nsmc = NotificationServiceMonitorControlHelper.narrow(nctx.resolve(new NameComponent[] { new NameComponent("MC_NotifyEventChannelFactory", "") }));
} catch (NotFound ex) {
fail("Failed to resolve factory's MC extension object in the naming service: " + factoryMonitorRegName + ". This is a recurrent problem, probably linked to the missing line 'ReBound ID: MC_NotifyEventChannelFactory' in ./tmp/acsStart.log.");
}
assertNotNull(nsmc);
}
use of org.omg.CosNaming.NamingContextPackage.NotFound in project wildfly by wildfly.
the class EjbIIOPService method rebind.
/**
* (Re)binds an object to a name in a given CORBA naming context, creating
* any non-existent intermediate contexts along the way.
* <p/>
* This method is synchronized on the class object, if multiple services attempt to bind the
* same context name at once it will fail
*
* @param ctx a reference to the COSNaming service.
* @param strName the name under which the CORBA object is to be bound.
* @param obj the CORBA object to be bound.
* @throws Exception if an error occurs while binding the object.
*/
public static synchronized void rebind(final NamingContextExt ctx, final String strName, final org.omg.CORBA.Object obj) throws Exception {
final NameComponent[] name = ctx.to_name(strName);
NamingContext intermediateCtx = ctx;
for (int i = 0; i < name.length - 1; i++) {
final NameComponent[] relativeName = new NameComponent[] { name[i] };
try {
intermediateCtx = NamingContextHelper.narrow(intermediateCtx.resolve(relativeName));
} catch (NotFound e) {
intermediateCtx = intermediateCtx.bind_new_context(relativeName);
}
}
intermediateCtx.rebind(new NameComponent[] { name[name.length - 1] }, obj);
}
use of org.omg.CosNaming.NamingContextPackage.NotFound in project wildfly by wildfly.
the class EjbIIOPService method stop.
@Override
public synchronized void stop(final StopContext context) {
// Get local (in-VM) CORBA naming context
final NamingContextExt corbaContext = corbaNamingContext.getValue();
// Unregister bean home from local CORBA naming context
try {
NameComponent[] name = corbaContext.to_name(this.name);
corbaContext.unbind(name);
} catch (InvalidName invalidName) {
EjbLogger.ROOT_LOGGER.cannotUnregisterEJBHomeFromCobra(invalidName);
} catch (NotFound notFound) {
EjbLogger.ROOT_LOGGER.cannotUnregisterEJBHomeFromCobra(notFound);
} catch (CannotProceed cannotProceed) {
EjbLogger.ROOT_LOGGER.cannotUnregisterEJBHomeFromCobra(cannotProceed);
}
// Deactivate the home servant and the bean servant
try {
homeServantRegistry.unbind(homeServantName(this.name));
} catch (Exception e) {
EjbLogger.ROOT_LOGGER.cannotDeactivateHomeServant(e);
}
try {
beanServantRegistry.unbind(beanServantName(this.name));
} catch (Exception e) {
EjbLogger.ROOT_LOGGER.cannotDeactivateBeanServant(e);
}
if (iri != null) {
// Deactivate the interface repository
iri.shutdown();
}
this.name = null;
}
use of org.omg.CosNaming.NamingContextPackage.NotFound in project wildfly by wildfly.
the class CNCtx method destroySubcontext.
/**
* Uses the callDestroy function to destroy the context. Destroys
* the current context if name is empty.
*
* @param name JNDI Name
* @throws javax.naming.OperationNotSupportedException when list is invoked
* with a non-null argument
*/
public void destroySubcontext(Name name) throws NamingException {
if (_nc == null)
throw IIOPLogger.ROOT_LOGGER.notANamingContext(name.toString());
NamingContext the_nc = _nc;
NameComponent[] path = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.nameToCosName(name);
if (name.size() > 0) {
try {
javax.naming.Context ctx = (javax.naming.Context) callResolve(path);
CNCtx cnc = (CNCtx) ctx;
the_nc = cnc._nc;
//remove the reference to the context
cnc.close();
} catch (ClassCastException e) {
throw new NotContextException(name.toString());
} catch (CannotProceedException e) {
javax.naming.Context cctx = getContinuationContext(e);
cctx.destroySubcontext(e.getRemainingName());
return;
} catch (NameNotFoundException e) {
if (e.getRootCause() instanceof NotFound && leafNotFound((NotFound) e.getRootCause(), path[path.length - 1])) {
// leaf missing OK
return;
}
throw e;
} catch (NamingException e) {
throw e;
}
}
callDestroy(the_nc);
callUnbind(path);
}
use of org.omg.CosNaming.NamingContextPackage.NotFound in project wildfly by wildfly.
the class ExceptionMapper method tryFed.
private static NamingException tryFed(NotFound e, CNCtx ctx, NameComponent[] inputName) throws NamingException {
NameComponent[] rest = ((NotFound) e).rest_of_name;
if (debug) {
}
// If one of those is not found, you get "aa" as 'rest'.
if (rest.length == 1 && inputName != null) {
// Check that we're not talking to 1.2/1.3 Sun tnameserv
NameComponent lastIn = inputName[inputName.length - 1];
if (rest[0].id.equals(lastIn.id) && rest[0].kind != null && rest[0].kind.equals(lastIn.kind)) {
// Might be legit
} else {
// Due to 1.2/1.3 bug that always returns single-item 'rest'
NamingException ne = new NameNotFoundException();
ne.setRemainingName(org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(rest));
ne.setRootCause(e);
throw ne;
}
}
// Fixed in 1.4; perform calculations based on correct (1.4) behavior
// Calculate the components of the name that has been resolved
NameComponent[] resolvedName = null;
int len = 0;
if (inputName != null && (inputName.length >= rest.length)) {
if (e.why == NotFoundReason.not_context) {
// First component of rest is found but not a context; keep it
// as part of resolved name
len = inputName.length - (rest.length - 1);
// Remove resolved component from rest
if (rest.length == 1) {
// No more remaining
rest = null;
} else {
NameComponent[] tmp = new NameComponent[rest.length - 1];
System.arraycopy(rest, 1, tmp, 0, tmp.length);
rest = tmp;
}
} else {
len = inputName.length - rest.length;
}
if (len > 0) {
resolvedName = new NameComponent[len];
System.arraycopy(inputName, 0, resolvedName, 0, len);
}
}
// Create CPE and set common fields
CannotProceedException cpe = new CannotProceedException();
cpe.setRootCause(e);
if (rest != null && rest.length > 0) {
cpe.setRemainingName(org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(rest));
}
cpe.setEnvironment(ctx._env);
// Lookup resolved name to get resolved object
final java.lang.Object resolvedObj = (resolvedName != null) ? ctx.callResolve(resolvedName) : ctx;
if (resolvedObj instanceof javax.naming.Context) {
// obj is a context and child is not found
// try getting its nns dynamically by constructing
// a Reference containing obj.
RefAddr addr = new RefAddr("nns") {
public java.lang.Object getContent() {
return resolvedObj;
}
private static final long serialVersionUID = 669984699392133792L;
};
Reference ref = new Reference("java.lang.Object", addr);
// Resolved name has trailing slash to indicate nns
CompositeName cname = new CompositeName();
// add trailing slash
cname.add("");
cpe.setResolvedObj(ref);
cpe.setAltName(cname);
cpe.setAltNameCtx((javax.naming.Context) resolvedObj);
return cpe;
} else {
// Not a context, use object factory to transform object.
Name cname = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(resolvedName);
java.lang.Object resolvedObj2;
try {
resolvedObj2 = NamingManager.getObjectInstance(resolvedObj, cname, ctx, ctx._env);
} catch (NamingException ge) {
throw ge;
} catch (Exception ge) {
NamingException ne = IIOPLogger.ROOT_LOGGER.errorGeneratingObjectViaFactory();
ne.setRootCause(ge);
throw ne;
}
// If a context, continue operation with context
if (resolvedObj2 instanceof javax.naming.Context) {
cpe.setResolvedObj(resolvedObj2);
} else {
// Add trailing slash
cname.add("");
cpe.setAltName(cname);
// Create nns reference
final java.lang.Object rf2 = resolvedObj2;
RefAddr addr = new RefAddr("nns") {
public java.lang.Object getContent() {
return rf2;
}
private static final long serialVersionUID = -785132553978269772L;
};
Reference ref = new Reference("java.lang.Object", addr);
cpe.setResolvedObj(ref);
cpe.setAltNameCtx(ctx);
}
return cpe;
}
}
Aggregations