As I know with the new JBoss application server, there is 2 ways to declare datasources :
Adding the datasource to the standalone.xml file
Adding the datasource under application.ear/META-INF/datasource-ds.xml
My questions are :
what is the best way to declare datasources in term of (best practices/maintainability,.. )
If I use the 2sd way, does my datasource shared between all ear deployed?
Thanks in advance
The best way (and safest) to add a datasource is by means of adding at first a new module for the JDBC driver, then creating a datasource which uses the JDBC driver as a module. See here how to create a datasource with JBoss AS 7
Deploying a datasource along with your application should be used for test purposes only as it is won't be manageable from the AS 7 Console/CLI this way.
Regards
Related
I have an application, written in JEE, JPA, I use Payara as the application server.
In my application's persistence.xml I have
<persistence-unit name="XYZ" transaction type="JTA" >
On the payara side, I have JDBC resource called XYZ, with JDBC connection Pool.
The database used by the application is dedicated to one customer.
Now I want to deploy this app (unchanged) to other customers (on the same server), each customer needs separate database. In order to achieve that I need to modify persistence unit name for each customer and recompile the app, and of course, define JDBC on the Payara side.
I would like to somehow have this persistence unit name being dynamic, so I don't have to recompile the app for each customer. Is there any simple way to achieve that?
In the worst case, I can just modify persistence.xml in the compiled war file, but I hope a more elegant solution exists.
Please advise how to solve that issue.
You can setup a own Instance inside Payara for every customer and deploy your Program to these Instances.
Then you're able to set a variable, different for each Instance.
This variable can than be used inside your persistence.xml.
Using variables is documentated here:
https://docs.payara.fish/community/docs/documentation/payara-server/server-configuration/var-substitution/README.html
Recently I began working with Teiid and Wildfly. I have a user defined function (UDF) that adds custom functionality to Teiid, and it works as expected. However, I need to modify it further and would like to use CDI to inject a bean from the Wildfly app server. I know that the UDF isn't managed by the container (it is a Wildfly module with an associated module.xml file deployed as a jar), so I've added (what seemed to be) necessary dependencies to module.xml but it doesn't work.
Is it possible to use CDI in a UDF with Teiid / Wildfly, and if so, how?
No, it is not possible. although Teiid is a resident of WildFly it is using the infrastructure of WildFly for a variety of features like transactions, security, data sources, administration etc. It is not part of JEE or anything, so there is no direct way to do this. If you want to explain what you are trying to accomplish, maybe we can offer any further guidance on alternatives.
There are couple of datasource configuration files for XA and NON-XA datasource in JBOSS v4.2.3 for the various need of the deployed applications in the jboss environment. Also the DB passwords are encrypted using the JBOSS provided techniques (some datasources are created using JaasSecurityDomain and some use SecureIdentityLoginModule) .
How these datasource configurations and these encryption methodologies are going to behave in jboss v5 and jbossv7 ?
Is there any JBOSS tool/utility to convert the datasource to the corresponding new JBOSS version and also take care of the encryption password part ?
What is the best way to migrate these datasources created with the password encrypted.
Any help in this topic is highly appreciated .
Regards,
Jiten
Take a look at Windup project http://windup.jboss.org/
that is aiming to provide as automated upgrade as possible.
As mentioned in the article https://community.jboss.org/wiki/DataSourceConfigurationInAS7 JBoss 7 provides 2 main ways to configure a data source.
What is the BEST practice of configuring a data source in JBoss 7 AS ? Is it
As a module?
As a deployment?
(The same question has been asked in the thread https://community.jboss.org/thread/198023, but no one has provided an acceptable answer yet.)
The guide JBoss AS7 DS configuration says the recommended way is to configure the datasource by deployment
But according to discussion on the link Jboss 7 DS configuration JBoss Community Discussion on page 54 of the guide it mentions that the recommended way to deploy JDBC driver is to use modular approach
But I personally say that the better(not the best) approach to configure JDBC driver would be to use modules because of 3 reasons
JDBC driver will generally not change.
Re-usability : You can use the same module across various applications and not deploy the jar along with each application, this prevents duplicacy
Space Effective : Using the module approach lets you reduce the size of your EAR/WAR as you do not need to supply the jar with the package
Hence I would argue that the better of the two approaches is via modules
#Mukul Goel
It's not necessary to include it the EAR of your application it's sufficient to put the .jar inside the deployments folder so:
no need to embed in ear
no need to create a module
Jist deploy in deployments folder or via admin console
I have a Tomcat 5.5 running which includes a Webapp with the Java Reporting Components (JRC) 2008.
The Server has a different data source than the client, and currently I set it with the setConnection() functions on the tables, and it works fine. The downside is, that this taken 800ms (Damn slow crystal) just to set the datasources.
Since Crystal Reports seem to use JNDI, how do I configure JNDI in my app? Can this be done programmatically, or do I have to specify the data sources in the web.xml?
Okey, I found out for myself.
Add the Datasource to the context.xml of the Tomcat Server, and add a ref to the web.xml! Now Crystal is happyly taking this datasource and no manual relinking of datasources is needed.