You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by David Blevins <da...@visi.com> on 2007/08/28 06:45:20 UTC

Fwd: How to confiigure an container managed EntityManger in an embeded server?

If someone wants to try this out and see if they can get something  
working for Paul by tomorrow evening, that'd be fantastic.  I'll pick  
it up tomorrow afternoon otherwise.

The related JIRA is http://issues.apache.org/jira/browse/OPENEJB-360

-David


Begin forwarded message:

> Resent-From: <db...@visi.com>
> From: David Blevins <da...@visi.com>
> Date: August 27, 2007 9:25:18 PM PDT
> To: users@openejb.apache.org
> Subject: Re: How to confiigure an container managed EntityManger in  
> an embeded server?
> Reply-To: users@openejb.apache.org
>
> That looks exactly right.  Let me see if I can whip up a quick  
> example with similar settings and see if we can't figure out what  
> might be going.  We need the example anyway.
>
> -David
>
> On Aug 27, 2007, at 9:00 PM, Paul Spencer wrote:
>
>> David,
>> See below.
>>
>> David Blevins wrote:
>>> On Aug 26, 2007, at 6:44 PM, Paul Spencer wrote:
>>> If you're persistence unit was not found when we attempted to  
>>> resolve  the reference (created via the annotation) during the  
>>> time the bean  as loading, we'd throw one of these which should  
>>> be logged and would  fail your app:
>>>   throw new IllegalArgumentException("Persistence unit " +   
>>> contextInfo.persistenceUnitName + " for persistence-context-ref " +
>>>                         contextInfo.referenceName + " not found");
>>>
>> I am getting this error, but I believe the datasource is defined.
>>
>> Below is my configuration.  Is their something missing?
>>
>> ***
>> * conf/openejb.xml
>> ***
>> ...
>> <Connector id="Default JDBC Database" >
>>     JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
>>     JdbcUrl jdbc:derby:openjpa-database;create=true;
>>     UserName
>>     Password
>> </Connector>
>> ...
>>
>> ***
>> * ArtifactManagerImpl.java
>> ***
>> ...
>> @Stateless
>> public class ArtifactManagerImpl implements ArtifactManager {
>> 	@PersistenceContext(unitName = "myDataSource")
>> 	private EntityManager entityManager;
>>
>> 	public ArtifactManagerImpl() {
>> 	}
>> ...
>>
>> ***
>> * META-INF/persistence.xml
>> ***
>> <persistence>
>>   <persistence-unit name="myDataSource" transaction-type="JTA">
>>     <provider>
>>        org.apache.openjpa.persistence.PersistenceProviderImpl
>>     </provider>
>>     <jta-data-source>
>>       java:openejb/Connector/Default JDBC Database
>>     </jta-data-source>
>>   </persistence-unit>
>> </persistence>
>>
>>> -David
>>
>> Paul Spencer
>>
>
>


Re: Fwd: How to confiigure an container managed EntityManger in an embeded server?

Posted by deniskulik <de...@ukonline.co.uk>.

David Blevins wrote:
> 
> If someone wants to try this out and see if they can get something  
> working for Paul by tomorrow evening, that'd be fantastic.  I'll pick  
> it up tomorrow afternoon otherwise.
> 
> The related JIRA is http://issues.apache.org/jira/browse/OPENEJB-360
> 
> -David
> 
> 
> Begin forwarded message:
> 
>> Resent-From: <db...@visi.com>
>> From: David Blevins <da...@visi.com>
>> Date: August 27, 2007 9:25:18 PM PDT
>> To: users@openejb.apache.org
>> Subject: Re: How to confiigure an container managed EntityManger in  
>> an embeded server?
>> Reply-To: users@openejb.apache.org
>>
>> That looks exactly right.  Let me see if I can whip up a quick  
>> example with similar settings and see if we can't figure out what  
>> might be going.  We need the example anyway.
>>
>> -David
>>
>> On Aug 27, 2007, at 9:00 PM, Paul Spencer wrote:
>>
>>> David,
>>> See below.
>>>
>>> David Blevins wrote:
>>>> On Aug 26, 2007, at 6:44 PM, Paul Spencer wrote:
>>>> If you're persistence unit was not found when we attempted to  
>>>> resolve  the reference (created via the annotation) during the  
>>>> time the bean  as loading, we'd throw one of these which should  
>>>> be logged and would  fail your app:
>>>>   throw new IllegalArgumentException("Persistence unit " +   
>>>> contextInfo.persistenceUnitName + " for persistence-context-ref " +
>>>>                         contextInfo.referenceName + " not found");
>>>>
>>> I am getting this error, but I believe the datasource is defined.
>>>
>>> Below is my configuration.  Is their something missing?
>>>
>>> ***
>>> * conf/openejb.xml
>>> ***
>>> ...
>>> <Connector id="Default JDBC Database" >
>>>     JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
>>>     JdbcUrl jdbc:derby:openjpa-database;create=true;
>>>     UserName
>>>     Password
>>> </Connector>
>>> ...
>>>
>>> ***
>>> * ArtifactManagerImpl.java
>>> ***
>>> ...
>>> @Stateless
>>> public class ArtifactManagerImpl implements ArtifactManager {
>>> 	@PersistenceContext(unitName = "myDataSource")
>>> 	private EntityManager entityManager;
>>>
>>> 	public ArtifactManagerImpl() {
>>> 	}
>>> ...
>>>
>>> ***
>>> * META-INF/persistence.xml
>>> ***
>>> <persistence>
>>>   <persistence-unit name="myDataSource" transaction-type="JTA">
>>>     <provider>
>>>        org.apache.openjpa.persistence.PersistenceProviderImpl
>>>     </provider>
>>>     <jta-data-source>
>>>       java:openejb/Connector/Default JDBC Database
>>>     </jta-data-source>
>>>   </persistence-unit>
>>> </persistence>
>>>
>>>> -David
>>>
>>> Paul Spencer
>>>
>>
>>
> 

I found what the problem is (at list my simulation of the above problem has
been solved sucessfully). When the above configuration is used the following
exception is thrown, which can be found in the log file:

javax.ejb.EJBException: The bean encountered a non-application exception.;
nested exception is: 
	<1.0.0-r561970-r561970 fatal general error>
org.apache.openjpa.persistence.PersistenceException: Cannot create
PoolableConnectionFactory (I/O Error: SSO Failed: Native SSPI library not
loaded. Check the java.library.path system property.)

This means that the url used to connect to the database misses login and
password details, so the jdbc driver may use windows authentication instead
and therefore fails to establish connection to the server.

What needs to be done is to change the url to include the missing details,
for instance:

<openejb>
	<Container
		id="Default CMP Container"
		ctype="CMP_ENTITY">
	</Container>
	<Deployments dir="bin" />
	<Connector id="Default JDBC Database">
		JdbcDriver net.sourceforge.jtds.jdbc.Driver 
		JdbcUrl
jdbc:jtds:sqlserver://localhost:1151/cpds;user=MY_USER_NAME;password=MY_PASSWORD	
	</Connector>
</openejb>

With this in mind I would suggest changing the format of connector
configuration to make it more clear, for example:

<Connector id="Default JDBC Database" >
    <property name="jdbc.driver"
value="org.apache.derby.jdbc.EmbeddedDriver" />
    <property name="jdbc.url"
value="jdbc:derby:openjpa-database;create=true;" />
    <property name="jdbc.login" value="abc"/>
    <property name="jdbc.password" value="xyz"/>
</Connector>

Any thoughts, comments?

Cheers

Denis
-- 
View this message in context: http://www.nabble.com/Fwd%3A-How-to-confiigure-an-container-managed-EntityManger-in-an-embeded-server--tf4339712.html#a12386969
Sent from the OpenEJB Dev mailing list archive at Nabble.com.