JMS Topic Creation in JBoss 5 AS - jboss

In Jboss 4, when I deployed an ear with an MDB for a topic that had not been specified in the deployment descriptors, the server would automatically create the topic (after posting a warning saying that topic didn't exist).
In Jboss 5, it doesn't seem to automatically create the topics anymore (errors out instead). Is there a configuration option somewhere that would allow automatic topic creation?

From the JBoss community forums -- This JIRA was added in 5AS.
Unfortunately it looks like there is no way to implement createDestination globally in the standardjboss.xml descriptor -- You have to add a custom jboss.xml descriptor to the ear deploying the mdb.
<jboss xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss_5_0.xsd" version="3.0">
<enterprise-beans>
<message-driven>
<ejb-name>MessageDriven</ejb-name>
<create-destination>true</create-destination>
</message-driven>
</enterprise-beans>
</jboss>

Related

How to config JBoss Eap 6.4 to serve images from an external folder outside webapps?

I have an application deployed on JBoss Eap 6.4 and I need to access to images that are located outside of my project in C:\AdminCont\Images, Is there any form to configure for JSP access to this images or any other form using NFS?
I´m trying using overlay in jboss-web.xml but I don´t know how is the correct implementation.
A portable way to implement this is to write a small servlet which simply maps the request URL to a filesystem location and sends the content out.
A not portable way, a JBoss specific way, is to declare an outside directory to <overlay> in jboss-web.xml in order to add non-existing files to your deployment. Here is an example:
<jboss-web version="7.0"
xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee jboss-web_7_0.xsd">
...
<overlay>/path/to/your/images/</overlay>
...
</jboss-web>

Embedded Message Driven Resource Adapter fails to deploy

I have been struggling to get an example of a Message driven (inbound) resource adapter to deploy and interact with an EAR on Wildfly 8.2.0.
I used this Java EE 7 JCA sample as the basis of my application.
I can see in the log files that the Resource Adapter gets deployed
INFO [org.jboss.as.connector.deployers.RADeployer] (MSC service thread 1-2)
IJ020002: Deployed: file:/C:/Software/jboss/wildfly/8.2.0.Final/standalone/tmp/
vfs/deployment/deployment4490b91cd6391845/jca-ra.rar-86794a0699d3da23/contents/
but when the MDB gets initialised I get the following error:
Caused by: java.lang.IllegalStateException: JBAS014521: No message listener
of type org.javaee7.jca.filewatch.adapter.FileSystemWatcher found in
resource adapter jcaInflowApp.ear#jca-ra.rar
The message listener is definitely in the RAR and the RAR is embedded in that location in the EAR.
I've uploaded the code base that I've been working on up to github - hopefully somebody can peruse and see what the issue is?
EDIT for anybody that wants to see a working JBoss example please see the github repo
The issue is duplicate JAR's containing message listener within your EAR. Change the scope of JAR to provided so that it does not get bundled inside lib folder. I've sent you a PR with the fix.

How to configure datasource jboss 4.2.3 for a jar library that initialize connection in the default context?

we have a jar library util that manage some of the logic of connection to db and store the data in memory. Well, this works fine in tomcat because we can configure the datasource in the $CATALINA_HOME/conf/context.xml and everything work's just fine.
How i can configure a datasource in jboss (4.2.3.GA) that's can be see by all the war, ear or apps deployed and of course this jar util that's it's deployed in the $JBOSS_HOME/server/<instance>/lib ?
Thanks :)
UPDATE:
I specifically want to do:
"2a. Shared resource configuration
Use this option if you wish to define a datasource that is shared across multiple JBoss Web applications, or if you just prefer defining your datasource in this file.
This author has not had success here, although others have reported so. Clarification would be appreciated here.
<Resource name="jdbc/postgres" auth="Container"
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://127.0.0.1:5432/mydb"
username="myuser" password="mypasswd" maxActive="20" maxIdle="10" maxWait="-1"/>
source: https://docs.jboss.org/jbossweb/2.1.x/jndi-datasource-examples-howto.html
Well, i'm in the part of "Clarification would be appreciated here"...
Create a JBoss Datasource
Add a datasource configuration (*-ds.xml file) into your $JBOSS_HOME/sever/<server-name>/deploy directory.
This StackOverflow answer has more details: How to create a DataSource in JBoss application server
The link is for JBoss 5, but I don't think the datasource configuration changed much between 4.2.3 and 5.
Configure the Tomcat Resource Reference
Configure a Tomcat resource reference to point to the JBoss datasource. This configuration will identify the datasource by JNDI name in order to retrieve connections from the JBoss datasource.
Step 1 of the accepted answer to this StackOverflow question has more details: JNDI path Tomcat vs. Jboss
Note that your Resource configuration is defining a new data source, not reusing the JBoss definition.
Look up the Data Source with JNDI
The same answer explains how to do this, but note that the URI is slightly different depending on whether the lookup is done from within client code outside of the EJB container, or from code within the EJB container.
Ok, this toke me about a week of researching:
Create a *-ds.xml file.
In the datasource definition add the following tag:
<use-java-context>false</use-java-context>
Then, in the java code we can call it like:
Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
env.setProperty(Context.PROVIDER_URL, "localhost:1100");
initialContext = new InitialContext(env);
DataSource datasource = (DataSource) initialContext.lookup("myCustomDs");

how to set specific ejb jndi names in jboss 7.1.1

my web application contains a few 2.x stateful and stateless session ejbs. but unlike previous jboss versions (as well as other major app servers), i am unable to specify an ejb jndi name in jboss 7.1.1. i have followed their docs by eliminating jboss.xml in favor of jboss-ejb3.xml, as well as starting the app server in full profile mode.
<jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd
http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1"
impl-version="2.0">
<enterprise-beans>
<session>
<ejb-name>MyEJB</ejb-name>
<jndi-name>MyEJB_JNDI_NAME</jndi-name>
</session>
</enterprise-beans>
</jboss:ejb-jar>
however, the jndi-name in jboss-ejb3.xml is not taking hold, preventing me from setting my own custom ejb jndi name. does anyone know how to do this right?
<jndi-name> is no longer supported in JBoss AS 7. From this JIRA:
In AS7 we no longer support binding to custom JNDI names for EJBs. So
the beans are always bound to the spec mandated java:global, java:app
and java:module namespaces. The <jndi-name> for the session bean
element is no longer supported.

What should I do with custom Log4j appender dependancies

I've written a custom log4j appender that creates a new Solr document for each log entry and I'm having problems deploying it to JBoss.
The source is viewable on github but the real problem is trying to use the appender from JBoss.
The relevent bits of jboss-log4j.xml look like this:
<appender name="SOLR" class="com.stuartgrimshaw.solrIndexAppender.SolrIndexAppender" />
<root>
<priority value="${jboss.server.log.threshold}"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
<appender-ref ref="SOLR"/>
</root>
The dependencies for Solr are all available in the .war file that's supplied, but I'm guessing that when the appender is initialised quite early on in the boot process, that application hasn't been deployed yet, which is why I see this error in the log:
2009-11-29 10:40:57,715 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Create: name=jboss.system:service=Logging,type=Log4jService state=Configured mode=Manual requiredState=Create
java.lang.NoClassDefFoundError: org/apache/solr/client/solrj/SolrServerException
Is there any way I can delay the initialization till the solr app has been deployed, or is there a way to deploy the Solr app so it's libraries are visible to jboss while it boots?
I think you could either deploy the Solr libs in server/[jboss-configuration]/lib (in JBoss 4 that is, might be the same in newer versions), then they are available at boot time.
Or don't use the JBoss log4j configuration and define your own log4j.xml in your WAR (either in a JAR in lib or in classes). It will be loaded by the application classloader when it is deployed.
As you've discovered, you'd have to put your JAR into the JBoss config's lib directory in order to refer to its types in jboss-log4j.xml, but this is generally not good practise.
A pretty straightward alternative is to invoke the log4j API programmatically from inside your application. If you have a WAR, then define a ServetContextListener (or something similar) which is invoked when the WAR deploys, and which attaches your appender. Similarly, when undeployed, it detaches the appender.
See the answer to this previous question for how to get started doing this.
I am guessing that this is to manage your log files and make them easier to search, a la Splunk???? However, this feels like a fairly odd way of doing this.. kind of the "look, I can make a dog walk on it's hind legs" kind of thing... Cool, but why would you want to?
I think a much simpler, more robust approach is to a) grab Splunk Free Edition! b) have a seperate process that consumes your log files from disk and send them to Solr using Solr4J.
I think requiring Solr, just to do logging adds a huge level of complexity.