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

Re: Tomcat - Injection: No such property

by JensToerber () :: Rate this Message:

Reply to Author | View in Thread

Hi,

i am facing the same problem in Tomcat 6.0.18. EntityManager does not get injected: "no such property".
Openejb 3.1 works in a test application with EJB-, EntityManager-, DataSource-, javax.Mail.Session-, Queue-injection.

Now i have the situation to port an existing application which uses Spring's org.springframework.jndi.JndiObjectFactoryBean for looking up EJBs.

Ok we could replace that by a ServiceLocator or of course the EJB3-Injection. But to minimize the effort it would be great to get this scenario running.

I have the impression that Spring changes something regarding JNDI, where then Openejb and/or Tomcat have problems.

How about this:
-Djava.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory
-Djava.naming.factory.url.pkgs=org.apache.naming.factory.XXX

What should work? This as system properties on startup of Tomcat?
-Djava.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory
-Djava.naming.factory.url.pkgs=org.apache.naming.factory

Don't get the complete idea here, i am sorry.

I found some entries at Springs JndiObjectFactoryBean regarding Containers and looking up JNDI.
I tried out the following:

<bean id="lookupdataDao" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="java:/openejb/ejb/LookupdataDaoLocal"/>
        <property name="expectedType" value="de.ILookupdataDao"/>
        <property name="jndiEnvironment">
        <props>
            <prop key="java.naming.factory.initial">
                org.apache.openejb.client.LocalInitialContextFactory
            </prop>
        </props>
        </property>
        <property name="lookupOnStartup" value="false"/>
        <property name="proxyInterface" value="de.ILookupdataDao"/>
</bean>

But it did not work either. Also copying the EJBs in WEB-INF\classes instead of WEB-INF\lib as stated here did not work.

EntityManager still not injected.

Any help appreciated.

Thanks in advance.

Best regards,

Jens

David Blevins wrote:
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