[JBoss AS7 Development] - Re: Weld-OSGi integration in AS7
by Kevin Pollet
Kevin Pollet [http://community.jboss.org/people/kevinpollet] created the discussion
"Re: Weld-OSGi integration in AS7"
To view the discussion, visit: http://community.jboss.org/message/605472#605472
--------------------------------------------------------------
> Thoughts?
Hi all,
I just want to give you my thinking and Mathieu's thinking about the use of the OSGiService qualifier. First of all, we agree with you that it's possible to get rid of the OSGiService qualifier (if a service is not found in CDI, it's possible to look at the OSGi service registry).
I thought a lot about this and one interrogation comes to my mind. How differentiate the case of a missing CDI binding and the case of a local implementation for a service? The default behavior of CDI is to throw an exception specifying that there is no binding for this injection target but in this case, a proxy waiting for an hypothetical OSGi service will be injected (and obviously will fail at runtime). IMHO, doing this will break the default CDI programming model. I mean that the user applicition will start without any problem in our case but in the default CDI programming model an exception will be thrown. We think that the user have to specify where he wants to use OSGi (so the user will knows where to deal with OSGi dynamism).
On the other hand, as you say in your above comments, this feature has to be enabled by the user. In this case he could be aware of this behavior, but we think it's too much changes for the CDI programming model.
WDYT?
Kevin & Mathieu
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/605472#605472]
Start a new discussion in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years
[JBoss ESB Development] - Exception handling between actions and ftp-listener
by Phillip Schulte
Phillip Schulte [http://community.jboss.org/people/phillip.schulte] created the discussion
"Exception handling between actions and ftp-listener"
To view the discussion, visit: http://community.jboss.org/message/564097#564097
--------------------------------------------------------------
Hello.
Thats one service in my jboss-esb.xml
<service category="de.eskalon.kn.garuda.invoice.HistoricalExchangeRates" name="HistoricalExchangeRateImporter" description="Imports historical exchange rates from ftp directory files" invmScope="GLOBAL">
<service category="de.eskalon.kn.garuda.invoice.HistoricalExchangeRates" name="HistoricalExchangeRateImporter" description="Imports historical exchange rates from ftp directory files" invmScope="GLOBAL">
<listeners>
<ftp-listener busidref="currency-ftp-in" is-gateway="true" maxThreads="2" name="ftp-listener-gateway" scheduleidref="everyminute" />
</listeners>
<actions mep="OneWay">
<action name="transform" class="org.jboss.soa.esb.actions.converters.ByteArrayToString">
<property name="encoding" value="UTF-8" />
</action>
<action name="properties" class="de.eskalon.kn.garuda.esb.GetPropertiesFromMessage"> </action>
<action class="org.jboss.soa.esb.actions.EJBProcessor" name="callPersist">
<property name="ejb3" value="true" />
<property name="jndi-name" value="garuda-invoicing/HistoricalExchangeRatesManagerBean/remote" />
<property name="initial-context-factory" value="org.jnp.interfaces.NamingContextFactory" />
<property name="provider-url" value="localhost:1099" />
<property name="method" value="persistRate" />
<property name="ejb-params">
<arg0 type="java.lang.String">FILE_NAME</arg0>
<arg1 type="java.lang.String">org.jboss.soa.esb.message.defaultEntry</arg1>
</property>
</action>
</actions>
</service>
<listeners>
And here my ftp-provider
<ftp-provider hostname="${currency.ftp.host}" name="currency-provider">
<ftp-bus busid="currency-ftp-in">
<ftp-message-filter directory="${currency.ftp.directory}" error-delete="false" error-suffix=".HAS_ERROR"
input-suffix=".csv"
passive="true" password="${currency.ftp.password}" post-delete="false" post-rename="true"
post-suffix=".COMPLETE" username="${currency.ftp.username}" work-suffix=".garudaWorking" />
</ftp-bus>
</ftp-provider>
So its possible tthat something goes wrong in my persistRate method. But in any case the ftp-listener will rename the file to <filename>.COMPLETE independently of throwing an exception in my method. So my question is how do I handle this correctly. What I want to have is, if anything goes wrong rename the file to <filename>.HAS_ERROR
Best regards
Phillip
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/564097#564097]
Start a new discussion in JBoss ESB Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 2 months
[JBoss AS7 Development] - How to specify a SAR's module dependencies?
by Matt Drees
Matt Drees [http://community.jboss.org/people/matt.drees] created the discussion
"How to specify a SAR's module dependencies?"
To view the discussion, visit: http://community.jboss.org/message/606619#606619
--------------------------------------------------------------
Hi all,
I'm trying to get a simple SAR deployed to AS7. It has an mbean class in it that implements ServiceMBean. However, when I deploy it, I get a ClassNotFoundException for ServiceMBean. I suspect I need to somehow tell Jboss Modules that my SAR needs to access whichever module has that class. But I don't know how to do that. I suspect http://docs.jboss.org/author/display/MODULES/Manifest+module+information http://docs.jboss.org/author/display/MODULES/Manifest+module+information is what I'd need, except that that page hasn't been written yet. Any suggestions?
Log output:
15:15:00,565 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "jboss-addons-3.0-SNAPSHOT.sar"
15:15:00,633 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define class org.ccci.ha.HighAvailabilityDataSourceMBean in Module "deployment.jboss-addons-3.0-SNAPSHOT.sar:main" from Service Module Loader: java.lang.LinkageError: Failed to link org/ccci/ha/HighAvailabilityDataSourceMBean (Module "deployment.jboss-addons-3.0-SNAPSHOT.sar:main" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:398) [:1.0.0.CR2]
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:258) [:1.0.0.CR2]
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:75) [:1.0.0.CR2]
at org.jboss.modules.Module.loadModuleClass(Module.java:588) [:1.0.0.CR2]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:180) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:357) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:329) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:329) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:306) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:100) [:1.0.0.CR2]
at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_24]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [:1.6.0_24]
at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [:1.6.0_24]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [:1.6.0_24]
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:394) [:1.0.0.CR2]
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:258) [:1.0.0.CR2]
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:75) [:1.0.0.CR2]
at org.jboss.modules.Module.loadModuleClass(Module.java:588) [:1.0.0.CR2]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:180) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:357) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:329) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:306) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:100) [:1.0.0.CR2]
at java.lang.Class.forName0(Native Method) [:1.6.0_24]
at java.lang.Class.forName(Class.java:247) [:1.6.0_24]
at org.jboss.as.service.ReflectionUtils.getClass(ReflectionUtils.java:100)
at org.jboss.as.service.ParsedServiceDeploymentProcessor.addServices(ParsedServiceDeploymentProcessor.java:111)
at org.jboss.as.service.ParsedServiceDeploymentProcessor.deploy(ParsedServiceDeploymentProcessor.java:102)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1675)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_24]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_24]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_24]
Caused by: java.lang.NoClassDefFoundError: org/jboss/system/ServiceMBean
at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_24]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [:1.6.0_24]
at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [:1.6.0_24]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [:1.6.0_24]
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:394) [:1.0.0.CR2]
... 32 more
Caused by: java.lang.ClassNotFoundException: org.jboss.system.ServiceMBean from [Module "deployment.jboss-addons-3.0-SNAPSHOT.sar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:188) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:357) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:329) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:329) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:306) [:1.0.0.CR2]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:100) [:1.0.0.CR2]
... 37 more
Thanks for your time,
-Matt
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/606619#606619]
Start a new discussion in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 2 months
[JBoss Messaging Development] - Failed to write property - java.lang.NullPointerException - infinity messages
by Alexei J
Alexei J [http://community.jboss.org/people/a_subscriber] created the discussion
"Failed to write property - java.lang.NullPointerException - infinity messages"
To view the discussion, visit: http://community.jboss.org/message/565750#565750
--------------------------------------------------------------
JBoss AS 5.1 - success started
I have a simple jms application
private void run(String customerName) throws Exception {
try {
Context initial = new InitialContext();
ConnectionFactory cf = (ConnectionFactory) initial.lookup("/ConnectionFactory");
Destination notifyTopic = (Destination) initial.lookup("topic/testTopic");
Destination requestTopic = (Destination) initial.lookup("topic/testDurableTopic");
logger.trace("Creating Connection...");
connection = cf.createConnection();
connection.setClientID(customerName);
logger.trace("Creating Session...");
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
logger.trace("Creating MessageProducer to send messages to the specified destination. ...");
producer = session.createProducer(requestTopic);
logger.trace("Creating a MessageConsumer for the specified destination. ...");
consumer = session.createConsumer(notifyTopic);
logger.trace("Starts (or restarts) a connection's delivery of incoming messages...");
connection.start();
for (;;) {
listen(customerName);
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
} finally {
if (connection != null)
connection.close();
}
}
jndi.properties file:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=jnp://localhost:1099
I create jar and deploy it to the %JBOSS_HOME%/server/default/messaging/myapplication/customers/Xavier/
run application on the jboss:
java -cp myproject.jar;%JBOSS_HOME%/client/jbossall-client.jar com.mycompany.myproject.Customer Xavier
and I get infinity the next messages:
[11 ieo 2010 12:03:00.963] com.mycompany.myproject.Customer.main(Customer.java:123) TRACE:
Start customer
[11 ieo 2010 12:03:01.041] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
createSocket, hostAddr: localhost/127.0.0.1, port: 1099, localAddr: null, localPort: 0, timeout: 0
[11 ieo 2010 12:03:01.713] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
org.jboss.aop.classpool.AOPClassPool@1389188011 [class path: sun.misc.Launcher$AppClassLoader@3326b249;] - dcl:sun.misc.Launcher$AppClassLoader@3326b249 creating pool for loader sun.misc.Launcher$AppClassLoader@3326b249 searchStrategy:org.jboss.aop.classpool.AOPClassPool$SearchAllRegisteredLoadersSearchStrategy@26302a05 isTemp:false
[11 ieo 2010 12:03:01.776] com.mycompany.myproject.Customer.run(Customer.java:69) TRACE:
Creating Connection...
[11 ieo 2010 12:03:01.807] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
Remoting version: 2.5.3.SP1 (Flounder)
[11 ieo 2010 12:03:01.822] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
Client[1699270891:5c4o56o-d5cpbk-gf547yym-1-gf547yym-2].connect(null)
[11 ieo 2010 12:03:01.822] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Client[1699270891:5c4o56o-d5cpbk-gf547yym-1-gf547yym-2]: metadata = null
[11 ieo 2010 12:03:01.885] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Mapping properties for bean: SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457]
[11 ieo 2010 12:03:01.885] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Property editor found for: marshaller, editor: java.beans.PropertyDescriptor@40f7af00, setter: public void org.jboss.remoting.MicroRemoteClientInvoker.setMarshaller(org.jboss.remoting.marshal.Marshaller)
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Failed to find property editor for: marshaller
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.trace(Logger.java:171) TRACE:
Failed to write property
java.lang.NullPointerException
at org.jboss.util.propertyeditor.PropertyEditors.mapJavaBeanProperties(PropertyEditors.java:377)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.mapJavaBeanProperties(MicroSocketClientInvoker.java:1359)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.setup(MicroSocketClientInvoker.java:533)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.<init>(MicroSocketClientInvoker.java:292)
at org.jboss.remoting.transport.socket.SocketClientInvoker.<init>(SocketClientInvoker.java:78)
at org.jboss.remoting.transport.bisocket.BisocketClientInvoker.<init>(BisocketClientInvoker.java:166)
at org.jboss.remoting.transport.bisocket.TransportClientFactory.createClientInvoker(TransportClientFactory.java:44)
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.remoting.InvokerRegistry.loadClientInvoker(InvokerRegistry.java:460)
at org.jboss.remoting.InvokerRegistry.createClientInvoker(InvokerRegistry.java:359)
at org.jboss.remoting.Client$6.run(Client.java:724)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.remoting.Client.connect(Client.java:720)
at org.jboss.remoting.Client.connect(Client.java:668)
at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.createClient(ClientConnectionFactoryDelegate.java:343)
at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.org$jboss$jms$client$delegate$ClientConnectionFactoryDelegate$getClientAOPStack$aop(ClientConnectionFactoryDelegate.java:246)
at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.getClientAOPStack(ClientConnectionFactoryDelegate.java)
at org.jboss.jms.client.ClientAOPStackLoader.load(ClientAOPStackLoader.java:75)
at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:192)
at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:87)
at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:82)
at com.mycompany.myproject.Customer.run(Customer.java:70)
at com.mycompany.myproject.Customer.main(Customer.java:127)
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Property editor found for: timeout, editor: java.beans.PropertyDescriptor@5f20829f, setter: null
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting timeout to 300000
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] constructed
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting timeout to 300000
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] connecting
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
Creating semaphore with size 50
[11 ieo 2010 12:03:01.932] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] added new pool ([]) as ServerAddress[127.0.0.1:4457, NO enableTcpNoDelay timeout 300000 ms, maxPoolSize=50]
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/565750#565750]
Start a new discussion in JBoss Messaging Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 3 months
[JBoss AS7 Development] - How do I put an MBean in JNDI?
by Matt Drees
Matt Drees [http://community.jboss.org/people/matt.drees] created the discussion
"How do I put an MBean in JNDI?"
To view the discussion, visit: http://community.jboss.org/message/606799#606799
--------------------------------------------------------------
Hi all,
I'm trying to get a SAR deployed to AS7.
One of my MBeans is trying to bind itself into JNDI using NonSerializableFactory.rebind(name, this, true). This apparently works fine on older jboss releases, but on AS7 I get this:
13:30:22,405 WARN [org.ccci.ha.HighAvailabilityDataSource] (MSC service thread 1-4) Starting up HighAvailabilityDataSource ccpDatasource in PRIMARY mode
13:30:22,406 INFO [stdout] (MSC service thread 1-4) fullName=jdbc/ccpDatasource
13:30:22,406 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.mbean.service."jboss.jca:name=jdbc/ccpDatasource,service=DataSourceBinding".start: org.jboss.msc.service.StartException in service jboss.mbean.service."jboss.jca:name=jdbc/ccpDatasource,service=DataSourceBinding".start: Failed to execute legacy service start() method
at org.jboss.as.service.StartStopService.start(StartStopService.java:51)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1675)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_24]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_24]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_24]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_24]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_24]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_24]
at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_24]
at org.jboss.as.service.AbstractService.invokeLifecycleMethod(AbstractService.java:59)
at org.jboss.as.service.StartStopService.start(StartStopService.java:49)
... 4 more
Caused by: java.lang.UnsupportedOperationException: Naming context is read-only
at org.jboss.as.naming.NamingContext.rebind(NamingContext.java:227)
at javax.naming.InitialContext.rebind(InitialContext.java:408) [:1.6.0_24]
at org.jboss.util.naming.NonSerializableFactory.rebind(NonSerializableFactory.java:185)
at org.jboss.util.naming.NonSerializableFactory.rebind(NonSerializableFactory.java:250)
at org.ccci.ha.HighAvailabilityDataSource.rebind(HighAvailabilityDataSource.java:53)
at org.ccci.ha.HighAvailabilityDataSource.start(HighAvailabilityDataSource.java:34)
... 10 more
So, it looks like JNDI is read-only now. What is the recommended approach for making an MBean available in JNDI?
Or, perhaps I'm just going about this all the wrong way. What I really need is to make a custom javax.sql.Datasource available in JNDI, and I need to be able to do some logic on start-up. (I don't want to use JCA for this, since this datasource simply delegates to one of two other standard (JCA) datasources.) I'm sure I don't need this object to be an MBean, but that seemed the simplest thing at the time. Is there a better way to do this?
Thanks!
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/606799#606799]
Start a new discussion in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 3 months
[JBoss Messaging Development] - Need help compiling JBoss Messaging 1.4.8.GA for AS5
by Johan Hedin
Johan Hedin [http://community.jboss.org/people/johan.hedin] created the discussion
"Need help compiling JBoss Messaging 1.4.8.GA for AS5"
To view the discussion, visit: http://community.jboss.org/message/607785#607785
--------------------------------------------------------------
Hi all
I have trouble compiling JBoss 1.4.8.GA for AS5. I have set the build.properties to integration.base=AS5. I then do
ant clean
# lots of download
Then
johan@localhost ~/tmp/JBossMessaging_1_4_8_GA-AS5 $ ant compile
Buildfile: /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/build.xml
check.inhibit.downloads:
createthirdparty:
compile:
show.version:
[echo] ========================================
[echo] Building 1.4.8.GA for AS5!
[echo] ========================================
compile-parsers:
[mkdir] Created dir: /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/output/gen-parsers/org/jboss/jms/server/selector
[echo] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/thirdparty/sun-javacc/lib/
[javacc] Java Compiler Compiler Version 4.0 (Parser Generator)
[javacc] (type "javacc" with no arguments for help)
[javacc] Reading from file /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/src/main/org/jboss/jms/server/selector/SelectorParser.jj . . .
[javacc] Note: UNICODE_INPUT option is specified. Please make sure you create the parser/lexer using a Reader with the correct character encoding.
[javacc] File "TokenMgrError.java" does not exist. Will create one.
[javacc] File "ParseException.java" does not exist. Will create one.
[javacc] File "Token.java" does not exist. Will create one.
[javacc] File "SimpleCharStream.java" does not exist. Will create one.
[javacc] Parser generated successfully.
[mkdir] Created dir: /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/output/classes
[javac] Compiling 7 source files to /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/output/classes
[javac] Note: /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/output/gen-parsers/org/jboss/jms/server/selector/SelectorParser.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
compile-classes:
[javac] Compiling 362 source files to /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/output/classes
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java:49: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: package org.jboss.security
[javac] import org.jboss.security.SecurityContext;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/src/main/org/jboss/messaging/util/JBMExecutor.java:45: warning: [deprecation] org.jboss.messaging.util.NamedThreadQueuedExecutor in org.jboss.messaging.util has been deprecated
[javac] public class JBMExecutor extends NamedThreadQueuedExecutor
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityActions.java:31: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: package org.jboss.security
[javac] import org.jboss.security.SecurityContext;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityActions.java:32: cannot find symbol
[javac] symbol : class SecurityContextAssociation
[javac] location: package org.jboss.security
[javac] import org.jboss.security.SecurityContextAssociation;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityActions.java:46: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.container.SecurityActions
[javac] static SecurityContext getSecurityContext()
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityActions.java:56: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.container.SecurityActions
[javac] static void setSecurityContext(final SecurityContext sc)
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityAspect.java:48: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: package org.jboss.security
[javac] import org.jboss.security.SecurityContext;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/SecurityActions.java:31: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: package org.jboss.security
[javac] import org.jboss.security.SecurityContext;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/SecurityActions.java:32: cannot find symbol
[javac] symbol : class SecurityContextAssociation
[javac] location: package org.jboss.security
[javac] import org.jboss.security.SecurityContextAssociation;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/SecurityActions.java:45: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.endpoint.SecurityActions
[javac] static SecurityContext getSecurityContext()
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/SecurityActions.java:55: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.endpoint.SecurityActions
[javac] static void setSecurityContext(final SecurityContext sc)
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:32: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: package org.jboss.security
[javac] import org.jboss.security.SecurityContext;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:33: cannot find symbol
[javac] symbol : class SecurityContextAssociation
[javac] location: package org.jboss.security
[javac] import org.jboss.security.SecurityContextAssociation;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:34: cannot find symbol
[javac] symbol : class SecurityContextFactory
[javac] location: package org.jboss.security
[javac] import org.jboss.security.SecurityContextFactory;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:36: cannot find symbol
[javac] symbol : class JBossSecurityContext
[javac] location: package org.jboss.security.plugins
[javac] import org.jboss.security.plugins.JBossSecurityContext;
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:48: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.security.SecurityActions
[javac] static SecurityContext getSecurityContext()
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:58: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.security.SecurityActions
[javac] static void setSecurityContext(final SecurityContext sc)
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/src/main/org/jboss/jms/client/container/ClientConsumer.java:81: warning: [deprecation] isDebugEnabled() in org.jboss.logging.Logger has been deprecated
[javac] debug = log.isDebugEnabled();
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java:226: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint
[javac] SecurityContext previousSCtx = SecurityActions.getSecurityContext();
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/src/main/org/jboss/jms/server/ServerPeer.java:1806: warning: [deprecation] deployXML(java.net.URL,java.lang.ClassLoader) in org.jboss.aop.AspectXmlLoader has been deprecated
[javac] AspectXmlLoader.deployXML(url, this.getClass().getClassLoader());
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java:146: warning: [deprecation] isDebugEnabled() in org.jboss.logging.Logger has been deprecated
[javac] private boolean debug = log.isDebugEnabled();
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityActions.java:48: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.container.SecurityActions
[javac] return AccessController.doPrivileged(new PrivilegedAction<SecurityContext>(){
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityActions.java:50: cannot find symbol
[javac] symbol: class SecurityContext
[javac] public SecurityContext run()
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityActions.java:52: cannot find symbol
[javac] symbol: variable SecurityContextAssociation
[javac] return SecurityContextAssociation.getSecurityContext();
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityActions.java:62: cannot find symbol
[javac] symbol: variable SecurityContextAssociation
[javac] SecurityContextAssociation.setSecurityContext(sc);
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/container/SecurityAspect.java:293: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.container.SecurityAspect
[javac] SecurityContext previousSCtx = SecurityActions.getSecurityContext();
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/SecurityActions.java:47: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.endpoint.SecurityActions
[javac] return AccessController.doPrivileged(new PrivilegedAction<SecurityContext>(){
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/SecurityActions.java:49: cannot find symbol
[javac] symbol: class SecurityContext
[javac] public SecurityContext run()
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/SecurityActions.java:51: cannot find symbol
[javac] symbol: variable SecurityContextAssociation
[javac] return SecurityContextAssociation.getSecurityContext();
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/endpoint/SecurityActions.java:61: cannot find symbol
[javac] symbol: variable SecurityContextAssociation
[javac] SecurityContextAssociation.setSecurityContext(sc);
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:50: cannot find symbol
[javac] symbol : class SecurityContext
[javac] location: class org.jboss.jms.server.security.SecurityActions
[javac] return AccessController.doPrivileged(new PrivilegedAction<SecurityContext>(){
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:52: cannot find symbol
[javac] symbol: class SecurityContext
[javac] public SecurityContext run()
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:54: cannot find symbol
[javac] symbol: variable SecurityContextAssociation
[javac] return SecurityContextAssociation.getSecurityContext();
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:64: cannot find symbol
[javac] symbol: variable SecurityContextAssociation
[javac] SecurityContextAssociation.setSecurityContext(sc);
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:158: cannot find symbol
[javac] symbol: class SecurityContext
[javac] SecurityContext context = SecurityContextFactory.createSecurityContext(principal, passwordChars, subject, secDom);
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:158: cannot find symbol
[javac] symbol: variable SecurityContextFactory
[javac] SecurityContext context = SecurityContextFactory.createSecurityContext(principal, passwordChars, subject, secDom);
[javac] ^
[javac] /home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/integration/AS5/src/main/org/jboss/jms/server/security/SecurityActions.java:159: cannot find symbol
[javac] symbol: variable SecurityContextAssociation
[javac] SecurityContextAssociation.setSecurityContext(context);
[javac] ^
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 33 errors
[javac] 4 warnings
BUILD FAILED
/home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/build.xml:69: The following error occurred while executing this line:
/home/johan/tmp/JBossMessaging_1_4_8_GA-AS5/build-messaging.xml:218: Compile failed; see the compiler error output for details.
Total time: 7 seconds
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/607785#607785]
Start a new discussion in JBoss Messaging Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 4 months
[JBoss ESB Development] - Re: httprouter issues with GET/POST WADL Services and Web Routing
by Luke Samad
Luke Samad [http://community.jboss.org/people/luke.samad] created the discussion
"Re: httprouter issues with GET/POST WADL Services and Web Routing"
To view the discussion, visit: http://community.jboss.org/message/601696#601696
--------------------------------------------------------------
I found this post extremely useful and I managed this by writing a custom action. I figured it might help others. Thank you guys for the great start.
<service category="Case" description="CRUD on docket" invmScope="GLOBAL" invmTransacted="true" name="Docket">
<listeners>
<http-gateway name="httpDocket" payloadAs="STRING" urlPattern="client/docket/*">
<property name="synchronousTimeout" value="150000" />
</http-gateway>
</listeners>
<actions mep="RequestResponse">
<action class="gov.usc.commons.soa.esb.actions.HttpRestProxyAction" name="DocketAction">
<property name="endpointUrl" value="${client.docket.war.url}" />
<property name="logDebug" value="${log.case}" />
</action>
</actions>
</service>
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.jboss.soa.esb.actions.AbstractActionLifecycle;
import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.actions.BeanConfiguredAction;
import org.jboss.soa.esb.http.HttpHeader;
import org.jboss.soa.esb.http.HttpRequest;
import org.jboss.soa.esb.message.Message;
public class HttpRestProxyAction extends AbstractActionLifecycle implements BeanConfiguredAction {
private static final Logger log = Logger.getLogger(HttpRestProxyAction.class);
private String endpointUrl;
private String logDebug;
private Boolean debug = Boolean.FALSE;
public Message process(Message message) throws ActionProcessingException {
debug = (logDebug != null && logDebug.equalsIgnoreCase("true")) ? Boolean.TRUE : Boolean.FALSE;
HttpRequest request = HttpRequest.getRequest(message);
String outputXml = null;
String inputXml = null;
Object defaultLocation = message.getBody().get();
if (defaultLocation != null && !defaultLocation.getClass().getSimpleName().equals("byte[]")) {
log.info("defaultLocation class type " + defaultLocation.getClass().getSimpleName());
inputXml = (String) defaultLocation;
}
if(debug && inputXml != null){
log.info("#############################");
log.info("Input XML >>>> \n"+inputXml);
log.info("#############################");
}
HashMap<String, String> headers = populateHeaders(request.getHeaders());
HashMap<String, String> params = populateParameters(request.getQueryParams());
if (request.getMethod().equals("GET")) {
if (!headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executeGet(endpointUrl, params, headers);
message.getBody().add(outputXml);
} else if (headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executeGet(endpointUrl, params);
message.getBody().add(outputXml);
} else {
outputXml = HttpClientUtil.executeGet(endpointUrl);
message.getBody().add(outputXml);
}
} else if (request.getMethod().equals("POST")) {
if (!headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executePost(inputXml, endpointUrl, params, headers);
message.getBody().add(outputXml);
} else if (headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executePost(inputXml, endpointUrl, params);
message.getBody().add(outputXml);
} else {
outputXml = HttpClientUtil.executePost(inputXml, endpointUrl);
message.getBody().add(outputXml);
}
} else if (request.getMethod().equals("PUT")) {
if (!headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executePut(inputXml, endpointUrl, params, headers);
message.getBody().add(outputXml);
} else if (headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executePut(inputXml, endpointUrl, params);
message.getBody().add(outputXml);
} else {
outputXml = HttpClientUtil.executePut(inputXml, endpointUrl);
message.getBody().add(outputXml);
}
} else if (request.getMethod().equals("DELETE")) {
if (!headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executeDelete(endpointUrl, params, headers);
message.getBody().add(outputXml);
} else if (headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executeDelete(endpointUrl, params);
message.getBody().add(outputXml);
} else {
outputXml = HttpClientUtil.executeDelete(endpointUrl);
message.getBody().add(outputXml);
}
}
if(debug && outputXml != null){
log.info("#############################");
log.info("Output XML \n"+outputXml);
log.info("#############################");
}
return message;
}
private HashMap<String, String> populateHeaders(List<HttpHeader> requestHeaders) {
HashMap<String, String> headers = new HashMap<String, String>();
if (requestHeaders != null && !requestHeaders.isEmpty()) {
if (debug) {
log.debug("****************** Request Headers ******************");
}
for (HttpHeader header : requestHeaders) {
if (debug) {
log.info("key: " + header.getName() + " " + "value: " + header.getValue());
}
headers.put(header.getName(), header.getValue());
}
}
return headers;
}
private HashMap<String, String> populateParameters(Map<String, String[]> requestParameters) {
HashMap<String, String> params = new HashMap<String, String>();
if (requestParameters != null && !requestParameters.isEmpty()) {
if (debug) {
log.info("******************Request parameters ******************");
}
for (String s : requestParameters.keySet()) {
String[] value = requestParameters.get(s);
if (debug) {
log.info("key " + s + " " + "value " + value[0]);
}
params.put(s, value[0]);
}
}
return params;
}
public void setEndpointUrl(String endpointUrl) {
this.endpointUrl = endpointUrl;
}
public void setLogDebug(String logDebug) {
this.logDebug = logDebug;
}
}
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.DeleteMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
public class HttpClientUtil {
public static final Logger log = Logger.getLogger(HttpClientUtil.class);
public static String executeGet(String url){
log.info("entering HTTP GET with no parameters and no headers");
log.info("URL >> "+url);
String xml = null;
GetMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new GetMethod(url);
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executeGet(String url, HashMap<String, String> parameters){
log.info("entering HTTP GET with parameters and no headers");
log.info("URL >> "+url);
String xml = null;
GetMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new GetMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
method.setQueryString(params);
}
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executeGet(String url, HashMap<String, String> parameters, HashMap<String, String> headers ){
log.info("entering HTTP GET with parameters and headers");
log.info("URL >> "+url);
String xml = null;
GetMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new GetMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
method.setQueryString(params);
}
if(headers!=null && headers.size() > 0){
setRequestHeaders(method, headers);
}
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executePut(String xml, String url){
log.info("entering HTTP PUT with no parameters and no headers");
log.info("URL >> "+url);
String xmlReturn = null;
PutMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PutMethod(url);
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream updateResponse = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(updateResponse ), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePut(String xml, String url, HashMap<String, String> parameters){
log.info("entering HTTP PUT with parameters and no headers");
log.info("URL >> "+url);
String xmlReturn = null;
PutMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PutMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream updateResponse = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(updateResponse ), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePut(String xml, String url, HashMap<String, String> parameters, HashMap<String, String> headers ){
log.info("entering HTTP PUT with parameters and headers");
log.info("URL >> "+url);
String xmlReturn = null;
PutMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PutMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
if(headers!=null && headers.size() > 0){
setRequestHeaders(method, headers);
}
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream updateResponse = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(updateResponse ), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePost(String xml, String url){
log.info("entering HTTP POST with no parameters and no headers");
log.info("URL >> "+url);
String xmlReturn = null;
PostMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PostMethod(url);
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePost(String xml, String url, HashMap<String, String> parameters){
log.info("entering HTTP POST with parameters and no headers");
log.info("URL >> "+url);
String xmlReturn = null;
PostMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PostMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePost(String xml, String url, HashMap<String, String> parameters, HashMap<String, String> headers ){
log.info("entering HTTP POST with parameters and headers");
log.info("URL >> "+url);
String xmlReturn = null;
PostMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PostMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
if(headers!=null && headers.size() > 0){
setRequestHeaders(method, headers);
}
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executeDelete(String url){
log.info("entering HTTP DELETE with no parameters and no headers");
log.info("URL >> "+url);
DeleteMethod method = null;
String xml = null;
try{
HttpClient httpClient = new HttpClient();
method = new DeleteMethod(url);
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executeDelete(String url, HashMap<String, String> parameters){
log.info("entering HTTP DELETE with parameters and no headers");
log.info("URL >> "+url);
String xml = null;
DeleteMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new DeleteMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executeDelete(String url, HashMap<String, String> parameters, HashMap<String, String> headers ){
log.info("entering HTTP DELETE with parameters and headers");
log.info("URL >> "+url);
String xml = null;
DeleteMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new DeleteMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
if(headers!=null && headers.size() > 0){
setRequestHeaders(method, headers);
}
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
private static void setRequestHeaders(HttpMethod method , HashMap<String, String> headers ){
log.info(" ************** headers ************** ");
if(headers != null && headers.size() > 0){
for(String s : headers.keySet()) {
log.info("header="+s+" valkue="+headers.get(s));
method.setRequestHeader(s, headers.get(s));
}
}
}
private static NameValuePair[] buildQueryParameters(HashMap<String, String> parameters ) throws Exception{
log.info(" ************** parameters ************** ");
NameValuePair[] params = null;
if (parameters != null) {
params = new NameValuePair[parameters.size()];
int i = 0;
for (String s : parameters.keySet()) {
log.info("parameter="+s+" value="+parameters.get(s));
params[i] = new NameValuePair(s, URIUtil.encodeQuery(parameters.get(s)));
i++;
}
}
return params;
}
private static String getExceptionStackTraceAsString(Exception exception) {
StringWriter sw = new StringWriter();
exception.printStackTrace(new PrintWriter(sw));
return sw.toString();
}
private static void logHTTPStatusCode(int code ){
log.info("HTTP Status code is >> "+code);
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/601696#601696]
Start a new discussion in JBoss ESB Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 6 months