[JBoss Tools] - m2e(clipse)-wtp 0.12.0 : New & Noteworthy
by Fred Bricon
Fred Bricon [http://community.jboss.org/people/fbricon] modified the blog post:
"m2e(clipse)-wtp 0.12.0 : New & Noteworthy"
To view the blog post, visit: http://community.jboss.org/community/tools/blog/2011/05/03/m2eclipse-wtp-...
--------------------------------------------------------------
So, thanks to Igor Fedorenko's last efforts, m2eclipse-wtp 0.12.0 is finally out, (update site available at http://m2eclipse.sonatype.org/sites/m2e-extras http://m2eclipse.sonatype.org/sites/m2e-extras), bringing the WTP integration with Maven to a whole new level. The complete release notes are available here (https://issues.sonatype.org/secure/ReleaseNote.jspa?projectId=10310&versi...). However, I wanted to highlight some of the most notable features in this new version, so let’s take a quick tour :
h3. On-the-fly web resource filtering
Maven has this interesting concept of web resource filtering (http://(http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html) : basically you can add resources existing in non standard directories, into your final web application. Moreover, you can filter these resources to apply, for instance, specific application configuration depending on a maven profile : you can activate some debug options in your web.xml, define development specific parameters in your spring configuration files, use a different css color scheme when you work locally and so forth.
Supported maven web resource filtering features are :
* inclusion/exclusion of resources
* filtering (not activated by default)
* target path (root of the web application by default)
* possibility to use specific properties file filters
Here is a sample of maven-war-plugin configuration filtering any xml files under src/main/webapp, using an external filter file :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<filters>
<filter>src/main/filters/dev.properties</filter>
</filters>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
Note that after adding the webResource configuration to your pom.xml, you need to update the Maven project configuration.
m2eclipse-wtp 0.12.0 not only supports these features from maven, but goes one step further and brings you on-the-fly filtering : as soon as you save a file included in the *<webResources>* configuration from the maven-war-plugin, filtering is triggered automatically. Couple that with WTP’s hot redeployment capabilities, and you can see your changes by just reloading the affected pages in your browser.
OK, to be fair, that depends on the changed files, actually. If you change the content of your web.xml, or some spring config files, chances are you’ll have to restart your application or the server for the changes to be taken in consideration.
The filtered resources are copied to the project build directory, under *m2e-wtp/web-resources*. You can view the content of this folder directly from the Project Explorer view in eclipse, under the *Web Resources* Node. You can open and compare side by side a raw file and its filtered version, as shown in the following screenshot.
http://community.jboss.org/servlet/JiveServlet/showImage/38-3769-16241/we... http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3769-1624...
In the previous example, the dev profile, activated by default (see lower right panel) determines which filter file must be used during filtering. In this case, we want to active some debugging options. The index.jsp page, shown in the browser in the lower left panel, displays the computed values of the different context-params from web.xml.
Now after changing the active profile (due to a bug in m2e-core 0.12.0, the pom.xml needs to be saved twice for the change to be detected, but this has been https://bugs.eclipse.org/bugs/show_bug.cgi?id=340159 fixed in m2e-core 0.13.0) and after restarting tomcat (it doesn't restart the application upon web.xml changes), you'll notice the web.xml values are updated, values are taken from another properties file.
http://community.jboss.org/servlet/JiveServlet/showImage/38-3769-16242/we... http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3769-1624...
h3. Context root customization
By default, the web project's context root is resolved from the *<finalName>* value resolved from the pom.xml. In the following example, the example-web project will be accessible at http://localhost:8080/ http://localhost:8080/example/, according to the finalName value :
http://community.jboss.org/servlet/JiveServlet/showImage/38-3769-16243/m2... http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3769-1624...
However, you can customize the context root used in WTP by setting a custom property in your pom.xml, for instance, if you need to use "/" as your context root, just add *<m2eclipse.wtp.contextRoot>* in your properties and update your maven project configuration :
<properties>
...
<m2eclipse.wtp.contextRoot>/<m2eclipse.wtp.contextRoot>
...
</properties>
When restarting tomcat, the context root change will be detected and tomcat will ask to update its configuration. Now the same application is accessible at http://localhost:8080/ http://localhost:8080/
http://community.jboss.org/servlet/JiveServlet/showImage/38-3769-16244/m2... http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3769-1624...
h3. Java nature no longer added to EAR projects
The java nature was wrongly added to EAR projects. This is no longer the case. Moreover, existing Java nature will be automatically removed from existing EAR projects upon update project configuration.
h3. Generation of application.xml outside the source folders
Since m2eclipse added support for EAR projects in 0.9.8, many users complained the deployment descriptor was generated under the source folder, under version control. Since application.xml (and jboss-app.xml) can be generated by maven automatically, there is no need to pollute the source folder right? Starting from m2eclipse-wtp 0.12.0, the deployment descriptors are now generated under *<build directory>/m2e-wtp/ear-resources*. Similarly to the web projects, a new *Application Ressources* node is now displayed in the Project Explorer view, showing you which EAR resources will be deployed/exported.
http://community.jboss.org/servlet/JiveServlet/showImage/38-3769-16237/ea... http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3769-1623...
If, for some reason, one would still want to generate the deployment descriptors under the source folder (src/main/application by default), then you could right click on the project, open the project Properties and go to the *Maven > WTP integration* page. There, after enabling specific project configuration, you can choose to NOT use the build folder to generate application.xml.
http://community.jboss.org/servlet/JiveServlet/showImage/38-3769-16240/m2... http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3769-1624...
The same setting can be enabled globally for all EAR projects in the workspace by opening the *Preferences > Maven > WTP Integration*
http://community.jboss.org/servlet/JiveServlet/showImage/38-3769-16239/m2... http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3769-1623...
After validating your choice, all EAR projects in the workspace will update their configuration, if you choose so.
h3. Support for the no-version file name mapping in maven-ear-plugin
maven-ear-plugin 2.5 introduced a new file name mapping strategy (http://maven.apache.org/plugins/maven-ear-plugin/examples/customize-file-...), namely *no-version*, that remove the version suffix from all EAR deployed dependencies. All you need to do is add the following configuration to your maven-ear-plugin configuration :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.5</version>
<configuration>
...
<fileNameMapping>no-version</fileNameMapping>
...
</configuration>
</plugin>
Then you can check in the Project Explorer view, under the Deployment Descriptor node, all dependencies' names under the Bundle Libraries and Modules are updated :
http://community.jboss.org/servlet/JiveServlet/showImage/38-3769-16238/ea... http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3769-1623...
h3. Increased stability
Many users, over the years, experienced random crashes during project import or configuration update, or saw test resources being deployed with their applications. All these issues could be https://issues.sonatype.org/secure/IssueNavigator.jspa?reset=true&jqlQuer... linked to one root cause : some WTP projects were missing a crucial element : the *org.eclipse.wst.common.modulecore.ModuleCoreNature* nature in their .project. The root cause of this "corruption" is still unclear, this is probably caused by some race condition, but unfortunately, this has proved impossible to reproduce with test projects.
m2eclipse-wtp 0.12.0 actually workarounds this issue : if the ModuleCoreNature is missing from WTP projects, it's automagically added to fix the projects, under the hood. Hopefully, this should fix most of the crashes users occasionally experience.
h3. Now, what next?
m2eclipse-wtp 0.12.0 is the last version supporting Eclipse 3.5 (Galileo) based platforms. Next 0.13.0 version will be aligned with the new, revamped m2e-core 0.13.0 (= future 1.0) and will be released at about the same time frame as Eclipse 3.7 Indigo (late june). The next big thing is the added support for war overlays, the single https://issues.sonatype.org/browse/MECLIPSEWTP-2 most requested feature in m2eclipse-wtp. If you like to live on the bleeding edge, you can already try the latest development builds, available under https://repository.sonatype.org//content/sites/forge-sites/m2eclipse-wtp/... https://repository.sonatype.org//content/sites/forge-sites/m2eclipse-wtp/... (use the latest directory as your update site).
One last thing : all this sweetness would not have been possible if I wasn't working full time on m2eclipse-wtp. Fortunately, Max R. Andersen got me a job in his JBoss Tools and Developer Studio team, and allows me to spend a considerable amount of time playing with my favorite toy of the moment :-) Thanks a bunch Max!!! Also big thanks to Eugene Kuleshov, Igor Fedorenko and Jason Van Zyl who gave me the chance to get involved in m2e(clipse).
Enjoy,
Fred.
--------------------------------------------------------------
Comment by going to Community
[http://community.jboss.org/community/tools/blog/2011/05/03/m2eclipse-wtp-...]
13 years, 7 months
[jBPM] - Re: How to install jBPM 5.0 on a JBoss AS
by Chris Melas
Chris Melas [http://community.jboss.org/people/melc] created the discussion
"Re: How to install jBPM 5.0 on a JBoss AS"
To view the discussion, visit: http://community.jboss.org/message/602952#602952
--------------------------------------------------------------
Hello,
You have to either tweak the build.properties and build.xml files and use start.demo or do manually the work that build.xml does.... I'll try to guide you with tweaking build.properties and build.xml ;)
First of all make a safety backup copy of your existing jboss installation i.e. copy your jboss directory .
Edit build.properties and set the property jboss.server.version with the version of your jboss installation, the property jboss.home with the path to your jboss installation.
Edit build.xml and replace the line,
<target name="install.demo" depends="install.jboss,install.guvnor.into.jboss,install.designer.into.jboss,install.jBPM-gwt-console.into.jboss,install.eclipse,install.jBPM-eclipse.into.eclipse,install.jBPM.runtime,install.drools-eclipse.into.eclipse" />
with the line,
<target name="install.demo" depends="install.guvnor.into.jboss,install.designer.into.jboss,install.jBPM-gwt-console.into.jboss,install.eclipse,install.jBPM-eclipse.into.eclipse,install.jBPM.runtime,install.drools-eclipse.into.eclipse" />
in other words delete the install.jboss part from the depends attribute value.
Now you may try to run ant install.demo and then ant start.demo .
If you get any exceptions stop the procedure (although ant will probably stop running) and post the exceptions here for further instructions :)
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/602952#602952]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 7 months
[jBPM] - Re: Central jBPM (enterprise) with remote access from managing apps
by kaissun bs
kaissun bs [http://community.jboss.org/people/kaissun] created the discussion
"Re: Central jBPM (enterprise) with remote access from managing apps"
To view the discussion, visit: http://community.jboss.org/message/603250#603250
--------------------------------------------------------------
i have some problems in my application Server !
like this :
CONFIG [EJBComponentProviderFactoryInitilizer] The EJB interceptor binding API is not available. JAX-RS EJB support is disabled.
javax.naming.NameNotFoundException: org.glassfish.ejb.container.interceptor_binding_spi not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.jersey.server.impl.ejb.EJBComponentProviderFactoryInitilizer.initialize(EJBComponentProviderFactoryInitilizer.java:56)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:486)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:246)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:520)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:199)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:308)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:471)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:950)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4122)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4421)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
at $Proxy38.start(Unknown Source)
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
at org.jboss.system.ServiceController.start(ServiceController.java:460)
at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:619)
Could you help me to solve the problem please !
thanks in advance.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/603250#603250]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 7 months
[JNDI and Naming] - lookup a session bean inside a servlet
by stefano bertozzi
stefano bertozzi [http://community.jboss.org/people/bertoz84] created the discussion
"lookup a session bean inside a servlet"
To view the discussion, visit: http://community.jboss.org/message/603050#603050
--------------------------------------------------------------
Hi,
i have a simple servlet that lookup up for a session bean in doPost:
+package webinterface.servlet;+
+import java.io.IOException;+
+import java.io.PrintWriter;+
+import javax.naming.Context;+
+import javax.naming.InitialContext;+
+import javax.naming.NamingException;+
+import javax.servlet.RequestDispatcher;+
+import javax.servlet.Servlet;+
+import javax.servlet.ServletException;+
+import javax.servlet.http.HttpServlet;+
+import javax.servlet.http.HttpServletRequest;+
+import javax.servlet.http.HttpServletResponse;+
*+import bookshop.library.entitybean.*;+*
*+import bookshop.library.sessionbean.*;+*
+public class somethingServlet extends HttpServlet+ +implements Servlet {+
+ static final long serialVersionUID = 1L;+
+ static Context context;+
+ static OperazioniUtenti opUser;+
+ static Utenti user;+
+ public somethingServlet() {+
+ super();+
+ } +
+protected void doPost(HttpServletRequest request, HttpServletResponse response)+ +throws ServletException, IOException {+
+ try+
+ {+
+ context = new InitialContext();+
+* System.out.println(OperazioniUtentiRemote.class.toString());* // print successfully INFO [STDOUT] interface bookshop.library.sessionbean.OperazioniUtentiRemote+
*+ opUser = (OperazioniUtenti) context.lookup("/BookShop/OperazioniUtenti/remote");+*
+ } catch (NamingException e) {+
+ e.printStackTrace();+
+ }+
I get the following error :
ERROR [STDERR] javax.naming.NameNotFoundException: BookShop not bound
I created a Web Project ( "Web" ) together with Struts in Eclipse Helios; then i added my BookShop.jar inside Web/WebContent/WEB-INF/lib
There's a problem with the JNDI lookup? Do i miss something?! I'm very new with those stuff!
thank you for helping me!!
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/603050#603050]
Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 7 months
[JBoss Messaging] - JBoss Settings for MDB Client ?
by shptlucky
shptlucky [http://community.jboss.org/people/shptlucky] created the discussion
"JBoss Settings for MDB Client ?"
To view the discussion, visit: http://community.jboss.org/message/603174#603174
--------------------------------------------------------------
I have made message driven bean.
I have made a producer class.
I am using Netbeans
Producer Class is sending message to local host and i am recieving it.
but i am not getting settings to be done for remote connection.
I am striving for last three weeks on it. Please anyone help and tell me what settings is required on client side or server for Remote JMS message retrieving. Code is here under:
*For Sending*
package com;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.jms.TopicConnectionFactory;
import javax.jms.TopicConnection;
import javax.jms.TopicSession;
import javax.jms.TopicPublisher;
import javax.jms.Topic;
import javax.jms.TextMessage;
import javax.jms.Session;
import javax.jms.JMSException;
/**
* <p>Simple JMS client, publish text messages to testTopic Topic.
* </p>
*
* <p><b>NOTE</b>This code is a showcase only. It may not provide
* a stable production example.</p>
* @author Peter Antman
* @version $Revision: 3.1 $
*/
public class NewClass {
/**
* Topic connection, hold on to this so you may close it.
*/
TopicConnection topicConnection;
/**
* Topic session, hold on to this so you may close it.
* Also used to create messages.
*/
TopicSession topicSession;
/**
* Use this to publish messages.
*/
TopicPublisher topicPublisher;
/**
* Destination where to publish.
*/
Topic topic;
/**
* Sets up all the JMS fixtures.
*
* Use close() when finished with object.
*
* @param factoryJNDI name of the topic connection factory to look up.
* @param topicJNDI name of the topic destination to look up
*/
public NewClass(String factoryJNDI, String topicJNDI)
throws JMSException, NamingException {
// Populate with needed properties
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL, "192.168.1.218:1099");
props.put("java.naming.rmi.security.manager", "yes");
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
// Get the initial context with given properties
Context context = new InitialContext(props);
System.out.println(factoryJNDI);
// Get the initial context
// Context context = new InitialContext();
// Get the connection factory
TopicConnectionFactory topicFactory = (TopicConnectionFactory) context.lookup("java:/XAConnectionFactory");
// Create the connection
topicConnection = topicFactory.createTopicConnection();
// Create the session
topicSession = topicConnection.createTopicSession(
// No transaction
false,
// Auto ack
Session.AUTO_ACKNOWLEDGE);
// Look up the destination
topic = (Topic) context.lookup(topicJNDI);
// Create a publisher
topicPublisher = topicSession.createPublisher(topic);
}
/**
* Publish the given String as a JMS message to the testTopic topic.
*/
public void publish(String msg) throws JMSException {
// Create a message
TextMessage message = topicSession.createTextMessage();
message.setText(msg);
// Publish the message
topicPublisher.publish(topic, message);
}
/**
* Close session and connection.
* When done, no publishing is possible any more.
*/
public void close() throws JMSException {
topicSession.close();
topicConnection.close();
}
/**
* Run an example publishing 10 messages to testTopic.
* Only works up to and including JBoss 2.4.0
*/
public static void main(String[] args) {
try {
// Create the HelloPublisher, giving it the name of the
// TopicConnection Factory and the Topic destination to
// use in lookup.
NewClass publisher = new NewClass("ConnectionFactory","topic/testTopic1");
// Publish 10 messages
for (int i = 1; i < 11; i++) {
String msg = "Hello World no. " + i;
System.out.println("Publishing message: " + msg);
publisher.publish(msg);
}
// Close down your publisher
publisher.close();
}
catch (Exception ex)
{
System.err.println("An exception occurred while testing HelloPublisher: " + ex);
ex.printStackTrace();
}
}
} // HelloPublisher
*MDB For reciving on Client End*
package com;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
@MessageDriven(mappedName = "topic/testTopic",
activationConfig = {
@ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/testTopic"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "NonDurable"),
@ActivationConfigProperty(propertyName = "clientId", propertyValue = "DrivenBean6"),
@ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "DrivenBean6")
})
public class DrivenBean implements MessageListener {
public DrivenBean() {
}
TextMessage tx=null;
public void onMessage(Message message)
{
tx=(TextMessage) message;
try {
System.out.println("Driven Bean -> " + tx.getText());
} catch (JMSException ex) {
}
System.out.println("Hello");
}
}
What Settings are required so that i could send message to client end.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/603174#603174]
Start a new discussion in JBoss Messaging at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 7 months