0

Specs:

  • Netbeans 7.3
  • JDK 6
  • Java EE 5
  • JSF 2
  • Server: Weblogic 11g (10.3.6)

Hi, programmers. I'm working with JDBC Modules and Descriptors in my Web Application. At first, NetBeans was creating the datasource file needed to register the database in the server and deploy it. But when i wanted to deploy the WAR file by myself in the server the JDBC Connection wasn't there. It doesn't recognize the JNDI.

I have a XML called "data-source-1-jdbc" which i copied from an old version of the project (NetBeans doesn't create the file nomore, i don't know why) to let Weblogic automatically create the JDBC Datasource, but what should i do to let Weblogic take this jdbc datasource and deploy it with my [Java Web App] ?

I just read this tutorial : http://docs.oracle.com/cd/E15051_01/wls/docs103/jdbc_admin/packagedjdbc.html

There's a tag called "Module" that does what i want. Like this:

<module>
<name> MyFile </name>
<path> {File Path} </path>
</module>

But it is just for the weblogic-application.xml, which is a file used in Enterprise Applications (EAR) not in WAR's. In my Java Web i just have these:

  • web.xml
  • weblogic.xml

I already tried using the <module> tag in weblogic.xml but it doesn't work.

All i want is avoid to manually create the connection in the server and instead use that xml as the configuration file when i deploy my application.

So, how do you make this work?

GabrielBB
  • 2,479
  • 1
  • 35
  • 49
  • It sounds like an easy workaround would be to put your .war file inside of a .ear so you do have access to the weblogic-application.xml file. If you're using Maven you could do it like this: http://stackoverflow.com/questions/5167024/how-to-add-war-inside-ear-with-maven – Display Name is missing Nov 05 '13 at 22:11
  • Yes, better_use_mkstemp ! I just answered that and now i see you already said it. Anyway... Thanks! – GabrielBB Nov 06 '13 at 02:23

2 Answers2

2

Ok, after i tried a lot to do it i just saw an option on NetBeans called "Create Enterprise Application using Existing Resources", i choose the web application as that "existing resource" and it created an Enterprise Application with the Web Application as a module.

Once there, now that i have an EAR and not just a WAR, i just followed the process in the Oracle's official tutorial for that. Done.

GabrielBB
  • 2,479
  • 1
  • 35
  • 49
  • Java EE 5 does not support deployment of single standalone WAR so you need an EAR anyway to deploy your application. Then, following the documentation will get the job done for sure. – Bruno Borges Jun 09 '14 at 08:05
2

You can create the connection pool using the configuration file. just place the config file at domain_dir/config/jdbc and restart the server, it will get created the connection pool automatically.

//ex

<?xml version="1.0" encoding="UTF-8"?>
<jdbc-data-source xmlns="http://xmlns.oracle.com/weblogic/jdbc-data-source">
<name>jdbc/karthick</name>
<jdbc-driver-params>
<url>jdbc:mysql://localhost:3306/karthick</url>
<driver-name>com.mysql.jdbc.Driver</driver-name>
<properties>
<property>
<name>user</name>
<value>mysql</value>
</property>
<property>
<name>password</name>
<value>mysql</value>
</property>
</properties>
</jdbc-driver-params>
<jdbc-data-source-params>
<jndi-name>jdbc/karthick</jndi-name>
</jdbc-data-source-params>
</jdbc-data-source>

Use jndi(jdbc/karthick) name to access the db connection.

Karthikeyan Sukkoor
  • 968
  • 2
  • 6
  • 24
  • Yes, we can do that too. But in my case, i wanted an application that the only thing you have to do is click deploy and done. I answered the correct solution in this post http://stackoverflow.com/questions/19987084/where-is-my-ejb-jar-xml – GabrielBB Dec 20 '13 at 13:53