« Return to Thread: Tomcat - Injection: No such property

Re: Tomcat - Injection: No such property

by David Blevins :: Rate this Message:

Reply to Author | View in Thread


On Apr 2, 2008, at 3:30 PM, klewelling wrote:

>
>
> You may want to try setting the properties as system properties,  
> i.e. java
> ...
> -
> Djava
> .naming
> .factory.initial=org.apache.openejb.client.LocalInitialContextFactory
> -Djava.naming.factory.url.pkgs=org.apache.naming.factory.XXX
>
> or something like that. I think it may be important that openEJB's
> initialContext is the first to start up rather than tomcats. If I  
> have some
> free time I can try to get my setup working with tomcat.

That's definitely true of most third-party JNDI implementations; i.e.  
we should be first as we will delegate to them, whereas they usually  
won't delegate to us.  But for Tomcat specifically, we have some code  
that exports all of our JNDI entries into Tomcat so that there only  
needs to be one JNDI impl controlling the show -- Tomcat's.

Not sure why the EntityManager isn't getting picked up with the beans  
in WEB-INF/lib/ vs WEB-INF/classes/.  We did add some very detailed  
logging around the resolution of EntityManager references specifically  
since 3.0-beta-2 that might help (in the new openejb.war i just put  
up).  Hopefully there'll be something in the log that might illuminate  
what's going on.

-David

> ebaxt wrote:
>>
>> Thank you Kenneth!
>>
>> I have tried to set the properties you talked about, but I don't  
>> really
>> know how to configure it to lookup Tomcat's JNDI context.
>>
>> I have tried this with no luck:
>>
>>        Properties p = new Properties();
>>        p.put(Context.INITIAL_CONTEXT_FACTORY,
>> "org.apache.openejb.client.LocalInitialContextFactory");
>>        p.put(Context.URL_PKG_PREFIXES,  
>> "org.apache.naming.factory.XXX");
>>
>> Do you know how to configure this correctly?
>>
>> Erik
>>
>>
>> klewelling wrote:
>>>
>>> FYI I got the injection to work. When I was putting together a
>>> demonstration the injection started working. The problem has to do  
>>> with
>>> dependencies in the pom.xml. I am not sure if there was something  
>>> extra
>>> causing the problem or perhaps the order of the jars in the  
>>> classpath. I
>>> am uploading an example
>>>
>>> http://www.nabble.com/file/p16421933/injection-example.zip
>>> injection-example.zip
>>>
>>> By the way this example demonstrations embedding openEJB in Jetty.  
>>> The
>>> important piece of the puzzle is in the WAR/pom.xml:
>>>
>>> <plugin>
>>>    <groupId>org.mortbay.jetty</groupId>
>>> <artifactId>maven-jetty-plugin</artifactId>
>>> <configuration>
>>> <scanIntervalSeconds>5</scanIntervalSeconds>
>>> <contextPath>/example</contextPath>
>>> <systemProperties>
>>> <systemProperty>
>>> <name>java.naming.factory.initial</name>
>>> <value>org.apache.openejb.client.LocalInitialContextFactory</
>>> value>
>>> </systemProperty>
>>> <systemProperty>
>>> <name>java.naming.factory.url.pkgs</name>
>>> <value>org.mortbay.naming</value>
>>> </systemProperty>
>>> </systemProperties>
>>> </configuration>
>>> <dependencies>
>>> </dependencies>
>>> </plugin>
>>>
>>>
>>> The system property "java.naming.factory.url.pkgs" is the key.  
>>> From what
>>> I can tell openEJB's IvmContext will attempt to do JNDI lookups  
>>> and if it
>>> fails will look for additional ObjectFactories and delegate to  
>>> them. By
>>> adding the "org.morbay.naming" system property IvmContext finds  
>>> the Jetty
>>> JNDI context. Without this setting the jetty plugin will fail with  
>>> the
>>> error: "javax.naming.NameNotFoundException: Name "java:comp" not  
>>> found."
>>>
>>> It took me a while to figure this out so it may be useful to add  
>>> to the
>>> openEJB docs.
>>>
>>> Hope this helps,
>>> Kenneth
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Tomcat---Injection%3A-No-such-property-tp16374013p16452221.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>

 « Return to Thread: Tomcat - Injection: No such property