How do I set myDatasource-ds.xml without modules.xml - jboss

I want to set database configuration using only ds.xml. So that without using modules.xml and standalone.xml I just deploy the ds.xml in deployments for Database connection.
mydatasource-ds.xml
<datasources>
<datasource jndi-name="java:jboss/datasources/myDatasource" pool-name="myDatasource_pool" enabled="true" use-java-context="true">
<connection-url></connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>ojdbc6</driver>
<security>
<user-name></user-name>
<password></password>
</security>
</datasource>

If you are creating driver module then only module.xml comes into picture. If you deploy driver jar directly into deployment directory, no need to create module.xml.
However it is recommended to create driver module and create datasource in standalone.xml because if you create datasource using ds.xml you will not be able to monitor it.

Related

Jboss AS 7.2 - Serve static content

Can I create a static directory in JBoss AS 7.2, like WildFly?
I know the WildFly server can be configured to serve static content by undertow subsystem. For instance:
<server name="default-server">
<http-listener name="default" socket-binding="http"/>
<host name="default-host" alias="localhost">
<location name="/mycontent" handler="content"/>
</host>
</server>
<handlers>
<file name="content" path="${jboss.home.dir}/content" directory-listing="true"/>
</handlers>
According to my requirement, user will upload the static content in the static directory.
I have found the solution.
JBoss AS 7.2 does not support to serve static content's directory as WildFly. I know, not everybody has luxury to use WildFly.
I created a war directory with extension (mycontent.war) instead of war file and created dodeployed.war file also. Inside the mycontent.war directory, I created WEB-INF directory and web.xml file. The web.xml file contains only display name tag. That is it. You can upload the static content in the directory and the contents can be served also.

Can we change Jboss default deploy folder path?

Let's assume I've war file in one location in file system and I have Jboss server installed at different location in file system.Now my question is there any way Jboss can access my war file directly.
In short I don't want to move my war file in deploy folder instead I want location of war file to be treated as deploy folder.
Is it possible??If yes then how?
Add path of custom deployment directory in standalone-*xml like :
<paths>
<path name="custom.dir" path="/PATH_TO/jboss/applications"/>
</paths>
and then in deployment-scanner subsystem mention it like :
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
<deployment-scanner path="customDeployDir" relative-to="custom.dir" > scan-interval="5000"/>
</subsystem>

Deployment of webapp in wildfly using Context Descriptors

I searched using "How to set Context Path in Wildfly", but got no success. Can anyone help me on how to do it..?
I've used the following code to set the Context Path in tomcat where I can access my application directly using localhost:8080/myApp
myApp.xml contains as follows and placed at $CATALINA_BASE\conf\[enginename]\[hostname]\myApp.xml
<Context path="myApp" docBase="G:\workspace\j2ee\myProject\myWebApp\WebContent" />
similar or equivalent type of configuration want to use in Wildfly server.
In your standalone.xml configuration you want to add a deployment like this:
<deployments>
<deployment name="myProject" runtime-name="myProject.war">
<fs-archive path="G:/workspace/j2ee/myProject/myWebApp/WebContent"/>
</deployment>
</deployments>
Then within WebContent/WEB-INF create a file called jboss-web.xml with a configuration similar to:
<?xml version="1.0"?>
<jboss-web>
<context-root>/my-context-path</context-root>
</jboss-web>
If this doesn't work you may need to rename WebContent directory to WebContent.war, even if it is exploded it may want .war in the name.

How to create subsystem via CLI in JBoss 7.1 standalone.xml config

Is there a way to create a <subsystem> tag in the standalone.xml file using JBoss CLI?
Specifically, I would like to add the following line:
<subsystem xmlns="urn:jboss:domain:snowdrop:1.0"/>
to the <profile> element as per https://docs.jboss.org/author/display/SNOWDROP/The+Spring+Deployer.
Best,
Kamil

How to connect Jboss-as-7.1.1 with Postgresql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Does anybody know how to connect jboss-as-7.1.1 to PostgreSQL?
(Note that this was written for JBoss AS 7.1.1; keep that in mind if on a newer version, as things might have changed.)
Download PgJDBC. I'm assuming you're using postgresql-9.1-902.jdbc4.jar, the current version at time of writing. Adjust any filenames to match if you need a different version.
Now deploy the JDBC driver to JBoss AS 7 by putting it in the deployments folder or using the deploy command in jboss-cli. This will work for most, but not all, purposes.
Alternately, you an define a PostgreSQL JDBC driver module:
Create the path $JBOSS_HOME/modules/org/postgresql/main. The modules/org part should already exist, make directories for the rest.
In $JBOSS_HOME/modules/org/postgresql/main/module.xml with the following content, changing the resource-root entry for the PgJDBC driver to refer to the driver you wish to use.
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.1-902.jdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
Into the same directory as module.xml place postgresql-9.1-902.jdbc4.jar
Start JBoss AS
Open jboss-cli by running $JBOSS_HOME/bin/jboss-cli --connect
Run the command:
/subsystem=datasources/jdbc-driver=postgresql-driver:add(driver-name=postgresql-driver, driver-class-name=org.postgresql.Driver, driver-module-name=org.postgresql)
Now create any required data sources, etc, using postgresql-driver as the driver name.
You can create a datasource via the web ui, with jboss-cli with the data-source create command (see data-source --help, data-source add --help), or by deploying a -ds.xml file like this:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<datasource jndi-name="java:/datasources/some-ds" enabled="true" use-java-context="true"
pool-name="some-ds-pool">
<connection-url>jdbc:postgresql:dbname</connection-url>
<driver>postgresql-driver</driver>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
</datasource>
</datasources>