Questions tagged [initial-context]

74 questions
14
votes
7 answers

How to fake InitialContext with default constructor

All, I'm trying to do some unit testing in some archaic java code (no interfaces, no abstraction, etc.) This is a servlet that uses a ServletContext (which I'm assuming is set up by Tomcat) and it has database information is set up in the…
Austin
  • 1,521
  • 5
  • 15
  • 27
7
votes
1 answer

Lookup EJB using InitialContext on Weblogic 10.x.x

Could you please tell me how to lookup EJB on Weblogic? I have following bean: @Stateless @EJB(name = "DataAccess", beanInterface = DataAccessLocal.class) public class DataAccess implements DataAccessLocal { ... } I need this bean in other…
kardanov
  • 575
  • 3
  • 13
  • 25
6
votes
0 answers

How to load jndi bindings from within a Storm jar?

We have a project moving to use Storm and as such our code must be packaged in a jar. We had previously used com.sun.jndi.fscontext.RefFSContextFactory as our InitialContextFactory implementation to load the jndicontext bindings from a file in the…
6
votes
1 answer

Programmatically creating a JNDI DataSource for Spring

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…
acvcu
  • 2,476
  • 10
  • 40
  • 56
6
votes
0 answers

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

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…
Dave
  • 15,639
  • 133
  • 442
  • 830
5
votes
1 answer

Initial Context property values for EJB lookup

I am learning basics of EJB 3.0. I have managed to get a sample code up and running. Now I am doing a line by line analysis to have in-depth knowledge. But I am stuck at few lines where there is a lookup to find the required bean. Can anyone please…
h-kach
  • 351
  • 2
  • 8
  • 25
5
votes
0 answers

Create InitialContext from context.xml in plain java application

As the question implies, I have a simple java app (aka a "simple main") that needs to initialize a hibernate connection whose information is in context.xml. After lots of searching and with some hacks from here I concluded to this: public static…
Stelios Adamantidis
  • 1,866
  • 21
  • 36
5
votes
1 answer

Questions on InitialContext and replica-aware stub caching in weblogic 11g

We have a cluster and deployed with some stateless ejb session beans. Currently we only cached the InitialContext object in the client code, and I have several questions: in the current case, if we call lookup() to get a replica-aware stub, which…
4
votes
2 answers

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

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…
JanFo
  • 150
  • 2
  • 9
4
votes
2 answers

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

I have a class like below: public class Poligon { public static void main(String[] args) { try { Context ctx = new InitialContext(); ConnectionFactory connectionFactory = (ConnectionFactory)…
pshemek
  • 1,369
  • 4
  • 17
  • 33
3
votes
2 answers

Which Java Runtime Exception to Use When Missing an InitialContext Definition

I am programming a Java Servlet application which needs certain environment variables and JNDI definitions to be present. These are defined in server.xml file. Using default values is not possible. So the program needs to throw a runtime (unchecked)…
3
votes
3 answers

How can I specifiy the drive letter (windows) for the PROVIDER_URL of the JNDI InitialContext

I am using the com.sun.jndi.fscontext.RefFSContextFactory file based JNDI context factory. It seems to take the drive of the where the java application is started in. Hashtable properties = new…
mrjohn
  • 1,141
  • 2
  • 13
  • 21
3
votes
1 answer

What does multitier means in weblogic server JNDI Lookup

I was checking InitialContext object and properties that are need for JNDI lookup. One of the property which is required for InitialContext is INITIAL_CONTEXT_FACTORY for environment, for weblogic server its value is…
Vishrant
  • 15,456
  • 11
  • 71
  • 120
3
votes
1 answer

Why does Url.OpenConnection() return SoapHttpUrlConnection?

I'm developing an Java application( J2SE ). In my application, I should send a message via a queue( using JDNI of Weblogic ) and then should interact with HTTP web url ( using an URLConnection ). If I try to interact with HTTP web using…
3
votes
1 answer

What is the use of InitialContext in Java EE over mappedName?

I don't understand when someone would use (new InitialContext()).lookup(....) instead of @Stateless(mappedName="A1Global") public class A1 implements A { ... } @EJB(mappedName="A1Global") private A a; does the latter approach with mappedName have…
Vjeetje
  • 5,314
  • 5
  • 35
  • 57
1
2 3 4 5