javax.naming.ConfigurationException does not contain an IOR - java

I have a probleme when I run client code for an Ejb Bean
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
System.out.println("property"+prop.getProperty(Context.INITIAL_CONTEXT_FACTORY));
prop.put(Context.PROVIDER_URL,"http://localhost:9191");
InitialContext context = new InitialContext(prop);
System.out.println("ha context"+context);
System.out.println(context.getEnvironment());
Object o = context.lookup("Advisor");
System.out.println("object"+o);
AdviceHome adviceHome = (AdviceHome) PortableRemoteObject.narrow(o,AdviceHome.class);
System.out.println("ha adviceHome"+adviceHome);
Advice advice = adviceHome.create();
System.out.println("enfin notre chere advice"+advice.getAdvice());
error: javax.naming.ConfigurationException: http://localhost:9191 does
not contain an IOR
Im using j2sdkee1.3.1 server

Related

T3 client with custom SSLSocketFactory

I have my T3 client code like this:
private InitialContext initContext() {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, context.providerURL);
for (Map.Entry<String, String> entry : getEnvironmentProperties().entrySet()) {
p.put(entry.getKey(), entry.getValue());
}
InitialContext res = null;
try {
res = new InitialContext(p);
} catch (NamingException e) {
e.printStackTrace();
}
return res;
}
My t3 client deployed on Tomcat (uses wlthint3client-12.1.3.jar) and trying to lookup remote bean of external system which deployed on Weblogic.
However when I trying to perform new InitialContext(p) I receive SSLHandshake exception, because it gets standart SSLSocketFactory with standart SSLConext and standart java trust store.
My question - is there any way to give to InitialContext some property which will override SSLSocketFacory. My aim is to populate my cutom trust store to this t3 client.
Changing standart trust store like this
System.setProperty("javax.net.ssl.trustStore", "pathToTrustStore");
works fine, however in case if my t3 client is used to communicate with 2 different external systems, it might be a problem in doing so.
Is there some property that I can populate?
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
**p.put("CUSTOM SSL SOCKET FACTORY, "MY CLASS");**
Problem was solved by adding few parameters on application side
export JAVA_OPTS ="$JAVA_OPTS -Djavax.net.ssl.trustStore=path/truststore.jks"
export JAVA_OPTS ="$JAVA_OPTS -Djavax.net.ssl.trustStorePassword=changeIT"

HotRodClientException:Request for message id[6] returned server error (status=0x85): java.lang.NullPointerException

I am new to infinispan and I am trying clustered configuration.
Here is my code
GlobalConfigurationBuilder globalConfig = GlobalConfigurationBuilder.defaultClusteredBuilder();
globalConfig.transport().clusterName("infiniDistributedCluster").distributedSyncTimeout(30000).globalJmxStatistics().enable().allowDuplicateDomains(Boolean.TRUE);
configBuilder = new org.infinispan.configuration.cache.ConfigurationBuilder();
embeddedCacheManager = new DefaultCacheManager(globalConfig.build());
configBuilder.dataContainer().compatibility().enable().clustering().cacheMode(CacheMode.DIST_SYNC).sync().hash().numOwners(2).l1().lifespan(60000);
embeddedCacheManager.defineConfiguration("TestCache", configBuilder.build());
HotRodServerConfiguration build = new HotRodServerConfigurationBuilder().host(hotRodIpAddress).build();
HotRodServer server = new HotRodServer();
server.start(build, embeddedCacheManager);
I am trying to fetch it from my HotRod client.
ConfigurationBuilder remoteBuilder = new ConfigurationBuilder();
remoteBuilder.addServers(serverIP).nearCache().mode(NearCacheMode.LAZY).maxEntries(500);
RemoteCacheManager remoteCacheManager = new RemoteCacheManager(remoteBuilder.build());
remoteCache = remoteCacheManager.getCache("TestCache");
But I receive the above exception.

Bean Lookup Error

The following code works fine in JBoss, but when deployed in Apache Tomcat it gives
javax.naming.NameNotFoundException: Name [SPConnectorClient] is not bound in this Context. Unable to find [SPConnectorClient].
Code:
logger.info("SPConnectorClientEJB::callSubmitRequest");
SPResponse response = new SPResponse();
Object responseObj = null;
try
{
InitialContext ctx = null;
ctx = new InitialContext();
logger.info("Got InitialContext");
SPConnectorClientHome home = (SPConnectorClientHome)ctx.lookup("SPConnectorClient");
SPConnectorClientRemote remote = null;
remote = home.create();
logger.info("Got Remote Object!");
Code in Setenv.sh file:
JAVA_OPTS="$JAVA_OPTS -DSPAppspecificJNDI=java:global/SP/sp_app_specific/SPConnectorClient!com.cdac.sp.SPConnectorClientRemote"

No Such Field Error : SASL PROPERTIES on invoking EJB Client

I am trying to invoke EJB but get SASL PROPERTY: No such filed error. I have added SASL jar "jboss-sasl-1.0.0.Beta1.jar" as a dependency too.
This is my code:
Properties properties = new Properties();
properties.put("endpoint.name", "client-endpoint");
properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
properties.put("remote.connections", "default");
properties.put("remote.connection.default.host", "localhost");
properties.put("remote.connection.default.port", "4447");
properties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
properties.put("remote.connection.default.username", "user");
properties.put("remote.connection.default.password", "pass");
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(properties);
final ContextSelector<EJBClientContext> ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(cc);
final ContextSelector<EJBClientContext> previousSelector = EJBClientContext.setSelector(ejbClientContextSelector);
StatelessEJBLocator<SomeClass> locator = new StatelessEJBLocator(SomeClass.class, "app", "module", "viewType", "distinctName");
SecurityDomainService ejb = org.jboss.ejb.client.EJBClient.createProxy(locator);`
But I get this exception:
java.lang.NoSuchFieldError: SASL_PROPERTIES
org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.<clinit>(PropertiesBasedEJBClientConfiguration.java:79)
Can anyone help?
It turns out I was getting this error because I wasn't using the correct EJB Client jar.
I guess jboss-ejb-client-1.0.16.Final.jar introduced this field, and it works fine when used with this jar.

Remote object call inside remote JVM

I'm working with weblogic Server. I was wondering if after binding an object in the JNDI context it would be possible to make remote call on this object (executing it inside the remote JVM).
In my local JVM:
Context ctx = null;
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,"t3://remoteServer:7001/);
env.put(Context.SECURITY_PRINCIPAL,"");
env.put(Context.SECURITY_CREDENTIALS,"");
try {
ctx = new InitialContext(env);
MyObjectImpl obj1 = new MyObjectImpl();
ctx.bind("jndi_name", obj1);
//Now my object can be retrieve from the JNDI context under "jndi_name"
MyObjectImpl obj2 = (MyObjectImpl)ctx.lookup("jndi_name"); //lookup of object
System.out.println(obj2.method(1,2)); //call
}catch (Exception e) {
// a failure occurred
}
But the call is done locally in the client JVM and not the remote JVM.
Is there any way to counter this problem?
Regards,
Make sure you have a remote interface(using annotation #Remote) for jndi lookup.
You can see this example: http://middlewaremagic.com/weblogic/?p=5532 (search for the class “CalculatorBean.java”).

Categories