You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by David Blevins <da...@visi.com> on 2008/04/02 21:12:55 UTC

Re: Eclipse Multiple Projects and Missing persistence.xml

On Mar 30, 2008, at 8:29 PM, Chad and Doria Skinner wrote:
> I have a project I am working on and we have separated our business  
> model from our business logic by placing them into different  
> projects in eclipse. These projects are both jars that are placed in  
> our ear file. When I try to run a test on one of our session beans  
> in the EJB project I keep getting errors that it is missing the  
> persistence.xml file that is in our BusinessLogic project. The code  
> is compiling properly, but the tests will not run until I copy the  
> persistence.xml into the EJB project. Does anyone know if having  
> separate jars for the SessionBeans and entities is supported?

I think there might be an issue with the module getting picked up if  
it only contains a peristence.xml and nothing else.  An alternate  
technique to moving the persistence.xml into the BusinessLogic project  
is to add an empty ejb-jar.xml file to the BusinessModel project  
containing only "<ejb-jar/>"

That should tide you over till we can get this fixed.

-David


Re: Eclipse Multiple Projects and Missing persistence.xml

Posted by uglything <ju...@gmail.com>.
Hi people.

I indeed faced the same problem-->
http://www.nabble.com/Sharing-persistence-unit-among-several-ejb-jars-in-a-collapsed-EAR-to17628307.html
I had a main project containing my application, and a dependent project
containing entities that were to be managed by a persistence unit declared
in the main project.
Using the JUnit test Eclipse facilities led me to your problem, namely the
persistence unit is deployed only for the main project, not for the
depending project.
But my application worked fine when I packaged it as a war and dropped it to
a openEJB enabled Tomcat. This got rid of the classpath problem David points
at.

I suggest you try the same just to ensure that everything else works
correctly.

Anyway, David I'm looking forward to test your new OpenEJB build !

Regards,

Juan Manuel

-- 
View this message in context: http://www.nabble.com/Eclipse-Multiple-Projects-and-Missing-persistence.xml-tp16391627p17793566.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Eclipse Multiple Projects and Missing persistence.xml

Posted by David Blevins <da...@visi.com>.
On Jun 18, 2008, at 11:20 PM, uglything wrote:

>
>
> David Blevins wrote:
>>
>>
>> On Jun 18, 2008, at 12:53 AM, uglything wrote:
>>
>>>
>>> You're the man !
>>
>> Muchas gracias!  Or if my suspicions are correct.  Maraming salamat!
>>
>
> If I don't get things wrong, Maraming salamat is a philippines'  
> expression,
> right ?
> Well, I'm a spanish man in france, as Police would say.

Si, es filipino.  Muchos de ellos tienen nombres espanoles, entonces  
nunca sabes :)  Tenemos un committer en el projecto con el apellido  
"Cabrera" y su padre es filipino, entonces sospeche que tu tambien eras.

Bienvenidos en qualquier forma :)

-David

> David Blevins wrote:
>>
>>
>>> I just have to not use the injection annotations in my servlets and
>>> launchers,
>>> but everything else works as expected.
>>
>> We definitely plan to get a Jetty integration in there that has all
>> the same quality of service that we offer with Tomcat.  It's good to
>> know you'd be interested in that kind of functionality as it helps us
>> prioritize.
>>
>
> Then, for the record, I'm very interested in a Jetty integration.
> That could be time saving for me as I develop with Maven2 + Eclipse
> and Jetty is the logical choice for testing in such environment.
>
>
> David Blevins wrote:
>>
>>
>>> I also tryed a JUnit launch on both my synthetic test application
>>> and my
>>> real application and everything works.
>>>
>>> (my synthetic application is described in
>>> http://www.nabble.com/forum/ViewPost.jtp?post=17628307&framed=y this
>>> post
>>> and
>>> http://www.nabble.com/forum/ViewPost.jtp?post=17666227&framed=y this
>>> other
>>> post
>>> The naming changes for the sake of readibility, but the underlaying
>>> application is the same.
>>> )
>>>
>>>
>>> Thanks a million again. I'm still quite new on the OpenEJB forums
>>> but I'm
>>> **truly amazed** by your quickness at adressing the problems.
>>
>> Thanks.  Part of the secret of OpenEJB is that we try very hard to
>> keep the code "lean" and free from needless architecture and over
>> abstraction.  It has a very direct impact on how fast we can turn
>> things around as there is usually very little standing in our way.
>>
>>
>
> That seems to be a good choice... I think I 'll try to be more  
> pragmatic my
> own.
> I realize now that I am probabily "over concepting" my applications.
> I'll take a thourough look at your code and try to learn some coding
> philosophy :working:
>
>
> David Blevins wrote:
>>
>>
>> And very seriously, we do appreciate the questions.  As well if you
>> have any "wouldn't it be neat if..." types of ideas, definitely let  
>> us
>> know.  Small or big, we'll take em all.  Dare to dream :)
>>
>> -David
>>
>>
>>
>
> I'll sleep more then, and keep you guys posted with the outcomes :-)
>
> Thanks again !
> Regards,
>
> Juan Manuel
> -- 
> View this message in context: http://www.nabble.com/Eclipse-Multiple-Projects-and-Missing-persistence.xml-tp16391627p17998053.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Re: Eclipse Multiple Projects and Missing persistence.xml

Posted by uglything <ju...@gmail.com>.

David Blevins wrote:
> 
> 
> On Jun 18, 2008, at 12:53 AM, uglything wrote:
> 
>>
>> You're the man !
> 
> Muchas gracias!  Or if my suspicions are correct.  Maraming salamat!
> 

If I don't get things wrong, Maraming salamat is a philippines' expression,
right ?
Well, I'm a spanish man in france, as Police would say.


David Blevins wrote:
> 
> 
>> I just have to not use the injection annotations in my servlets and
>> launchers,
>> but everything else works as expected.
> 
> We definitely plan to get a Jetty integration in there that has all  
> the same quality of service that we offer with Tomcat.  It's good to  
> know you'd be interested in that kind of functionality as it helps us  
> prioritize.
> 

Then, for the record, I'm very interested in a Jetty integration.
That could be time saving for me as I develop with Maven2 + Eclipse
and Jetty is the logical choice for testing in such environment.


David Blevins wrote:
> 
> 
>> I also tryed a JUnit launch on both my synthetic test application  
>> and my
>> real application and everything works.
>>
>> (my synthetic application is described in
>> http://www.nabble.com/forum/ViewPost.jtp?post=17628307&framed=y this  
>> post
>> and
>> http://www.nabble.com/forum/ViewPost.jtp?post=17666227&framed=y this  
>> other
>> post
>> The naming changes for the sake of readibility, but the underlaying
>> application is the same.
>> )
>>
>>
>> Thanks a million again. I'm still quite new on the OpenEJB forums  
>> but I'm
>> **truly amazed** by your quickness at adressing the problems.
> 
> Thanks.  Part of the secret of OpenEJB is that we try very hard to  
> keep the code "lean" and free from needless architecture and over  
> abstraction.  It has a very direct impact on how fast we can turn  
> things around as there is usually very little standing in our way.
> 
> 

That seems to be a good choice... I think I 'll try to be more pragmatic my
own.
I realize now that I am probabily "over concepting" my applications.
I'll take a thourough look at your code and try to learn some coding
philosophy :working:


David Blevins wrote:
> 
> 
> And very seriously, we do appreciate the questions.  As well if you  
> have any "wouldn't it be neat if..." types of ideas, definitely let us  
> know.  Small or big, we'll take em all.  Dare to dream :)
> 
> -David
> 
> 
> 

I'll sleep more then, and keep you guys posted with the outcomes :-)

Thanks again !
Regards,

Juan Manuel
-- 
View this message in context: http://www.nabble.com/Eclipse-Multiple-Projects-and-Missing-persistence.xml-tp16391627p17998053.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Eclipse Multiple Projects and Missing persistence.xml

Posted by David Blevins <da...@visi.com>.
On Jun 18, 2008, at 12:53 AM, uglything wrote:

>
> You're the man !

Muchas gracias!  Or if my suspicions are correct.  Maraming salamat!

> I tried your version and all works like a charm.
>
>
>
> I've launched a webapp with Maven2/Jetty6 w/o problems.

Great!

> I just have to not use the injection annotations in my servlets and
> launchers,
> but everything else works as expected.

We definitely plan to get a Jetty integration in there that has all  
the same quality of service that we offer with Tomcat.  It's good to  
know you'd be interested in that kind of functionality as it helps us  
prioritize.

> I also tryed a JUnit launch on both my synthetic test application  
> and my
> real application and everything works.
>
> (my synthetic application is described in
> http://www.nabble.com/forum/ViewPost.jtp?post=17628307&framed=y this  
> post
> and
> http://www.nabble.com/forum/ViewPost.jtp?post=17666227&framed=y this  
> other
> post
> The naming changes for the sake of readibility, but the underlaying
> application is the same.
> )
>
>
> Thanks a million again. I'm still quite new on the OpenEJB forums  
> but I'm
> **truly amazed** by your quickness at adressing the problems.

Thanks.  Part of the secret of OpenEJB is that we try very hard to  
keep the code "lean" and free from needless architecture and over  
abstraction.  It has a very direct impact on how fast we can turn  
things around as there is usually very little standing in our way.

And very seriously, we do appreciate the questions.  As well if you  
have any "wouldn't it be neat if..." types of ideas, definitely let us  
know.  Small or big, we'll take em all.  Dare to dream :)

-David


Re: Eclipse Multiple Projects and Missing persistence.xml

Posted by uglything <ju...@gmail.com>.
You're the man !


I tried your version and all works like a charm.



I've launched a webapp with Maven2/Jetty6 w/o problems.

I just have to not use the injection annotations in my servlets and
launchers,
but everything else works as expected.



I also tryed a JUnit launch on both my synthetic test application and my
real application and everything works.

(my synthetic application is described in
http://www.nabble.com/forum/ViewPost.jtp?post=17628307&framed=y this post 
and
http://www.nabble.com/forum/ViewPost.jtp?post=17666227&framed=y this other
post 
The naming changes for the sake of readibility, but the underlaying
application is the same.
)


Thanks a million again. I'm still quite new on the OpenEJB forums but I'm
**truly amazed** by your quickness at adressing the problems.



Regards,

Juan Manuel

-- 
View this message in context: http://www.nabble.com/Eclipse-Multiple-Projects-and-Missing-persistence.xml-tp16391627p17961537.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Eclipse Multiple Projects and Missing persistence.xml

Posted by David Blevins <da...@visi.com>.
On Jun 11, 2008, at 5:57 PM, David Blevins wrote:

> The crux of the issue is that perfectly valid approach to testing is  
> to treat the entire classpath and all modules in it as essentially  
> one big ear, the things like persistence units declared in other  
> jars will still be considered part of the same "application".   
> Currently we treat every module we find as a separate application  
> which is really not the right technique for some people.
[...]
> I'm going to try and cook up a solution for this and put up some  
> snapshot binaries that you both can try out.

Ok.  I've put something together here and created an example for it.

  http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/ear-testing/

To try it out in your modules update your openejb version to 3.1- 
SNAPSHOT.  This will come out in 3.0.1, just we're running 3.1 on  
trunk at the moment.  Then add openejb.deployments.classpath.ear=true  
this to your startup options as in:

         Properties p = new Properties();
         p.put(Context.INITIAL_CONTEXT_FACTORY,  
"org.apache.openejb.client.LocalInitialContextFactory");
         p.put("openejb.deployments.classpath.ear", "true");  // <-  
new option
         Context context = new InitialContext(p);


One thing that has yet to be fixed is that you still need an ejb- 
jar.xml (or web.xml, etc.) next to your persistence.xml in order for  
it to get picked up.  Will get that fixed as well.

Anyway, let us know if it works out.

-David


Re: Eclipse Multiple Projects and Missing persistence.xml

Posted by David Blevins <da...@visi.com>.
Hi Chad,

This looks like the exact same issue that Juan Manuel is facing.

I'm going to try and cook up a solution for this and put up some  
snapshot binaries that you both can try out.  I'll likely be next week  
before I can get to this, but hopefully it will only take a couple  
days to get something together.

The crux of the issue is that perfectly valid approach to testing is  
to treat the entire classpath and all modules in it as essentially one  
big ear, the things like persistence units declared in other jars will  
still be considered part of the same "application".  Currently we  
treat every module we find as a separate application which is really  
not the right technique for some people.

-David

On Jun 10, 2008, at 1:30 PM, chadws wrote:

>
>
> David Blevins wrote:
>>
>>
>> On Mar 30, 2008, at 8:29 PM, Chad and Doria Skinner wrote:
>>> I have a project I am working on and we have separated our business
>>> model from our business logic by placing them into different
>>> projects in eclipse. These projects are both jars that are placed in
>>> our ear file. When I try to run a test on one of our session beans
>>> in the EJB project I keep getting errors that it is missing the
>>> persistence.xml file that is in our BusinessLogic project. The code
>>> is compiling properly, but the tests will not run until I copy the
>>> persistence.xml into the EJB project. Does anyone know if having
>>> separate jars for the SessionBeans and entities is supported?
>>
>> I think there might be an issue with the module getting picked up if
>> it only contains a peristence.xml and nothing else.  An alternate
>> technique to moving the persistence.xml into the BusinessLogic  
>> project
>> is to add an empty ejb-jar.xml file to the BusinessModel project
>> containing only "<ejb-jar/>"
>>
>> That should tide you over till we can get this fixed.
>>
>> -David
>>
>>
>
> I am getting back to working on this and still have the same  
> problem. My
> projects are configured as:
>
> websiteBusinessLogic - contains Entity Beans
> websiteEJB - contains my EJBs
>
> I have ejb-jar.xml files in the META-INF directories of both  
> projects and my
> my persistence.xml file contains the following:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.0"
> 	xmlns="http://java.sun.com/xml/ns/persistence"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
> 	<persistence-unit name="website" transaction-type="JTA">
> 		<jta-data-source>jdbc/websitedb</jta-data-source>
> 		<non-jta-data-source>jdbc/unmanagedWebsitedb</non-jta-data-source>
>
> 		<class>us.ks.k12.topeka.website.model.Alert</class>
> 		<class>us.ks.k12.topeka.website.model.Announcement</class>
> 		<class>us.ks.k12.topeka.website.model.Entry</class>
> 		<class>us.ks.k12.topeka.website.model.Job</class>
> 		<class>us.ks.k12.topeka.website.model.Location</class>
> 		<class>us.ks.k12.topeka.website.model.NewsEntry</class>
> 		<class>us.ks.k12.topeka.website.model.Preference</class>
> 		<class>us.ks.k12.topeka.website.model.Profile</class>
> 		<class>us.ks.k12.topeka.website.model.Tag</class>
> 		<class>us.ks.k12.topeka.website.model.TagGroup</class>
> 		<class>us.ks.k12.topeka.website.model.TagSearch</class>
>
> 		<properties>
> 		</properties>
> 	</persistence-unit>
> </persistence>
>
> my jUnit test:
>
> 	@Before
> 	public void setup() {
> 		try {
> 			Logger.getRootLogger().setLevel(Level.DEBUG);
> 			
>    		Properties p = new Properties();
>    		p.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
>
>    		p.put("openejb.deployments.classpath.include",
> ".*seamTest/WebsiteBusinessModel/.*");
>   		
>    		p.put("jdbc/websitedb",             "new://Resource? 
> type=DataSource");
>    		p.put("jdbc/websitedb.JdbcUrl",
> "jdbc:mysql://localhost:3306/website");
>    		p.put("jdbc/websitedb.JdbcDriver",  "com.mysql.jdbc.Driver");
>    		p.put("jdbc/websitedb.UserName",    "webuser");
>    		p.put("jdbc/websitedb.Password",    "webpass");
>    		
>    		p.put("jdbc/unmanagedWebsitedb",
> "new://Resource?type=DataSource");
>    		p.put("jdbc/unmanagedWebsitedb.JdbcUrl",
> "jdbc:mysql://localhost:3306/website");
>    		p.put("jdbc/unmanagedWebsitedb.JdbcDriver",   
> "com.mysql.jdbc.Driver");
>    		p.put("jdbc/unmanagedWebsitedb.UserName",    "webuser");
>    		p.put("jdbc/unmanagedWebsitedb.Password",    "webpass");
>    		p.put("jdbc/unmanagedWebsitedb.JtaManaged",  "false");
>
>    		p.put("jdbc/profileDB",             "new://Resource? 
> type=DataSource");
>    		p.put("jdbc/profileDB.JdbcUrl",
> "jdbc:mysql://localhost:3306/website");
>    		p.put("jdbc/profileDB.JdbcDriver",  "com.mysql.jdbc.Driver");
>    		p.put("jdbc/profileDB.UserName",    "webuser");
>    		p.put("jdbc/profileDB.Password",    "webpass");
>    		p.put("jdbc/profileDB.JtaManaged",  "false");
>
>    		p.put("myStatefulContainer", "new://Container?type=STATEFUL");
>    		p.put("myStatefulContainer.PoolSize", "5");
>    		p.put("myStatefulContainer.BulkPassivate", "1");
>
>    		p.put("myStatelessContainer", "new://Container?type=STATELESS");
>    		p.put("myStatelessContainer.PoolSize", "5");
>    		p.put("myStatelessContainer.BulkPassivate", "1");
>
>    		context = new InitialContext(p);
> 		} catch(NamingException e) {
> 			e.printStackTrace();
> 			Assert.fail(e.getMessage());
> 		}
> 	}
> 	
> 	
> 	@Test
> 	public void testProfileSynchronizer() throws Exception {
> 		ProfileSynchronizer lProfileSynchronizer = (ProfileSynchronizer)
> context.lookup("ProfileSynchronizerLocal");
> 		lProfileSynchronizer.updateProfiles();
> 	}
>
> But when I run the test I get the following error:
>
> Apache OpenEJB 3.0    build: 20080408-04:13
> http://openejb.apache.org/
> INFO - openejb.home =
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB
> INFO - openejb.base =
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB
> INFO - Configuring Service(id=Default Security Service,
> type=SecurityService, provider-id=Default Security Service)
> INFO - Configuring Service(id=Default Transaction Manager,
> type=TransactionManager, provider-id=Default Transaction Manager)
> INFO - Configuring Service(id=jdbc/profileDB, type=Resource,
> provider-id=Default JDBC Database)
> INFO - Configuring Service(id=jdbc/websitedb, type=Resource,
> provider-id=Default JDBC Database)
> INFO - Configuring Service(id=jdbc/unmanagedWebsitedb, type=Resource,
> provider-id=Default JDBC Database)
> INFO - Configuring Service(id=Default JDK 1.3 ProxyFactory,
> type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory)
> INFO - Configuring Service(id=myStatelessContainer, type=Container,
> provider-id=Default Stateless Container)
> INFO - Configuring Service(id=myStatefulContainer, type=Container,
> provider-id=Default Stateful Container)
> INFO - Found EjbModule in classpath:
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/ 
> WebsiteBusinessModel/build/classes
> INFO - Found EjbModule in classpath:
> /home/cskinne1/.m2/repository/org/jboss/seam/jboss-seam/2.0.1.GA/ 
> jboss-seam-2.0.1.GA.jar
> INFO - Found EjbModule in classpath:
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/ 
> classes
> INFO - Configuring app:
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/ 
> WebsiteBusinessModel/build/classes
> INFO - Configuring PersistenceUnit(name=website)
> INFO - Loaded Module:
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/ 
> WebsiteBusinessModel/build/classes
> INFO - Configuring app:
> /home/cskinne1/.m2/repository/org/jboss/seam/jboss-seam/2.0.1.GA/ 
> jboss-seam-2.0.1.GA.jar
> INFO - Loaded Module:
> /home/cskinne1/.m2/repository/org/jboss/seam/jboss-seam/2.0.1.GA/ 
> jboss-seam-2.0.1.GA.jar
> INFO - Configuring app:
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/ 
> classes
> INFO - Auto-linking resource-ref 'termsDTA' in bean  
> ProfileSynchronizer to
> Resource(id=jdbc/profileDB)
> ERROR - FAIL ... JobManager:	Missing required persistence.xml for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... ProfileManager:	Missing required persistence.xml for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... ProfileSynchronizer:	Missing required  
> persistence.xml for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... LocationManager:	Missing required persistence.xml for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... AlertManager:	Missing required persistence.xml for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... NewsEntryManager:	Missing required persistence.xml  
> for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... CalendarEntryManager:	Missing required  
> persistence.xml for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... PreferenceManager:	Missing required persistence.xml  
> for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... TagManager:	Missing required persistence.xml for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... TagGroupManager:	Missing required persistence.xml for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... AnnouncementManager:	Missing required  
> persistence.xml for
> @PersistenceContext ref "entityManager" to unit "website"
> ERROR - FAIL ... TagSearchManager:	Missing required persistence.xml  
> for
> @PersistenceContext ref "entityManager" to unit  "website"
> ERROR - Invalid
> EjbModule(path=/home/cskinne1/.eclipse/europa/workspaces/seamTest/ 
> WebsiteEJB/build/classes)
> INFO - Set the 'openejb.validation.output.level' system property to  
> VERBOSE
> for increased validation details.
> WARN - Jar not loaded.
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/ 
> classes.
> Module failed validation.
> AppModule(path=/home/cskinne1/.eclipse/europa/workspaces/seamTest/ 
> WebsiteEJB/build/classes)
> WARN - Property "BulkPassivate" not supported by  
> "myStatelessContainer"
> INFO - Assembling app:
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/ 
> WebsiteBusinessModel/build/classes
> INFO - PersistenceUnit(name=website,
> provider=org.apache.openjpa.persistence.PersistenceProviderImpl)
> ERROR - JAVA AGENT NOT INSTALLED. The JPA Persistence Provider  
> requested
> installation of a ClassFileTransformer which requires a JavaAgent.   
> See
> http://openejb.apache.org/3.0/javaagent.html
> INFO - Deployed
> Application(path=/home/cskinne1/.eclipse/europa/workspaces/seamTest/ 
> WebsiteBusinessModel/build/classes)
> INFO - Assembling app:
> /home/cskinne1/.m2/repository/org/jboss/seam/jboss-seam/2.0.1.GA/ 
> jboss-seam-2.0.1.GA.jar
> INFO - Jndi(name=TimerServiceDispatcherLocal) -->
> Ejb(deployment-id=TimerServiceDispatcher)
> INFO - Jndi(name=EjbSynchronizationsLocal) -->
> Ejb(deployment-id=EjbSynchronizations)
> INFO - Created Ejb(deployment-id=TimerServiceDispatcher,
> ejb-name=TimerServiceDispatcher, container=myStatelessContainer)
> INFO - Created Ejb(deployment-id=EjbSynchronizations,
> ejb-name=EjbSynchronizations, container=myStatefulContainer)
> INFO - Deployed
> Application(path=/home/cskinne1/.m2/repository/org/jboss/seam/jboss- 
> seam/2.0.1.GA/jboss-seam-2.0.1.GA.jar)
>
> If I set the system property - 
> Dopenejb.validation.output.level=VERBOSE I get
> a series of the following error (one per entity).
>
> ERROR - FAIL ... JobManager:	A persistence unit must be defined via
> META-INF/persistence.xml to satisfy @PersistenceContext ref  
> "entityManager"
> to unit "website".  An example of a suitable persistence.xml might
> be:<persistence xmlns="http://java.sun.com/xml/ns/persistence"
> version="1.0"><persistence-unit
> name="website"><jta-data-source>java:openejb/Resource/myDataSource</ 
> jta-data-source><non-jta-data-source>java:openejb/Resource/ 
> myUnmanagedDataSource</non-jta-data-source><properties><property
> name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)"/></properties></persistence- 
> unit></persistence>
>
> One of the things that concerns me is the error:
>
> WARN - Jar not loaded.
> /home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/ 
> classes.
> Module failed validation.
> AppModule(path=/home/cskinne1/.eclipse/europa/workspaces/seamTest/ 
> WebsiteEJB/build/classes)
>
> Does anyone know what I am missing so that I can get this to load my
> entities from one jar and the session beans from a seperate jar.
>
> I don't understand why my jar would not validate and the error does  
> not tell
> me. Are there any other flags that I can set to figure out why the  
> jar is
> not being loaded?
>
> Also, do I need to put anything in my ejb-jar.xml file to register  
> the local
> interfaces for my beans (at this point I don't have any remote beans).
> -- 
> View this message in context: http://www.nabble.com/Eclipse-Multiple-Projects-and-Missing-persistence.xml-tp16391627p17764028.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Re: Eclipse Multiple Projects and Missing persistence.xml

Posted by chadws <cs...@topeka.k12.ks.us>.

David Blevins wrote:
> 
> 
> On Mar 30, 2008, at 8:29 PM, Chad and Doria Skinner wrote:
>> I have a project I am working on and we have separated our business  
>> model from our business logic by placing them into different  
>> projects in eclipse. These projects are both jars that are placed in  
>> our ear file. When I try to run a test on one of our session beans  
>> in the EJB project I keep getting errors that it is missing the  
>> persistence.xml file that is in our BusinessLogic project. The code  
>> is compiling properly, but the tests will not run until I copy the  
>> persistence.xml into the EJB project. Does anyone know if having  
>> separate jars for the SessionBeans and entities is supported?
> 
> I think there might be an issue with the module getting picked up if  
> it only contains a peristence.xml and nothing else.  An alternate  
> technique to moving the persistence.xml into the BusinessLogic project  
> is to add an empty ejb-jar.xml file to the BusinessModel project  
> containing only "<ejb-jar/>"
> 
> That should tide you over till we can get this fixed.
> 
> -David
> 
> 

I am getting back to working on this and still have the same problem. My
projects are configured as:

websiteBusinessLogic - contains Entity Beans
websiteEJB - contains my EJBs

I have ejb-jar.xml files in the META-INF directories of both projects and my
my persistence.xml file contains the following:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
	xmlns="http://java.sun.com/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
	<persistence-unit name="website" transaction-type="JTA">
		<jta-data-source>jdbc/websitedb</jta-data-source>
		<non-jta-data-source>jdbc/unmanagedWebsitedb</non-jta-data-source>

		<class>us.ks.k12.topeka.website.model.Alert</class>
		<class>us.ks.k12.topeka.website.model.Announcement</class>
		<class>us.ks.k12.topeka.website.model.Entry</class>
		<class>us.ks.k12.topeka.website.model.Job</class>
		<class>us.ks.k12.topeka.website.model.Location</class>
		<class>us.ks.k12.topeka.website.model.NewsEntry</class>
		<class>us.ks.k12.topeka.website.model.Preference</class>
		<class>us.ks.k12.topeka.website.model.Profile</class>
		<class>us.ks.k12.topeka.website.model.Tag</class>
		<class>us.ks.k12.topeka.website.model.TagGroup</class>
		<class>us.ks.k12.topeka.website.model.TagSearch</class>

		<properties>
		</properties>
	</persistence-unit>
</persistence>

my jUnit test:

	@Before
	public void setup() {
		try {
			Logger.getRootLogger().setLevel(Level.DEBUG);
			
    		Properties p = new Properties();
    		p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");

    		p.put("openejb.deployments.classpath.include",
".*seamTest/WebsiteBusinessModel/.*");
   		
    		p.put("jdbc/websitedb",             "new://Resource?type=DataSource");
    		p.put("jdbc/websitedb.JdbcUrl",    
"jdbc:mysql://localhost:3306/website");
    		p.put("jdbc/websitedb.JdbcDriver",  "com.mysql.jdbc.Driver");
    		p.put("jdbc/websitedb.UserName",    "webuser");
    		p.put("jdbc/websitedb.Password",    "webpass");
    		
    		p.put("jdbc/unmanagedWebsitedb",            
"new://Resource?type=DataSource");
    		p.put("jdbc/unmanagedWebsitedb.JdbcUrl",    
"jdbc:mysql://localhost:3306/website");
    		p.put("jdbc/unmanagedWebsitedb.JdbcDriver",  "com.mysql.jdbc.Driver");
    		p.put("jdbc/unmanagedWebsitedb.UserName",    "webuser");
    		p.put("jdbc/unmanagedWebsitedb.Password",    "webpass");
    		p.put("jdbc/unmanagedWebsitedb.JtaManaged",  "false");
    
    		p.put("jdbc/profileDB",             "new://Resource?type=DataSource");
    		p.put("jdbc/profileDB.JdbcUrl",    
"jdbc:mysql://localhost:3306/website");
    		p.put("jdbc/profileDB.JdbcDriver",  "com.mysql.jdbc.Driver");
    		p.put("jdbc/profileDB.UserName",    "webuser");
    		p.put("jdbc/profileDB.Password",    "webpass");
    		p.put("jdbc/profileDB.JtaManaged",  "false");
    
    		p.put("myStatefulContainer", "new://Container?type=STATEFUL");
    		p.put("myStatefulContainer.PoolSize", "5");
    		p.put("myStatefulContainer.BulkPassivate", "1");
    
    		p.put("myStatelessContainer", "new://Container?type=STATELESS");
    		p.put("myStatelessContainer.PoolSize", "5");
    		p.put("myStatelessContainer.BulkPassivate", "1");
    
    		context = new InitialContext(p);
		} catch(NamingException e) {
			e.printStackTrace();
			Assert.fail(e.getMessage());
		}
	}
	
	
	@Test
	public void testProfileSynchronizer() throws Exception {
		ProfileSynchronizer lProfileSynchronizer = (ProfileSynchronizer)
context.lookup("ProfileSynchronizerLocal");
		lProfileSynchronizer.updateProfiles();
	}

But when I run the test I get the following error:

Apache OpenEJB 3.0    build: 20080408-04:13
http://openejb.apache.org/
INFO - openejb.home =
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB
INFO - openejb.base =
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=jdbc/profileDB, type=Resource,
provider-id=Default JDBC Database)
INFO - Configuring Service(id=jdbc/websitedb, type=Resource,
provider-id=Default JDBC Database)
INFO - Configuring Service(id=jdbc/unmanagedWebsitedb, type=Resource,
provider-id=Default JDBC Database)
INFO - Configuring Service(id=Default JDK 1.3 ProxyFactory,
type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory)
INFO - Configuring Service(id=myStatelessContainer, type=Container,
provider-id=Default Stateless Container)
INFO - Configuring Service(id=myStatefulContainer, type=Container,
provider-id=Default Stateful Container)
INFO - Found EjbModule in classpath:
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteBusinessModel/build/classes
INFO - Found EjbModule in classpath:
/home/cskinne1/.m2/repository/org/jboss/seam/jboss-seam/2.0.1.GA/jboss-seam-2.0.1.GA.jar
INFO - Found EjbModule in classpath:
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/classes
INFO - Configuring app:
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteBusinessModel/build/classes
INFO - Configuring PersistenceUnit(name=website)
INFO - Loaded Module:
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteBusinessModel/build/classes
INFO - Configuring app:
/home/cskinne1/.m2/repository/org/jboss/seam/jboss-seam/2.0.1.GA/jboss-seam-2.0.1.GA.jar
INFO - Loaded Module:
/home/cskinne1/.m2/repository/org/jboss/seam/jboss-seam/2.0.1.GA/jboss-seam-2.0.1.GA.jar
INFO - Configuring app:
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/classes
INFO - Auto-linking resource-ref 'termsDTA' in bean ProfileSynchronizer to
Resource(id=jdbc/profileDB)
ERROR - FAIL ... JobManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... ProfileManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... ProfileSynchronizer:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... LocationManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... AlertManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... NewsEntryManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... CalendarEntryManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... PreferenceManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... TagManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... TagGroupManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... AnnouncementManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit "website"
ERROR - FAIL ... TagSearchManager:	Missing required persistence.xml for
@PersistenceContext ref "entityManager" to unit  "website"
ERROR - Invalid
EjbModule(path=/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/classes)
INFO - Set the 'openejb.validation.output.level' system property to VERBOSE
for increased validation details.
WARN - Jar not loaded.
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/classes. 
Module failed validation.
AppModule(path=/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/classes)
WARN - Property "BulkPassivate" not supported by "myStatelessContainer"
INFO - Assembling app:
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteBusinessModel/build/classes
INFO - PersistenceUnit(name=website,
provider=org.apache.openjpa.persistence.PersistenceProviderImpl)
ERROR - JAVA AGENT NOT INSTALLED. The JPA Persistence Provider requested
installation of a ClassFileTransformer which requires a JavaAgent.  See
http://openejb.apache.org/3.0/javaagent.html
INFO - Deployed
Application(path=/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteBusinessModel/build/classes)
INFO - Assembling app:
/home/cskinne1/.m2/repository/org/jboss/seam/jboss-seam/2.0.1.GA/jboss-seam-2.0.1.GA.jar
INFO - Jndi(name=TimerServiceDispatcherLocal) -->
Ejb(deployment-id=TimerServiceDispatcher)
INFO - Jndi(name=EjbSynchronizationsLocal) -->
Ejb(deployment-id=EjbSynchronizations)
INFO - Created Ejb(deployment-id=TimerServiceDispatcher,
ejb-name=TimerServiceDispatcher, container=myStatelessContainer)
INFO - Created Ejb(deployment-id=EjbSynchronizations,
ejb-name=EjbSynchronizations, container=myStatefulContainer)
INFO - Deployed
Application(path=/home/cskinne1/.m2/repository/org/jboss/seam/jboss-seam/2.0.1.GA/jboss-seam-2.0.1.GA.jar)

If I set the system property -Dopenejb.validation.output.level=VERBOSE I get
a series of the following error (one per entity).

ERROR - FAIL ... JobManager:	A persistence unit must be defined via
META-INF/persistence.xml to satisfy @PersistenceContext ref "entityManager"
to unit "website".  An example of a suitable persistence.xml might
be:<persistence xmlns="http://java.sun.com/xml/ns/persistence"
version="1.0"><persistence-unit
name="website"><jta-data-source>java:openejb/Resource/myDataSource</jta-data-source><non-jta-data-source>java:openejb/Resource/myUnmanagedDataSource</non-jta-data-source><properties><property
name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/></properties></persistence-unit></persistence>

One of the things that concerns me is the error:

WARN - Jar not loaded.
/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/classes. 
Module failed validation.
AppModule(path=/home/cskinne1/.eclipse/europa/workspaces/seamTest/WebsiteEJB/build/classes)

Does anyone know what I am missing so that I can get this to load my
entities from one jar and the session beans from a seperate jar.

I don't understand why my jar would not validate and the error does not tell
me. Are there any other flags that I can set to figure out why the jar is
not being loaded?

Also, do I need to put anything in my ejb-jar.xml file to register the local
interfaces for my beans (at this point I don't have any remote beans).
-- 
View this message in context: http://www.nabble.com/Eclipse-Multiple-Projects-and-Missing-persistence.xml-tp16391627p17764028.html
Sent from the OpenEJB User mailing list archive at Nabble.com.