I think I’ve understood what you’ve written :) Well the fact is an any resources.json/xml or persistence.xml won’t get picked up by TomEE, I guess TomEE just does’t scan the libs for these files. (I think this is a correct statement :D)
If you need to have different resources.json files for different deployment environments then you should look into profile building. Maven is useful for this, so you could maintain multiple resources.json within the web app project, and in the build process attach the desired resources.json file for the build you want. Milo On 9 Jan 2014, at 16:41, Kay Wrobel <[email protected]> wrote: > So I think I explained my thinking for this in a separate thread where I > asked about pulling out my entities and their facade session beans out of the > web app into a dedicated library. We have multiple databases for this > project. It's actually a much bigger project, but I'm working on a small > dedicated web app for it. There are differences in the table schema between > the various database deployments: > > * My development always has the latest and greatest schema > * Customer 1 is on the oldest database rev and has a few less fields > in some tables > * Customer 2 has a newer version of the database, but not the latest > as I have on my dev machine > > The web app I'm writing is not influenced by these differences, but I am > creating a datalayer for the entire schema (for future project sure to come > soon). This is why I'm trying to keep the entire data layer out in a separate > EJB Project. That way I can include whichever data layer I need to use in my > web app. So during testing, I'm using datalayer1. When we go live against > Customer1's database, I will include datalayer2 instead. And they do point to > different databases on different machines, hence my wish to separate out the > data source definitions into the datalayer EJB project. > > I could ultimately also not include ANY data source definitions and just > define them hard inside tomee.xml. But, I do love the fact that I have these > definitions inside my project and not on a server config file that surely > requires me to ssh to that machine and "vi" the tomee.xml file. > > Hope that makes some sense as to what my motivation is. > > Kay > > On 01/09/2014 10:24 AM, Milo Jaden wrote: >> Hmm, I see you are using the the ejb-jar as a lib, I don’t think TomEE will >> look for resources.json inside a lib jar (Likewise I don’t think it would >> look for the persistence.xml). You would have to have the myejb.jar inside >> webapps within TomEE for resources.json to get picked up. >> >> I don’t see why you want resources.json inside a lib jar anyway. This is a >> configuration file for your current webapps (i.e the jars/wars within the >> apps folder). So basically you have 3 options: >> >> 1) Put the myejb.jar inside the webapps folder >> 2) put the resources.json file inside your web app. >> 3) move the contents of resources.json to tomee.json located in the conf >> folder. >> >> Milo >> >> >> On 9 Jan 2014, at 16:20, Kay Wrobel <[email protected]> wrote: >> >>> Affirmative, Milo. Putting the resources.json file under src/conf on my EJB >>> Project puts it in its final resting place under /META-INF. Here's a >>> snippet of the jar output: >>> >>>> META-INF/ >>>> META-INF/MANIFEST.MF >>>> com/ >>>> com/example/ >>>> com/example/myejb/ >>>> com/example/myejb/datalayer/ >>>> com/example/myejb/datalayer/entity/ >>>> com/example/myejb/datalayer/facade/ >>>> META-INF/beans.xml >>>> META-INF/persistence.xml >>>> *META-INF/resources.json* >>> So that looks good according to your description. >>> >>> So, next is: I've added the EJB project's jar to the web app that calls its >>> beans. That one put the jar under /WEB-INF/lib. As documented here: >>>> WEB-INF/faces-config.xml >>>> WEB-INF/ignore-this-resources.xml >>>> WEB-INF/lib/myfaces-extcdi-bv1-module-api-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-bv1-module-impl-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-core-api-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-core-impl-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-jpa1-module-api-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-jpa1-module-impl-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-jsf20-module-api-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-jsf20-module-impl-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-message-module-api-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-message-module-impl-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-scripting-module-api-1.0.5.jar >>>> WEB-INF/lib/myfaces-extcdi-scripting-module-impl-1.0.5.jar >>>> WEB-INF/lib/primefaces-3.5.jar >>>> WEB-INF/lib/primefaces-mobile-0.9.4.jar >>>> *WEB-INF/lib/myejb.jar* >>> Still, when I deploy the war file, I don't see TomEE picking up the data >>> source definition and creating a data source for it. I see the persistence >>> unit trying to reference the data source name, although the log looks >>> suspicious too: >>>> INFO: Adjusting PersistenceUnit vmi-dal-qsvmi-devPU <jta-data-source> to >>>> Resource ID*'Default JDBC Database' *from 'jdbc/mydb' >>> Which to me sounds like: hey I didn't find that data source you're telling >>> me, so I'm setting it to a default data source. >>> >>> Any more idea before I throw in the towel and get back to the way I had it >>> (resources.xml inside web app)? >>> >>> Thanks. >>> >>> >>> On 01/09/2014 09:45 AM, Milo Jaden wrote: >>>> Well I don’t really know how NetBeans goes about doing things. But >>>> basically you want to end up with an ejb-jar file (let’s call it app.jar) >>>> where the META-INF folder is at the root: >>>> >>>> extract app.jar produces: >>>> >>>> \META-INF\resources.json >>>> \META-INF\persistence.xml >>>> \META-INF\MANIFEST.MF >>>> \com\mycompany\model\MyEntity.class >>>> etc… >>>> >>>> try calling jar -xvf app.jar (after NetBeans creates the jar file) to see >>>> if its creating as above. >>>> >>>> Milo >>>> >>>> >>>> >>>> On 9 Jan 2014, at 15:32, Kay Wrobel <[email protected]> wrote: >>>> >>>>> My persistence.xml looks like that. Thanks. >>>>> >>>>> However, I can't seem to make TomEE pick up the resources.json file. Now, >>>>> I don't have a maven project, just a regular project in NetBeans. I'm >>>>> confused about the location of where to put the file as I don't have >>>>> src/main/resources... I've tried to create a META-INF directory under >>>>> Source Packages (in NetBeans) and put the file there. That didn't work. >>>>> Then I tried to move the json file in the same location as the >>>>> persistence.xml file, which in my case under NetBeans is physically under >>>>> src/conf. That didn't work either. So hmmm... >>>>> >>>>> On 01/09/2014 09:19 AM, Milo Jaden wrote: >>>>>> Well it works without specifying the type for me, so I’m guessing its >>>>>> not needed, not sure if its needed for the resources.xml. >>>>>> >>>>>> Just want to confirm that you have in your persistence.xml a tag of the >>>>>> following: >>>>>> >>>>>> <jta-data-source>MusicPulseDataSource</jta-data-source> >>>>>> >>>>>> (i.e the name of the datasource that you’ve put in the resources.xml) >>>>>> >>>>>> Milo >>>>>> >>>>>> On 9 Jan 2014, at 15:19, Kay Wrobel <[email protected]> wrote: >>>>>> >>>>>>> Milo: thanks for the example. I'm comparing it to the resources.xml >>>>>>> file and notice one difference: there's no resource type (e.g. >>>>>>> javax.sql.DataSource). Is that implied or default? >>>>>>> >>>>>>> On 01/09/2014 08:55 AM, Milo Jaden wrote: >>>>>>>> Hi, >>>>>>>> >>>>>>>> My complete file, resources.json (obviously i changed the login >>>>>>>> details :P): >>>>>>>> >>>>>>>> { >>>>>>>> "resources": { >>>>>>>> "MusicPulseDataSource": { >>>>>>>> "properties": { >>>>>>>> "JdbcDriver": "com.mysql.jdbc.Driver", >>>>>>>> "JdbcUrl": >>>>>>>> "jdbc:mysql://localhost:3306/MYDATABASE", >>>>>>>> "UserName": “db_user", >>>>>>>> "Password": “db_password", >>>>>>>> "JtaManaged": true, >>>>>>>> "MaxActive": 200 >>>>>>>> } >>>>>>>> } >>>>>>>> } >>>>>>>> } >>>>>>>> >>>>>>>> >>>>>>>> Remember to have it in src/main/resources/META-INF/resources.json >>>>>>>> (alongside my persistence.xml) >>>>>>>> >>>>>>>> and my pom.xml packaging is: >>>>>>>> >>>>>>>> <packaging>ejb</packaging> >>>>>>>> >>>>>>>> an ejb jar. >>>>>>>> >>>>>>>> >>>>>>>> Milo >>>>>>>> >>>>>>>> >>>>>>>> On 9 Jan 2014, at 14:53, Kay Wrobel <[email protected]> wrote: >>>>>>>> >>>>>>>>> Interesting. Can you send me a sample of sucha file? Also, any reason >>>>>>>>> why a regular resources.xml doesn't work? >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> >>>>>>>>> Kay >>>>>>>>> >>>>>>>>> >>>>>>>>> On 01/09/2014 05:13 AM, Milo Jaden wrote: >>>>>>>>>> I have a resources.json (same thing as resources.xml) located at >>>>>>>>>> src/resources/META-INF/resources.json in my maven project. My >>>>>>>>>> project is an EJB jar and when running OpenEJB it picks up the >>>>>>>>>> resources.json fine. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 9 Jan 2014, at 06:07, Romain Manni-Bucau <[email protected]> >>>>>>>>>> wrote: >>>>>>>>>> >>>>>>>>>>> Hi >>>>>>>>>>> >>>>>>>>>>> No but we can think to a resources-fragment.xml. the main issue it >>>>>>>>>>> has is >>>>>>>>>>> it add deployment data to lib which are generally not aware of it. >>>>>>>>>>> The idea >>>>>>>>>>> is even the opposite ans uqe ${xxx} for resources values and set it >>>>>>>>>>> as >>>>>>>>>>> system properties >>>>>>>>>>> Le 9 janv. 2014 04:19, "Kay Wrobel" <[email protected]> a écrit : >>>>>>>>>>> >>>>>>>>>>>> Question: Is it possible to put the resources.xml file that >>>>>>>>>>>> defines a data >>>>>>>>>>>> source inside an EJB jar instead of putting it inside a WAR under >>>>>>>>>>>> WEB-INF??? The reason why I'm asking is that it would be very >>>>>>>>>>>> convenient if >>>>>>>>>>>> I could put the data source definition inside the EJB that matches >>>>>>>>>>>> the >>>>>>>>>>>> remote database. >>>>>>>>>>>> >>>>>>>>>>>> The documentation just mentions the WEB-INF location or defining >>>>>>>>>>>> the data >>>>>>>>>>>> source directly on the server inside tomee.xml. >>>>>>>>>>>> >>>>>>>>>>>> Thanks. >>>>>>>>>>>> >>>>>>>>>>>> Kay >>>>>>>>>>>> >
