RE: JNDI Context Lookup Help

2008-11-18 Thread Mark Aufdencamp
Thanks! You must have been reading my mind about just dumping the whole
JNDI name space to find the proper name.

Question:  Why did my code work in 1.1.1 with the slash after comp:/,
should it have?  Just curious about it.

Is there a documentation area on migrating between Geronimo versions
that a note about this could be added for future reference by others?


Probably another thread here, but I'll drop this in anyway:

It was fairly simple to change my deployment descriptors and get my EAR
to run in G 2.1.3.

I had to modify my geronimo-application.xml (application-1.1 to
application-2.0), and my openejb-jar.xml (openejb-jar-2.1 to
openejb-jar-2.2) for the new name space definition, but my
geronimo-web.xml worked without changing the the namespace from 1.1 to
1.2.  I was pleasantly surprised to have my EJB 2.1 beans deploy as
smoothly as they have.  Once again, is there any documentation
discussing this?

I migrated a couple of Database Pool and Security Realm deployment plans
with the project, but would have to go back and look at them to identify
any differences.

Also, any gotchas when combining EJB 2.1 and EJB 3.0 components in the
same EAR.  I plan on utilizing EJB 3.0 moving forward without migrating
my existing session and entity beans from 2.1 any time soon.

Hope this helps others in the future

Mark

>  Original Message 
> Subject: Re: JNDI Context Lookup Help
> From: "Łukasz_Budnik" <[EMAIL PROTECTED]>
> Date: Tue, November 18, 2008 3:02 am
> To: user@geronimo.apache.org
> 
> 
> Hi Mark,
> 
> I had similar problems with Geronimo 2.1.
> 
> You can check out my simple method for traversing JNDI:
> 
> private void traverse(Context ctx, String path) throws NamingException {
>  // lists all contents of current context
>  NamingEnumeration ne = ctx.listBindings("");
>  while (ne.hasMore()) {
>   Binding b = ne.next();
>   String name = path + "/" + b.getName();
>   // if current object is a context, traverse it
>   if (b.getObject() instanceof Context) {
>traverse((Context) b.getObject(), name);
>   }
>   // otherwise print out object's name and its class
>   else {
>logger.debug(name + " ==> " + b.getClassName());
>   }
>  }
> }
> 
> invoke it like this:
> Context c = new InitialContext();
> traverse(c, "java:comp/env");
> 
> You can read more here:
> http://jee-bpel-soa.blogspot.com/2008/09/traversing-jndi-directory.html
> 
> hope it helps :)
> 
> best regards
> Łukasz
> 
> 2008/11/17 Mark Aufdencamp <[EMAIL PROTECTED]>:
> > Hi All,
> >
> > It's been a while since I had to ask for help from the list, but I hit a
> > snag migrating an application from G-1.1.1 to G-2.1.3.  Specifically,
> > I'm having a problem with a JNDI context lookup inside a
> > ServletContextListener.  I presume this is a problem with the move to a
> > global JNDI namespace in G-1.2 and forward.  I have had the same result
> > in 1.2-beta and 2.1.3.  The Documentation and Google have not helped me
> > here.
> >
> > I'm looking up an  defined in the web.xml:
> >
> > 
> >   web/ContentLocation
> >   java.lang.String
> >   /SomeDirectoryHeirarchyName/
> > 
> >
> >
> > Access code as follows:
> >
> > String contentLocation = null;
> > String contentLocationJNDIName = "java:/comp/env/web/ContentLocation";
> >
> > Context ctx = null;
> > boolean initialContextSuccess = false;
> > try {
> >  ctx = new InitialContext();
> >  initialContextSuccess = true;
> > } catch (NamingException namingException){
> >  namingException.printStackTrace();
> > }
> >
> > if(initialContextSuccess){
> >  try{
> >contentLocation = (String) ctx.lookup(contentLocationJNDIName);
> >  } catch(NamingException namingException){
> > namingException.printStackTrace();
> >  }
> > } else{
> >  // Error Handling
> > }
> >
> >
> > The ctx.lookup() throws a javax.naming.NotContextException:
> > comp/env/web/ContentLocation.
> >
> > Do I need to define Properties for the InitialContext Factory, add
> > something to my geronimo-web.xml plan, or utilize a different JNDI name?
> >
> > Thanks for your help,
> >
> > Mark Aufdencamp
> > [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> >
> >
> >



Re: JNDI Context Lookup Help

2008-11-18 Thread Łukasz Budnik
Hi Mark,

I had similar problems with Geronimo 2.1.

You can check out my simple method for traversing JNDI:

private void traverse(Context ctx, String path) throws NamingException {
 // lists all contents of current context
 NamingEnumeration ne = ctx.listBindings("");
 while (ne.hasMore()) {
  Binding b = ne.next();
  String name = path + "/" + b.getName();
  // if current object is a context, traverse it
  if (b.getObject() instanceof Context) {
   traverse((Context) b.getObject(), name);
  }
  // otherwise print out object's name and its class
  else {
   logger.debug(name + " ==> " + b.getClassName());
  }
 }
}

invoke it like this:
Context c = new InitialContext();
traverse(c, "java:comp/env");

You can read more here:
http://jee-bpel-soa.blogspot.com/2008/09/traversing-jndi-directory.html

hope it helps :)

best regards
Łukasz

2008/11/17 Mark Aufdencamp <[EMAIL PROTECTED]>:
> Hi All,
>
> It's been a while since I had to ask for help from the list, but I hit a
> snag migrating an application from G-1.1.1 to G-2.1.3.  Specifically,
> I'm having a problem with a JNDI context lookup inside a
> ServletContextListener.  I presume this is a problem with the move to a
> global JNDI namespace in G-1.2 and forward.  I have had the same result
> in 1.2-beta and 2.1.3.  The Documentation and Google have not helped me
> here.
>
> I'm looking up an  defined in the web.xml:
>
> 
>   web/ContentLocation
>   java.lang.String
>   /SomeDirectoryHeirarchyName/
> 
>
>
> Access code as follows:
>
> String contentLocation = null;
> String contentLocationJNDIName = "java:/comp/env/web/ContentLocation";
>
> Context ctx = null;
> boolean initialContextSuccess = false;
> try {
>  ctx = new InitialContext();
>  initialContextSuccess = true;
> } catch (NamingException namingException){
>  namingException.printStackTrace();
> }
>
> if(initialContextSuccess){
>  try{
>contentLocation = (String) ctx.lookup(contentLocationJNDIName);
>  } catch(NamingException namingException){
> namingException.printStackTrace();
>  }
> } else{
>  // Error Handling
> }
>
>
> The ctx.lookup() throws a javax.naming.NotContextException:
> comp/env/web/ContentLocation.
>
> Do I need to define Properties for the InitialContext Factory, add
> something to my geronimo-web.xml plan, or utilize a different JNDI name?
>
> Thanks for your help,
>
> Mark Aufdencamp
> [EMAIL PROTECTED]
>
>
>
>
>
>
>
>


RE: JNDI Context Lookup Help

2008-11-17 Thread Mark Aufdencamp
Thanks David,  Worked like a charm!  Guess G got a little more precise
after 1.1.1:)  It's been wrong for the last year, G-1.1.1 must have been
more forgiving.  I bet my definition in geronimo-web.xml was wrong.

>  Original Message 
> Subject: Re: JNDI Context Lookup Help
> From: David Jencks <[EMAIL PROTECTED]>
> Date: Mon, November 17, 2008 3:05 pm
> To: user@geronimo.apache.org
> 
> 
> Shouldn't your name be java:comp/env/web/ContentLocation  (no slash  
> before the comp)?
> 
> thanks
> david jencks
> 
> On Nov 17, 2008, at 11:57 AM, Mark Aufdencamp wrote:
> 
> > Hi All,
> >
> > It's been a while since I had to ask for help from the list, but I  
> > hit a
> > snag migrating an application from G-1.1.1 to G-2.1.3.  Specifically,
> > I'm having a problem with a JNDI context lookup inside a
> > ServletContextListener.  I presume this is a problem with the move  
> > to a
> > global JNDI namespace in G-1.2 and forward.  I have had the same  
> > result
> > in 1.2-beta and 2.1.3.  The Documentation and Google have not helped  
> > me
> > here.
> >
> > I'm looking up an  defined in the web.xml:
> >
> > 
> >   web/ContentLocation
> >   java.lang.String
> >   /SomeDirectoryHeirarchyName/
> > 
> >
> >
> > Access code as follows:
> >
> > String contentLocation = null;
> > String contentLocationJNDIName = "java:/comp/env/web/ContentLocation";
> >
> > Context ctx = null;
> > boolean initialContextSuccess = false;
> > try {
> >  ctx = new InitialContext();
> >  initialContextSuccess = true;
> > } catch (NamingException namingException){
> >  namingException.printStackTrace();
> > }
> >
> > if(initialContextSuccess){
> >  try{
> >contentLocation = (String) ctx.lookup(contentLocationJNDIName);
> >  } catch(NamingException namingException){
> > namingException.printStackTrace();
> >  }
> > } else{
> > // Error Handling
> > }
> >
> >
> > The ctx.lookup() throws a javax.naming.NotContextException:
> > comp/env/web/ContentLocation.
> >
> > Do I need to define Properties for the InitialContext Factory, add
> > something to my geronimo-web.xml plan, or utilize a different JNDI  
> > name?
> >
> > Thanks for your help,
> >
> > Mark Aufdencamp
> > [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> >
> >



Re: JNDI Context Lookup Help

2008-11-17 Thread David Jencks
Shouldn't your name be java:comp/env/web/ContentLocation  (no slash  
before the comp)?


thanks
david jencks

On Nov 17, 2008, at 11:57 AM, Mark Aufdencamp wrote:


Hi All,

It's been a while since I had to ask for help from the list, but I  
hit a

snag migrating an application from G-1.1.1 to G-2.1.3.  Specifically,
I'm having a problem with a JNDI context lookup inside a
ServletContextListener.  I presume this is a problem with the move  
to a
global JNDI namespace in G-1.2 and forward.  I have had the same  
result
in 1.2-beta and 2.1.3.  The Documentation and Google have not helped  
me

here.

I'm looking up an  defined in the web.xml:


  web/ContentLocation
  java.lang.String
  /SomeDirectoryHeirarchyName/



Access code as follows:

String contentLocation = null;
String contentLocationJNDIName = "java:/comp/env/web/ContentLocation";

Context ctx = null;
boolean initialContextSuccess = false;
try {
 ctx = new InitialContext();
 initialContextSuccess = true;
} catch (NamingException namingException){
 namingException.printStackTrace();
}

if(initialContextSuccess){
 try{
   contentLocation = (String) ctx.lookup(contentLocationJNDIName);
 } catch(NamingException namingException){
namingException.printStackTrace();
 }
} else{
// Error Handling
}


The ctx.lookup() throws a javax.naming.NotContextException:
comp/env/web/ContentLocation.

Do I need to define Properties for the InitialContext Factory, add
something to my geronimo-web.xml plan, or utilize a different JNDI  
name?


Thanks for your help,

Mark Aufdencamp
[EMAIL PROTECTED]











JNDI Context Lookup Help

2008-11-17 Thread Mark Aufdencamp
Hi All,

It's been a while since I had to ask for help from the list, but I hit a
snag migrating an application from G-1.1.1 to G-2.1.3.  Specifically,
I'm having a problem with a JNDI context lookup inside a
ServletContextListener.  I presume this is a problem with the move to a
global JNDI namespace in G-1.2 and forward.  I have had the same result
in 1.2-beta and 2.1.3.  The Documentation and Google have not helped me
here.

I'm looking up an  defined in the web.xml:


   web/ContentLocation
   java.lang.String
   /SomeDirectoryHeirarchyName/



Access code as follows:

String contentLocation = null;
String contentLocationJNDIName = "java:/comp/env/web/ContentLocation";

Context ctx = null;
boolean initialContextSuccess = false;
try {
  ctx = new InitialContext();
  initialContextSuccess = true;
} catch (NamingException namingException){
  namingException.printStackTrace();
}

if(initialContextSuccess){
  try{
contentLocation = (String) ctx.lookup(contentLocationJNDIName);
  } catch(NamingException namingException){
 namingException.printStackTrace();
  }
} else{
 // Error Handling
}


The ctx.lookup() throws a javax.naming.NotContextException:
comp/env/web/ContentLocation. 

Do I need to define Properties for the InitialContext Factory, add
something to my geronimo-web.xml plan, or utilize a different JNDI name?

Thanks for your help,

Mark Aufdencamp
[EMAIL PROTECTED]