Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot remotely find JNDI resources using InitialContext

Charles LeeOct 9 2012 — edited Oct 23 2012
I've got 2 laptops here, running next to eachother, connected to the same network switch. One is running an almost default instance of glassfish 3x, the other is running a client OUTSIDE of the container comprised of only a few lines of code to get a connectionFactory from the Glassfish server.
Running both on the same machine works like a charm, but when ran on different machines it refuses to connect, and my head-ache is now getting worse by the minute...

Server side:
============
Running inside Netbeans IDE 7.2

GlassFish Server version: 3+
JMS Service Type: LOCAL (instead of EMBEDDED)
Created javax.jms.QueueConnectionFactory named "TapServiceConnectionFactory" under JMS Resources.

Glassfish configuration is otherwise untouched (I've fooled around lots, so created a clean glassfish instance for this example):

Startup log:

Launching GlassFish on Felix platform
INFO: Running GlassFish Version: GlassFish Server Open Source Edition 3.1.2.2 (build 5)
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
INFO: Grizzly Framework 1.9.50 started in: 69ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.50 started in: 21ms - bound to [0.0.0.0:4848]
INFO: Grizzly Framework 1.9.50 started in: 36ms - bound to [0.0.0.0:8181]
INFO: Grizzly Framework 1.9.50 started in: 24ms - bound to [0.0.0.0:3700]
INFO: The Admin Console is already installed, but not yet loaded.
INFO: GlassFish Server Open Source Edition 3.1.2.2 (5) startup time : Felix (3,007ms), startup services(1,486ms), total(4,493ms)
INFO: HV000001: Hibernate Validator 4.3.0.Final
INFO: Grizzly Framework 1.9.50 started in: 12ms - bound to [0.0.0.0:8080]
INFO: JMS010: ADDRESSLIST in setJmsServiceProvider: mq://localhost:7676/
INFO: JMS08: JMS Service Connection URL is : mq://localhost:7676/
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter: Version: 4.5.2 Patch 1 (Build 3-d) Compile: Thu Jun 7 10:46:15 PDT 2012
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter starting: broker is LOCAL, connection mode is TCP
INFO: Grizzly Framework 1.9.50 started in: 11ms - bound to [0.0.0.0:8181]
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter Started:LOCAL
INFO: Created EjbThreadPoolExecutor with thread-core-pool-size 16 thread-max-pool-size 32 thread-keep-alive-seconds 60 thread-queue-capacity 2147483647 allow-core-thread-timeout false
INFO: Initiating Jersey application, version 'Jersey: 1.11.1 03/31/2012 06:49 PM'
INFO: REST00001: Listening to REST requests at context: /management/domain
INFO: The Admin Console is already installed, but not yet loaded.
INFO: The Admin Console is starting. Please wait.
INFO: JMX005: JMXStartupService had Started JMXConnector on JMXService URL service:jmx:rmi://localhost:8686/jndi/rmi://localhost:8686/jmxrmi
INFO: WEB0169: Created HTTP listener [http-listener-1] on host/port [0.0.0.0:8080]
INFO: WEB0169: Created HTTP listener [http-listener-2] on host/port [0.0.0.0:8181]
INFO: WEB0169: Created HTTP listener [admin-listener] on host/port [0.0.0.0:4848]
INFO: WEB0171: Created virtual server [server]
INFO: WEB0171: Created virtual server [__asadmin]
INFO: WEB0172: Virtual server [server] loaded default web module []
INFO: SEC1002: Security Manager is OFF.
INFO: SEC1010: Entering Security Startup Service
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
INFO: SEC1011: Security Service(s) Started Successfully
INFO: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context ''
INFO: WEB0671: Loading application [__admingui] at []
INFO: CORE10010: Loading application __admingui done in 8,732 ms
INFO: The Admin Console application is loaded.


ClientSide:
===========

Simple maven application containing 1 class with a main-method:


import com.sun.enterprise.naming.SerialInitContextFactory;
import java.util.Hashtable;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

/**
* The SimpleClient class sends several messages to a
* destination.
*/
public class SimpleClient {

/**
* Main method.
*/
public static void main(String[] args) {

Context jndiContext = null;
ConnectionFactory connectionFactory = null;
Connection connection = null;
Session session = null;
Queue queue = null;
MessageProducer messageProducer = null;

try
{
Hashtable properties = new Hashtable(2);

properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
properties.put(Context.PROVIDER_URL, "iiop://172.19.1.25:7676"); // vm://localhost:
properties.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
properties.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");


jndiContext = new InitialContext(properties);

connectionFactory = (ConnectionFactory) jndiContext.lookup("TapServiceConnectionFactory");

// Lookup queue
// get MessageProducer
// Send TextMessage
}
catch(Exception ex)
{
System.out.println("Error: " + ex );
}


finally
{
if(connection !=null)
{
try
{
connection.close();
}
catch(JMSException e)
{
System.out.println("Error: " + e );
}
}
}
}
}


POM.XML:

<repositories>
<repository>
<id>Java.Net</id>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>


<dependencies>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.1</version>
<type>jar</type>
</dependency>
</dependencies>


This is what happens if my glassfish server is running and the client is started:

=============
run:
org.omg.CORBA.COMM_FAILURE: FINE: IOP00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 3700 vmcid: OMG minor code: 1 completed: No
at sun.reflect.GeneratedConstructorAccessor27.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:248)
at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:95)TapServiceConnectionFactory
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.handleFullLogging(WrapperGenerator.java:387)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.access$400(WrapperGenerator.java:107)
at com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator$2.invoke(WrapperGenerator.java:511)
at com.sun.corba.ee.spi.orbutil.proxy.CompositeInvocationHandlerImpl.invoke(CompositeInvocationHandlerImpl.java:99)
at $Proxy26.connectFailure(Unknown Source)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:257)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:270)
at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:129)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:223)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:228)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:393)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:130)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNameService(SerialContext.java:1241)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:411)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at nl.tap.service.client.jupiterclientnextgen.SimpleClient.main(SimpleClient.java:71)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection refused: connect
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:339)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:242)
... 14 more
Caused by: java.net.ConnectException: Connection refused: connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:364)
at sun.nio.ch.Net.connect(Net.java:356)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:623)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocketChannel(ORBUtility.java:110)
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:324)
... 15 more
Error: javax.naming.NamingException: Lookup failed for 'TapServiceConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.provider.url=iiop://172.19.1.25:7676, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.provider.url=iiop://172.19.1.25:7676, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is org.omg.CORBA.COMM_FAILURE: FINE: IOP00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 3700 vmcid: OMG minor code: 1 completed: No]]

=============

Also not very sure which port to use, 3700 (JMS) or 7676 (IIOPS), however, I've tried both, but both fail.
I'm out of ideas :/

Edited by: 964095 on Oct 9, 2012 5:33 AM

Comments

IlicAlex
Hi,
TNS_ADMIN used in command prompt is somehow ignored (added comment afterwards: mapped drive used in TNS_ADMIN may not be accessable, use UNC path in TNS_ADMIN instead).
Create TNSNAMES entry through Oracle Net Configuration Assistant.

Test Connection on Linked server must work before any SELECT can work.

To use insert from linked server data change provider options:
Allow inprocess = checked

Restart SQL server windows service and try again.

Best regards,
Alex

Edited by: user4580124 on Dec 15, 2010 1:40 PM

Edited by: user4580124 on Nov 15, 2011 2:56 AM
newbiegal
Thanks Alex. I installed Oracle client 10.2.0.1, created linked server and followed the steps above and it worked. But get the following error for some selects..

SELECT * FROM
testlink..user.table

Invalid data for type "numeric".


I researched on this error that it is fixed in ODAC 10.2.0.2.21. I first installed Oracle client (Oracle10g_client_64bit.zip) and then tried installing ODAC (Oracle 10g Release 2 ODAC 10.2.0.2.21) but get a "runtime error" during the install.. Not sure if I'm missing something...


Please help
IlicAlex
Hi,
Whenever I detect strange behavior of an Oracle installation I first check the paths:
Installation folder and destination paths should not have blanks or empty space characters.
I can tell you for 11g x64 client installation. It does not work if the installation folder contains blank.

Do you have only problem with numeric tables? How about tables with string values only?

Best regards,
Alex
1010089
You get this error because the Oracle data dictionary is case sensitive. Oracle object names are all uppercase by default. The linked-server query must exactly match the case of all referenced Oracle metadata, such as schema and table names. So, the following query works:
SELECT * FROM oradb..SCOTT.DEPT WHERE deptno = 10
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 20 2012
Added on Oct 9 2012
2 comments
7,462 views