i created a Java EE 5 Enterprise Application on NetBeans 7.4 including a WAR and an EJB using Weblogic 10.3.0
Im using JPA so i need to use the datasource for my persistence.xml
My problem is i'm trying to make a JDBC Datasource following this: http://docs.oracle.com/cd/E15051_01/wls/docs103/jdbc_admin/wwimages/jdbc_package_simple.gif
But Netbeans didn't add a ejb-jar.xml to the EJB, which i need for a resource reference. Oracle's documentation says it needs to be inside META-INF folder but if i add that file to that folder and then compile it is automatically deleted.
So, where is my ejb-jar.xml ? If i create it by my own what can i do to include it without being deleted after compilation ? Open the jar with WINRAR and add it manually (joke) ? Is there a easier way of doing this ?
Thanks
Well, i deleted my EJB (it wasn't necessary). I just created my JDBC Application Module to use it in my WAR without doing all those things in the link. Putting my datasource-jdbc.xml in the config folder (META-INF) and inserting the next code in the weblogic-application.xml was enough:
Then I used the JNDI "MyDatabase" in my Persistence.xml
To generate the datasource-jdbc.xml you can go to the server (a testing one), make the datasource and then go to the server folder and there is a folder (inside one of the main folders, look for it) with the name "jdbc". Inside it, you can get your generated xml.
I strongly recommend you use the new Java EE 5 Annotations instead. For this example thisIsMyDataSource is the name, but you can use whatever name configured on the Server (e.g. you might have several).
Java EE 5 simplifies development by removing the requirement for that older boilerplate configuration. You can, but probably should not, use something like Apache Derby programing (perhaps through DI). There's a separation of roles in EJB. Here's an example using WebSphere. You might want to read more about JDBC.