JNDI context

2009-05-05 Thread govinda

Thanks all for your valuable answers. I'm a WebSphere user, new to geronimo.
I'm migrating applications from websphere to geronimo. I thought I could
avoid modifying the code with 
Context envContext  = (Context)initContext.lookup("java:comp/env"); . I have
specified "jdbc/LiferayPool" for an example, not seeking help with liferay.


This message was accepted by the d...@geronimo.apache.org mailing list. 
How do I connect to a datasource thru code without context "java:comp/env" 

Context envContext  = (Context)initContext.lookup("java:comp/env"); 

I just want to connect to DB like this 

DataSource ds = (DataSource)initContext.lookup("jdbc/LiferayPool"); 

Is it possible, if so where do I specify java jndi context ("java:comp/env")
outside the code? 

Thanks
 

 Re: JNDI context  
by djencks May 04, 2009; 07:08pm :: Rate this Message:- Use ratings to
moderate (?)

Reply | Reply to Author | Print | View Threaded | Show Only this Message 

This is a user list question.  If you have further questions on this   
subject pleas ask there and only there. 
On May 4, 2009, at 8:19 AM, govinda wrote: 

> 
> How do I connect to a datasource thru code without context   
> "java:comp/env" 
> 
> Context envContext  = (Context)initContext.lookup("java:comp/env"); 
> 
> I just want to connect to DB like this 
> 
> DataSource ds = (DataSource)initContext.lookup("jdbc/LiferayPool"); 

Any such jndi name is going to be container specific.  The java:comp/   
stuff is there specifically so you can use the same jndi name in every   
container, so you don't have to recompile your app for every container. 

For information on the geronimo absolute jndi names, see
http://cwiki.apache.org/GMOxDOC21/jndi.html

Basically what you should do is deploy your datasource, restart   
geronimo, and look in var/log/geronimo.log for the log message telling   
you what the jndi location is. 

> 
> 
> Is it possible, if so where do I specify java jndi context   
> ("java:comp/env") 
> outside the code? 

As far as I understand what you are asking for in this sentence, it is   
not possible. 

thanks 
david jencks 
> 
> 
> Thanks 
> -- 
> View this message in context:
> http://www.nabble.com/JNDI-context-tp23370580s134p23370580.html
> Sent from the Apache Geronimo - Dev mailing list archive at   
> Nabble.com. 
> 

 

 Re: JNDI context  
by Jack Cai May 04, 2009; 10:59pm :: Rate this Message:- Use ratings to
moderate (?)

Reply | Reply to Author | Print | View Threaded | Show Only this Message 

What's your real purpose behind this (not specifying "java:comp/env")? 

If it is just that you hate this string, you can use the "@Resource"
annotation to inject the datasource in container-managed artifacts (Servlet,
EJB, etc.).
@Resource (name="jdbc/LiferayPool")
private DataSource ds;

-Jack


2009/5/5 David Jencks 

This is a user list question.  If you have further questions on this subject
pleas ask there and only there.

On May 4, 2009, at 8:19 AM, govinda wrote:



How do I connect to a datasource thru code without context "java:comp/env"

Context envContext  = (Context)initContext.lookup("java:comp/env");

I just want to connect to DB like this

DataSource ds = (DataSource)initContext.lookup("jdbc/LiferayPool");



Any such jndi name is going to be container specific.  The java:comp/ stuff
is there specifically so you can use the same jndi name in every container,
so you don't have to recompile your app for every container.

For information on the geronimo absolute jndi names, see
http://cwiki.apache.org/GMOxDOC21/jndi.html

Basically what you should do is deploy your datasource, restart geronimo,
and look in var/log/geronimo.log for the log message telling you what the
jndi location is.





Is it possible, if so where do I specify java jndi context ("java:comp/env")
outside the code?



As far as I understand what you are asking for in this sentence, it is not
possible.

thanks
david jencks




Thanks
-- 
View this message in context:
http://www.nabble.com/JNDI-context-tp23370580s134p23370580.html
Sent from the Apache Geronimo - Dev mailing list archive at Nabble.com.





 

 Re: JNDI context  
by Peter Petersson-2 May 05, 2009; 03:10am :: Rate this Message:- Use
ratings to moderate (?)

Reply | Reply to Author | Print | View Threaded | Show Only this Message 

govinda wrote: 
> How do I connect to a datasource thru code without context "java:comp/env" 
> 
> Context envContext  = (Context)initContext.lookup("java:comp/env"); 
> 
> I just want to connect to DB like this 
> 
> DataSource ds = (DataSource)initContext.lookup("jdbc/Life

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]









Re: ClassCastException while using the gloabl JNDI Context

2007-11-27 Thread Jacek Laskowski
On Nov 27, 2007 9:42 AM, Jochen Zink <[EMAIL PROTECTED]> wrote:

> I deployed a new Configuration which contains the jar file with RolleDTO 
> inside. Both WebApplications becomes a dependency to this configuration and 
> not to the jar File direct. After this, everythink is working!

Could you show the plans you used to deploy the apps?

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl


Re: ClassCastException while using the gloabl JNDI Context

2007-11-27 Thread Jochen Zink
Thanks a lot for the helpful answer! It works like David descriped.

I deployed a new Configuration which contains the jar file with RolleDTO 
inside. Both WebApplications becomes a dependency to this configuration and not 
to the jar File direct. After this, everythink is working!

Thanks a lot!

Regards
Jochen


> -Ursprüngliche Nachricht-
> Von: user@geronimo.apache.org
> Gesendet: 26.11.07 22:12:22
> An: user@geronimo.apache.org
> Betreff: Re: ClassCastException while using the gloabl JNDI Context


> 
> 
> On Nov 26, 2007, at 1:01 PM, Jacek Laskowski wrote:
> 
> > On Nov 26, 2007 9:50 PM, David Jencks <[EMAIL PROTECTED]> wrote:
> >
> >> Not exactly.  I interpreted the original message is indicating this
> >> is what was already tried and didn't work.  Instead I was suggesting
> >> creating a new 3rd configuration that only has dependencies to create
> >> a classloader with the needed jar that can be used as a parent
> >> classloader for both of the web apps.  Of course I may have
> >> misinterpreted both the original post and your question :-)
> >
> > I was mistaken and when I had sent the email I realized I made the
> > mistake. Sorry for confusion.
> >
> > As to the user's question, you're right - a parent configuration is
> > the solution. Where could I find sample configuration I could borrow
> > the idea from?
> 
> jee-specs?
> 
> I haven't been tracking what's in the console or eclipse plugin but  
> it seems to me that we could really use a wizard that helps you set  
> up the classloader for a module -- so you can specify the parent  
> configurations and jars that go in the classloader.  This could be  
> used for either setting up an app plan with additional classes or for  
> setting up a shared classloader such as is needed here.  Do we  
> already have something like this?
> 
> thanks
> david jencks
> 
> >
> > Jacek
> >
> > -- 
> > Jacek Laskowski
> > http://www.JacekLaskowski.pl
> 
> 


___
Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate
kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=00



Re: ClassCastException while using the gloabl JNDI Context

2007-11-26 Thread David Jencks


On Nov 26, 2007, at 1:01 PM, Jacek Laskowski wrote:


On Nov 26, 2007 9:50 PM, David Jencks <[EMAIL PROTECTED]> wrote:


Not exactly.  I interpreted the original message is indicating this
is what was already tried and didn't work.  Instead I was suggesting
creating a new 3rd configuration that only has dependencies to create
a classloader with the needed jar that can be used as a parent
classloader for both of the web apps.  Of course I may have
misinterpreted both the original post and your question :-)


I was mistaken and when I had sent the email I realized I made the
mistake. Sorry for confusion.

As to the user's question, you're right - a parent configuration is
the solution. Where could I find sample configuration I could borrow
the idea from?


jee-specs?

I haven't been tracking what's in the console or eclipse plugin but  
it seems to me that we could really use a wizard that helps you set  
up the classloader for a module -- so you can specify the parent  
configurations and jars that go in the classloader.  This could be  
used for either setting up an app plan with additional classes or for  
setting up a shared classloader such as is needed here.  Do we  
already have something like this?


thanks
david jencks



Jacek

--
Jacek Laskowski
http://www.JacekLaskowski.pl




Re: ClassCastException while using the gloabl JNDI Context

2007-11-26 Thread Jacek Laskowski
On Nov 26, 2007 9:50 PM, David Jencks <[EMAIL PROTECTED]> wrote:

> Not exactly.  I interpreted the original message is indicating this
> is what was already tried and didn't work.  Instead I was suggesting
> creating a new 3rd configuration that only has dependencies to create
> a classloader with the needed jar that can be used as a parent
> classloader for both of the web apps.  Of course I may have
> misinterpreted both the original post and your question :-)

I was mistaken and when I had sent the email I realized I made the
mistake. Sorry for confusion.

As to the user's question, you're right - a parent configuration is
the solution. Where could I find sample configuration I could borrow
the idea from?

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl


Re: ClassCastException while using the gloabl JNDI Context

2007-11-26 Thread David Jencks


On Nov 26, 2007, at 12:17 PM, Jacek Laskowski wrote:


On Nov 26, 2007 6:35 PM, David Jencks <[EMAIL PROTECTED]> wrote:


1.  create a configuration with (only) that common jar as a
dependency, and have a dependency on this configuration in both  
web apps


Hi Dave,

(This is my second question for you so consider today as a question  
day ;-))


Am I correct that you suggested to install-file the dependency to
Geronimo's repo and declare it as a dependency in these webapps?


Not exactly.  I interpreted the original message is indicating this  
is what was already tried and didn't work.  Instead I was suggesting  
creating a new 3rd configuration that only has dependencies to create  
a classloader with the needed jar that can be used as a parent  
classloader for both of the web apps.  Of course I may have  
misinterpreted both the original post and your question :-)


thanks
david jencks



Jacek

--
Jacek Laskowski
http://www.JacekLaskowski.pl




Re: ClassCastException while using the gloabl JNDI Context

2007-11-26 Thread Jacek Laskowski
On Nov 26, 2007 6:35 PM, David Jencks <[EMAIL PROTECTED]> wrote:

> 1.  create a configuration with (only) that common jar as a
> dependency, and have a dependency on this configuration in both web apps

Hi Dave,

(This is my second question for you so consider today as a question day ;-))

Am I correct that you suggested to install-file the dependency to
Geronimo's repo and declare it as a dependency in these webapps?

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl


Re: ClassCastException while using the gloabl JNDI Context

2007-11-26 Thread David Jencks
Right now your configuration loads the same jar into each of the web  
app classloaders, so the classes are different (same bytes, different  
classloaders).  You need to get the common jar into a shared  
classloader.  Some ways to do this are:


1.  create a configuration with (only) that common jar as a  
dependency, and have a dependency on this configuration in both web apps

2. make one web app depend on the other one
3. use the shared-lib feature (I don't recommend this)

thanks
david jencks

On Nov 26, 2007, at 6:33 AM, Jochen Zink wrote:


Hello,

I try to put a Javaobjekt to the global JNDI Context, and access  
this Objekt from different Applications.


A WebApplication (named webAppA) deployed as standalone WAR File,  
puts an Object to the global JNDI Context:

InitialContext ic = new InitialContext();
Context namingContext = (Context) ic.lookup("ger:");
RolleDTO objectToBind = new RolleDTO();
namingContext.bind( "myObject" , objectToBind);

Another WebApplication (named webAppB) deployed as WAR File inside  
an EAR File, trys to access the Object with name myObject:


InitialContext ic = new InitialContext();
Context context = (Context) ic.lookup("ger:");
RolleDTO rolle = (RolleDTO) context.lookup("myObject ");

The Result is the follwoing ClassCastException.

Both Webapplications uses a common lib, which contains the RolleDTO  
class, and both has a dependency entry in geronimo-web.xml to this  
Library. This lib only exists as common lib. No local versions are  
placed inside the war files or inside the ear file.


I’m using Geronimo 2.0.1. Has anyone an idea what is going wrong?

Thanks a lot
Jochen

javax.naming.NameNotFoundException: com.accumio.ae.Test
	at org.apache.xbean.naming.context.AbstractContext.lookup 
(AbstractContext.java:163)
	at org.apache.xbean.naming.context.AbstractContext.lookup 
(AbstractContext.java:597)
	at com.accumio.ae.jobtrigger.TriggerServlet.init 
(TriggerServlet.java:58)
	at org.apache.catalina.core.StandardWrapper.loadServlet 
(StandardWrapper.java:1053)
	at org.apache.catalina.core.StandardWrapper.load 
(StandardWrapper.java:955)
	at org.apache.catalina.core.StandardContext.loadOnStartup 
(StandardContext.java:4035)
	at org.apache.catalina.core.StandardContext.start 
(StandardContext.java:4338)
	at org.apache.geronimo.tomcat.GeronimoStandardContext.access$201 
(GeronimoStandardContext.java:60)
	at org.apache.geronimo.tomcat.GeronimoStandardContext 
$SystemMethodValve.invoke(GeronimoStandardContext.java:343)
	at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke 
(GeronimoBeforeAfterValve.java:47)
	at org.apache.geronimo.tomcat.GeronimoStandardContext.start 
(GeronimoStandardContext.java:196)
	at org.apache.catalina.core.ContainerBase.addChildInternal 
(ContainerBase.java:791)
	at org.apache.catalina.core.ContainerBase.addChild 
(ContainerBase.java:771)
	at org.apache.catalina.core.StandardHost.addChild 
(StandardHost.java:525)
	at org.apache.geronimo.tomcat.TomcatContainer.addContext 
(TomcatContainer.java:355)
	at org.apache.geronimo.tomcat.TomcatContainer$$FastClassByCGLIB$ 
$9370b073.invoke()

at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
	at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke 
(FastMethodInvoker.java:38)
	at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke 
(GBeanOperation.java:124)
	at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke 
(GBeanInstance.java:830)
	at org.apache.geronimo.gbean.runtime.RawInvoker.invoke 
(RawInvoker.java:57)
	at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke 
(RawOperationInvoker.java:35)
	at  
org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept 
(ProxyMethodInterceptor.java:96)
	at org.apache.geronimo.tomcat.TomcatContainer$$EnhancerByCGLIB$ 
$34b6a2f8.addContext()
	at org.apache.geronimo.tomcat.TomcatWebAppContext.doStart 
(TomcatWebAppContext.java:524)
	at org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance 
(GBeanInstance.java:996)
	at  
org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart( 
GBeanInstanceState.java:268)
	at org.apache.geronimo.gbean.runtime.GBeanInstanceState.start 
(GBeanInstanceState.java:102)
	at org.apache.geronimo.gbean.runtime.GBeanInstance.start 
(GBeanInstance.java:539)
	at  
org.apache.geronimo.gbean.runtime.GBeanDependency.attemptFullStart 
(GBeanDependency.java:111)
	at org.apache.geronimo.gbean.runtime.GBeanDependency.addTarget 
(GBeanDependency.java:146)
	at org.apache.geronimo.gbean.runtime.GBeanDependency$1.running 
(GBeanDependency.java:120)
	at  
org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.fireRunningEven 
t(BasicLifecycleMonitor.java:176)
	at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.access 
$300(BasicLifecycleMonitor.java:44)
	at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor 
$RawLifecycleBroadcaster.fireRunningEvent 
(BasicLifecycleMonitor.java:254)
	at  
org.apache.geronimo.gbea

Re: ClassCastException while using the gloabl JNDI Context

2007-11-26 Thread Jochen Zink
Thank you for your answer.

Sure, the classloaders must be different. The first Webapp is a standalone 
Webapplication and the second (the one which makes the lookup) is inside an ear.

I added the System.outs. you want and I get the following output:

>>> RolleDTO's classloader 
>>> [org.apache.geronimo.kernel.classloader.JarFileClassLoader 
>>> id=com.accumio.ae/ear/1.0/ear]
>>> RolleDTO's from JNDI classloader 
>>> [org.apache.geronimo.kernel.classloader.JarFileClassLoader 
>>> id=com.accumio.ae.LieferantenVerwaltung/Webapp/1.0/car]

Here is the geronimo-web.xml from the Webapplication which puts the RolleDTO to 
JNDI:
http://geronimo.apache.org/xml/ns/j2ee/web-1.1";
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1";>
http://geronimo.apache.org/xml/ns/deployment-1.1";>


com.accumio.ae.LieferantenVerwaltung
Webapp
1.0
car



com.accumio.ae
AE-Base
1.0
jar
   

com.accumio.ae
pushAEConnectionPool
   

com.accumio.ae
bev2DataSource



   


/lieferantenverwaltung

jdbc/pushAEConnectionPool
pushAEConnectionPool
 

jdbc/BEVPooledDS
bev2DataSource



The relevant dependency is

  com.accumio.ae
  AE-Base
  1.0
  jar
   


And the deployment plan of the Webapplication which trys to lookup the RolleDTO 
Object:
http://geronimo.apache.org/xml/ns/j2ee/web-1.1";
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1";>
http://geronimo.apache.org/xml/ns/deployment-1.1";>

com.accumio.ae.JobTrigger
Webapp
1.0
car



com.accumio.ae
AE-Base
1.0
jar
   

com.accumio.ae
pushAEConnectionPool



   


/pushaetrigger

jdbc/pushAEConnectionPool
pushAEConnectionPool




Thanks a lot!

Regards!
Jochen

> -Ursprüngliche Nachricht-
> Von: user@geronimo.apache.org
> Gesendet: 26.11.07 15:54:28
> An: user@geronimo.apache.org
> Betreff: Re: ClassCastException while using the gloabl JNDI Context


> 
> On Nov 26, 2007 3:33 PM, Jochen Zink <[EMAIL PROTECTED]> wrote:
> 
> > InitialContext ic = new InitialContext();
> > Context context = (Context) ic.lookup("ger:");
> > RolleDTO rolle = (RolleDTO) context.lookup("myObject ");
> >
> > The Result is the follwoing ClassCastException.
> 
> Could you do the following in your code so it gets easier to track it
> down (writting it from the top off my head - sorry for typos):
> 
> InitialContext ic = new InitialContext();
> Context context = (Context) ic.lookup("ger:");
> System.out.println(">>> RolleDTO's classloader" +
> RolleDTO.class.getClassLoader());
> Object myObj = context.lookup("myObject ");
> System.out.println(">>> RolleDTO from JNDI's classloader" +
> myObj.getClass().getClassLoader());
> 
> They're surely different. Could you attach geronimo plans for the
> webapp and the ear?
> 
> Jacek
> 
> -- 
> Jacek Laskowski
> http://www.JacekLaskowski.pl
> 


_
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=0066



Re: ClassCastException while using the gloabl JNDI Context

2007-11-26 Thread Jacek Laskowski
On Nov 26, 2007 3:33 PM, Jochen Zink <[EMAIL PROTECTED]> wrote:

> InitialContext ic = new InitialContext();
> Context context = (Context) ic.lookup("ger:");
> RolleDTO rolle = (RolleDTO) context.lookup("myObject ");
>
> The Result is the follwoing ClassCastException.

Could you do the following in your code so it gets easier to track it
down (writting it from the top off my head - sorry for typos):

InitialContext ic = new InitialContext();
Context context = (Context) ic.lookup("ger:");
System.out.println(">>> RolleDTO's classloader" +
RolleDTO.class.getClassLoader());
Object myObj = context.lookup("myObject ");
System.out.println(">>> RolleDTO from JNDI's classloader" +
myObj.getClass().getClassLoader());

They're surely different. Could you attach geronimo plans for the
webapp and the ear?

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl


Re: ClassCastException while using the gloabl JNDI Context

2007-11-26 Thread Jochen Zink
 
org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
at 
org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
at 
org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
at 
org.apache.geronimo.gbean.GBeanLifecycle$$EnhancerByCGLIB$$4c0db839.startConfiguration()
at 
org.apache.geronimo.deployment.plugin.local.StartCommand.run(StartCommand.java:67)
at java.lang.Thread.run(Thread.java:619)


> 
> Hello,
> 
> I try to put a Javaobjekt to the global JNDI Context, and access this Objekt 
> from different Applications.
> 
> A WebApplication (named webAppA) deployed as standalone WAR File, puts an 
> Object to the global JNDI Context:
> InitialContext ic = new InitialContext();
> Context namingContext = (Context) ic.lookup("ger:");
> RolleDTO objectToBind = new RolleDTO();
> namingContext.bind( "myObject" , objectToBind);
> 
> Another WebApplication (named webAppB) deployed as WAR File inside an EAR 
> File, trys to access the Object with name myObject:
> 
> InitialContext ic = new InitialContext();
> Context context = (Context) ic.lookup("ger:");
> RolleDTO rolle = (RolleDTO) context.lookup("myObject ");
> 
> The Result is the follwoing ClassCastException.
> 
> Both Webapplications uses a common lib, which contains the RolleDTO class, 
> and both has a dependency entry in geronimo-web.xml to this Library. This lib 
> only exists as common lib. No local versions are placed inside the war files 
> or inside the ear file.
> 
> I’m using Geronimo 2.0.1. Has anyone an idea what is going wrong?
> 
> Thanks a lot
> Jochen
> 
> javax.naming.NameNotFoundException: com.accumio.ae.Test
>   at 
> org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:163)
>   at 
> org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:597)
>   at com.accumio.ae.jobtrigger.TriggerServlet.init(TriggerServlet.java:58)
>   at 
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1053)
>   at 
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:955)
>   at 
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4035)
>   at 
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4338)
>   at 
> org.apache.geronimo.tomcat.GeronimoStandardContext.access$201(GeronimoStandardContext.java:60)
>   at 
> org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:343)
>   at 
> org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
>   at 
> org.apache.geronimo.tomcat.GeronimoStandardContext.start(GeronimoStandardContext.java:196)
>   at 
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
>   at 
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
>   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
>   at 
> org.apache.geronimo.tomcat.TomcatContainer.addContext(TomcatContainer.java:355)
>   at 
> org.apache.geronimo.tomcat.TomcatContainer$$FastClassByCGLIB$$9370b073.invoke()
>   at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>   at 
> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
>   at 
> org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:124)
>   at 
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:830)
>   at 
> org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
>   at 
> org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
>   at 
> org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
>   at 
> org.apache.geronimo.tomcat.TomcatContainer$$EnhancerByCGLIB$$34b6a2f8.addContext()
>   at 
> org.apache.geronimo.tomcat.TomcatWebAppContext.doStart(TomcatWebAppContext.java:524)
>   at 
> org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(GBeanInstance.java:996)
>   at 
> org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInstanceState.java:268)
>   at 
> org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.java:102)
>   at 
> org.apache.geronimo.gbean.runtime.GBeanInstance.start(GBeanInstance.java:539)
>   at 
> org.apache.geronimo.gbean.runtime.GBeanDependency.attemptFullStart(GBeanDependency.java:111)
>   at 
>

ClassCastException while using the gloabl JNDI Context

2007-11-26 Thread Jochen Zink
Hello,

I try to put a Javaobjekt to the global JNDI Context, and access this Objekt 
from different Applications.

A WebApplication (named webAppA) deployed as standalone WAR File, puts an 
Object to the global JNDI Context:
InitialContext ic = new InitialContext();
Context namingContext = (Context) ic.lookup("ger:");
RolleDTO objectToBind = new RolleDTO();
namingContext.bind( "myObject" , objectToBind);

Another WebApplication (named webAppB) deployed as WAR File inside an EAR File, 
trys to access the Object with name myObject:

InitialContext ic = new InitialContext();
Context context = (Context) ic.lookup("ger:");
RolleDTO rolle = (RolleDTO) context.lookup("myObject ");

The Result is the follwoing ClassCastException.

Both Webapplications uses a common lib, which contains the RolleDTO class, and 
both has a dependency entry in geronimo-web.xml to this Library. This lib only 
exists as common lib. No local versions are placed inside the war files or 
inside the ear file.

I’m using Geronimo 2.0.1. Has anyone an idea what is going wrong?

Thanks a lot
Jochen

javax.naming.NameNotFoundException: com.accumio.ae.Test
at 
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:163)
at 
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:597)
at com.accumio.ae.jobtrigger.TriggerServlet.init(TriggerServlet.java:58)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1053)
at 
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:955)
at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4035)
at 
org.apache.catalina.core.StandardContext.start(StandardContext.java:4338)
at 
org.apache.geronimo.tomcat.GeronimoStandardContext.access$201(GeronimoStandardContext.java:60)
at 
org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:343)
at 
org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
at 
org.apache.geronimo.tomcat.GeronimoStandardContext.start(GeronimoStandardContext.java:196)
at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at 
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at 
org.apache.geronimo.tomcat.TomcatContainer.addContext(TomcatContainer.java:355)
at 
org.apache.geronimo.tomcat.TomcatContainer$$FastClassByCGLIB$$9370b073.invoke()
at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
at 
org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
at 
org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:124)
at 
org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:830)
at 
org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
at 
org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
at 
org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
at 
org.apache.geronimo.tomcat.TomcatContainer$$EnhancerByCGLIB$$34b6a2f8.addContext()
at 
org.apache.geronimo.tomcat.TomcatWebAppContext.doStart(TomcatWebAppContext.java:524)
at 
org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(GBeanInstance.java:996)
at 
org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInstanceState.java:268)
at 
org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.java:102)
at 
org.apache.geronimo.gbean.runtime.GBeanInstance.start(GBeanInstance.java:539)
at 
org.apache.geronimo.gbean.runtime.GBeanDependency.attemptFullStart(GBeanDependency.java:111)
at 
org.apache.geronimo.gbean.runtime.GBeanDependency.addTarget(GBeanDependency.java:146)
at 
org.apache.geronimo.gbean.runtime.GBeanDependency$1.running(GBeanDependency.java:120)
at 
org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.fireRunningEvent(BasicLifecycleMonitor.java:176)
at 
org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.access$300(BasicLifecycleMonitor.java:44)
at 
org.apache.geronimo.kernel.basic.BasicLifecycleMonitor$RawLifecycleBroadcaster.fireRunningEvent(BasicLifecycleMonitor.java:254)
at 
org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInstanceState.java:294)
at 
org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.java:102)
at 
org.apache.geronimo.gbean.runtime.GBeanInstanceState.startRecursive(GBeanInstanceState.java:124)
at 
org.apache.geronimo.gbean.runtime.GBeanInstance.startRecu