JBoss 5.1.0 Adding Queues - java

How do I add custom queues to JBoss 5.1.0?
I found a way to do it via the Admin Console however for some reason it keeps failing, also I need to be able to quickly and easily move my queues from one JBoss Server to another.
So basically I was wondering if there is a way to create custom queues in an xml file and add that file to the deploy folder much like how you can do with a custom datasource file (mydatasource-ds.xml).
Thank you.

Create a file ending with destinations-service.xml under your instance's deploy directory (or deploy/messaging if you like), e.g. my-jms-destinations-service.xml. It should look something like:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Messaging Destinations deployment descriptor.
-->
<server>
<mbean code="org.jboss.jms.server.destination.QueueService"
name="jboss.messaging.destination:service=Queue,name=MyQueue"
xmbean-dd="xmdesc/Queue-xmbean.xml">
<attribute name="JNDIName">MyQueue</attribute>
<depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
<depends>jboss.messaging:service=PostOffice</depends>
</mbean>
</server>
Set the mbean name and JNDI name as required. Add more mbean definitions for additional queues, or split them across multiple *destinstations-service.xml files for easily deploying / undeploying queues independently of each other.

this may come a little late, but I also had a few errors when creating queues through the Admin console.
The error was due to a missing folder named queue inside the deploy folder. After creating the queue folder, I was able to create the queues using the admin console.

Related

View Tomcat's JNDI tree

Given I have context.xml with Resource definitions and I copy it to /usr/local/tomcat/conf/context.xml
How can I check that Resources were created as expected?
Is there any way how to view JNDI tree after context.xml is applied?
If you want to see what is going on inside Tomcat, you should enable JMX.
See Monitoring and Managing Tomcat 8.5.
You can then connect using the jconsole command that comes with Java, where you can see the Resources available to each of the webapps running in that Tomcat instance.
I personally never put Data Sources <Resource> elements in the context.xml file, but instead put them in server.xml and then put <ResourceLink> elements in the context's XML file (not .../conf/context.xml, but .../conf/Catalina/localhost/mywebapp.xml).
This allows multiple webapps running in the same Tomcat instance to share the database connection pool(s).
So in my instance, I can see the Resource Links for my webapp (from mywebapp.xml) below the /Catalina/ResourceLink/Context node, and the Resources (from server.xml) below the /Catalina/Resource/Global node.
I can also see the Data Sources below the /Catalina/DataSource/javax.sql.DataSource node.

Server.xml for WAS

I am looking for a configuration file in websphere 8.5.1 which holds all the server settings like datasources, buses, queues etc. I am aware of server.xml which is present for every server instance at cell level but it does not have all the settings.
Please help me with some suggestion. I am looking for this file as I want to configure a maven integration test with websphere8.5.1.
So, in order to run these tests I would need some file to get the configurations from.
Basically i am trying to replicate a maven integration test with glassfish where domain.xml was used in the maven integration script pom.xml to configure all the resources.
For WebSphere "full Profile" (as opposed to "Liberty Profile"), there is no single file. All that information is spread across many files.
The information on datasources will be in resource.xml. However, there is a resources.xml file at every scope ie at cell level , cluster level, node level and JVM level. So based on where datasource is defined the correct resource.xml can be used. Sib configuration will be created in the PROFILE_HOME/config/cells//buses
VG, opinions are my own and not those of my employer
There is a PropertiesBasedConfiguration command group from WAS 7 onwards which can let you extract your config to a single file but there are some limitations too.
You can check below links to get more info on same:
http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/index.jsp?topic=/com.ibm.websphere.base.doc/ae/rxml_7propbasedconfig.html
http://www.ibm.com/developerworks/websphere/techjournal/0904_chang/0904_chang.html

off-the-shelf web application working directory

I've just started working with Spring/java web. I'm wondering how to accomplish following scenario:
Let's say that I'm creating an application which supports file upload, uses a database connection and maybe a web service. This is an off-the-shelf system, so all the settings are customer specific and should be configured by customer's IT people on the deployment time.
More general in the web.xml file I would like to point the application working directory containing uploaded files, license key file, configuration files, other customer specific resources and maybe even fragments of spring context.
<context-param>
<param-name>workdir</param-name>
<param-value>/var/r2/</param-value>
</context-param>
In my application I would like use the workdir value in order to include configuration files ...
<import resource="wordir_param_value/settings.properties" />
context config fragments
<import resource="wordir_param_value/security.xml"/>
And how may I later use these values in the java code? What is "the best" approach in case like this anyway (off-the-shelf application config)?
Best Regards,
Alek
You can use Spring's property support for that. This allowed two different approaches:
Having a property file outside the application (at a fixed location), the admin can edit it, and the application loads it
In a Tomcat you can write properties in the application specific context.XML file
In the code use #value annotation to inject the properties in a variable.
In the spring XML file you use it with ${name}
Of course you need to configure the proprtyPlaceholderConfigurer

How do I have multiple datasources with the same JNDI name in JBoss?

So, I have a situation where I will be deploying multiple ear files, each of which I need to configure with a different database (potentially).
Right now I have a *-ds.xml file that is deployed in JBoss, with a JNDI name that all my portlets and servlets use to look up the database connection. If I deploy more than one ear file with a *-ds.xml file that points to a different database, but with the same JNDI name, the deployment barfs. Shouldn't JNDI be more modular to prevent naming collision when deploying different application to isolate them.
It will take quite some time to change my lookup in the code, so is there a way to deploy that will work? The only other idea I had would be to set a JNDI property as the value for the datasource name to look up, and then look up that JNDI property first and retrieve the datasource based on the retrieved "key." This seems kind of hackish to me...
You can have the different data source defined on the application server with different name (on the server namespace) and then map it to a resource-ref name (this time component namespace, so each application can have its own one) via the deployment xml file.
For JBoss prior as7: https://community.jboss.org/wiki/HowDoICreateAResourceRef for as7: https://community.jboss.org/message/629666

Commons configuration - JNDIConfiguration - How to?

I usually use Commons Configuration for manage my applications configs. I have used properties files configuration. Now I'm interested in using a JNDIConfiguration but I'm not able to understand how this works reading the documentation or googling it.
Contextualizing, I'm working in webapps running in an JBoss AS.
Where will be the properties stored? In a file? some tables in a database?
I will be grateful for any guidance at this level even if it comes in shape of links where I can read some valuable information about it.
As a final note my goal is to free me of linking a file with a hardcoded path for my properties, but also don't force me to have my config in database tables. If you have any suggestions on how to do that in some other way be free to share.
JNDIConfiguration looks up the configuration data on a JNDI server (in your case, the JBoss JNDI server). However, you still need a way of getting that data into the JNDI server in the first place, and Commons-Configuration won't help you with that.
It sounds to me that JNDI isn't what you want, it's just pushing the problem around a bit. JBoss still needs to store the configuration data somewhere, so you'll still have the same basic problem.
If you don't want hard-coded file paths, and you don't want a database, then I suggest you pass in the location of the properties file via a system property, e.g.
java -Dmy.config.path=/my/config.properties com.MyClass
Then pass that location to Commons Configuration and let it load your config that way. No hardcoded-paths, no database.
I don't know much about Commons Configuration and JNDIConfiguration, but if what you want is a set of key/value pairs, the standard way of doing this as per the Java EE specs, is to use env-entry in the web.xml or ejb.xml.
<env-entry>
<env-entry-name>maxExemptions</env-entry-name>
<env-entry-value>10</env-entry-value>
<env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>
(example taken from JBoss web conf. reference.)
These values are bound in the JNDI so they can be looked up or injected.
Where will be the properties stored? In a file? some tables in a database?
As #ewernli mentioned, the Java EE way to add entries in the JNDI tree is to use env-entry in your deployment descriptor(s).
Now, if you don't want to repeat the same env-entry in several deployment descriptors, then there is a service for specifying global JNDI bindings: JNDIBindingServiceMgr.
Below, the provided jboss-service.xml example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server PUBLIC "-//JBoss//DTD MBean Service 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd">
<server>
<mbean code="org.jboss.naming.JNDIBindingServiceMgr"
name="jboss.tests:service=JNDIBindingServiceMgr">
<attribute name="BindingsConfig" serialDataType="jbxb">
<jndi:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jndi="urn:jboss:jndi-binding-service:1.0"
xs:schemaLocation="urn:jboss:jndi-binding-service:1.0 resource:jndi-binding-service_1_0.xsd"
>
<jndi:binding name="urls/jboss-home">
<jndi:value type="java.net.URL">http://www.jboss.org</jndi:value>
</jndi:binding>
<jndi:binding name="hosts/localhost">
<jndi:value editor="org.jboss.util.propertyeditor.InetAddressEditor">
127.0.0.1
</jndi:value>
</jndi:binding>
<jndi:binding name="maps/testProps">
<java:properties xmlns:java="urn:jboss:java-properties"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="urn:jboss:java-properties resource:java-properties_1_0.xsd">
<java:property>
<java:key>key1</java:key>
<java:value>value1</java:value>
</java:property>
<java:property>
<java:key>key2</java:key>
<java:value>value2</java:value>
</java:property>
</java:properties>
</jndi:binding>
</jndi:bindings>
</attribute>
<depends>jboss:service=Naming</depends>
</mbean>
</server>
If this is not what you are looking for, then I don't understand what you're looking for :) In that case, you should maybe clarify it.

Categories