initial-context

How to setup JNDI for Glassfish 3.1.2 for a stand-alone client?

二次信任 提交于 2019-12-17 14:18:44
问题 I try to connect from a stand-alone swing client (running in a separate JVM on the client machine) to the Glassfish server. I currently use the following settings from Netbeans and everything works just fine: System.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory"); System.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming"); System.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi

Cannot Lookup from InitialContext Queue that has same name with another Topic

大城市里の小女人 提交于 2019-12-11 23:12:27
问题 This line of code produces an exception Queue queue = (Queue) initialCtx.lookup("sample"); javax.naming.CannotProceedException: Name 'sample' is ambiguous: both a topic and a queue exist at com.tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:715)[tibjms-4.4.3.jar:4.4.3] at com.tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:489)[tibjms-4.4.3.jar:4.4.3] at javax.naming.InitialContext.lookup(InitialContext.java:392)[:1.6.0_45] Background info: I have tried with another

How can I bind lookup with a String

十年热恋 提交于 2019-12-11 19:03:18
问题 My Program is package client; import homeif.HelloWorldHome; import remoteif.HelloWorld; import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import java.awt.image.LookupOp; import java.util.Properties; public class HelloClient { public static void main(String args[]) { try { Context initialContext = new InitialContext(); Object object = initialContext.lookup("myHelloWorld"); HelloWorldHome home = (HelloWorldHome) PortableRemoteObject.narrow

Programmatically creating a JNDI DataSource for Spring

一个人想着一个人 提交于 2019-12-09 17:44:16
问题 I have an existing Spring web-based application that has datasources defined using JNDI, and I'm trying to create a standalone app to use the beans. How can I create the JNDI entry and database properties programmatically in the standalone application? <bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/MyDS" /> </bean> public static void main(String[] args) { // this throws an error since the JNDI lookup fails -

How to solve sun/io/MalformedInputException during JNDI lookup on remote WebSphere

别等时光非礼了梦想. 提交于 2019-12-09 00:40:51
问题 I use WebSphere 8.5 to host my application and configured some JDBC resources on the application server. Also I developed a client application using the thin client runtime library. When the JNDI look-up is performed in the following manner: env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); env.put(Context.PROVIDER_URL, "corbaloc:iiop:serv:2809"); Context initialContext = new InitialContext(env); DataSource ds = (DataSource) initialContext.lookup(

How to get initial context from GlassFish server in Java SE?

风流意气都作罢 提交于 2019-12-06 05:38:30
问题 I have a class like below: public class Poligon { public static void main(String[] args) { try { Context ctx = new InitialContext(); ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("jms/javaee7/ConnectionFactory"); Destination destination = (Destination) ctx.lookup("jms/javaee7/Topic"); JMSContext context = connectionFactory.createContext(); OrderDTO order = context.createConsumer(destination).receiveBody(OrderDTO.class); System.out.println("Order received: " + order); }

How to setup JNDI lookup in a Spring-JUnit test?

烂漫一生 提交于 2019-12-06 01:57:18
问题 I'm using Maven 3.0.3, Spring 3.1.0.RELEASE, and JUnit 4.8.1. How do I create JNDI functionality outside the container (which in my case would be JBoss)? I thought Spring's jndiTemplate would do the trick (from my testApplicationContext.xml file): <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate" lazy-init="true"> <property name="environment"> <props> <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop> <prop key="java.naming.provider.url"

How to get initial context from GlassFish server in Java SE?

◇◆丶佛笑我妖孽 提交于 2019-12-04 12:35:01
I have a class like below: public class Poligon { public static void main(String[] args) { try { Context ctx = new InitialContext(); ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("jms/javaee7/ConnectionFactory"); Destination destination = (Destination) ctx.lookup("jms/javaee7/Topic"); JMSContext context = connectionFactory.createContext(); OrderDTO order = context.createConsumer(destination).receiveBody(OrderDTO.class); System.out.println("Order received: " + order); } catch (NamingException ex) { Logger.getLogger(Poligon.class.getName()).log(Level.SEVERE, null, ex); } }

How to setup JNDI lookup in a Spring-JUnit test?

家住魔仙堡 提交于 2019-12-04 07:26:42
I'm using Maven 3.0.3, Spring 3.1.0.RELEASE, and JUnit 4.8.1. How do I create JNDI functionality outside the container (which in my case would be JBoss)? I thought Spring's jndiTemplate would do the trick (from my testApplicationContext.xml file): <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate" lazy-init="true"> <property name="environment"> <props> <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop> <prop key="java.naming.provider.url">localhost:1099</prop> </props> </property> </bean> ... <!-- Can't change the below code --> <bean

Programmatically creating a JNDI DataSource for Spring

对着背影说爱祢 提交于 2019-12-04 05:48:44
I have an existing Spring web-based application that has datasources defined using JNDI, and I'm trying to create a standalone app to use the beans. How can I create the JNDI entry and database properties programmatically in the standalone application? <bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/MyDS" /> </bean> public static void main(String[] args) { // this throws an error since the JNDI lookup fails - can I programmatically define the database properties here? ClassPathXmlApplicationContext ctx = new