[JBoss Messaging] - Re: View payload and header data in the table
by Pasan Perera
Pasan Perera [https://community.jboss.org/people/pasanperera] created the discussion
"Re: View payload and header data in the table"
To view the discussion, visit: https://community.jboss.org/message/727718#727718
--------------------------------------------------------------
If you want to get the javax.jms.Message (or any other message types that you have added to the queue) the following will help.
Note that most of the source is copied from JDBCPersistenceManager class in package "jboss-messaging-1.4.2.GA-SP1
Write a query to retrieve all columns from JBM_MSG
if (rs.next())
{
long messageId = rs.getLong("MESSAGE_ID");
boolean reliable = rs.getString("RELIABLE").equals("Y");
long expiration = rs.getLong("EXPIRATION");
long timestamp = rs.getLong("TIMESTAMP");
byte priority = rs.getByte("PRIORITY");
byte[] bytes = getBytes(rs, "HEADERS");
HashMap headers = bytesToMap(bytes);
byte[] payload = getBytes(rs, "PAYLOAD");
byte type = rs.getByte("TYPE");
MapMessage m = (MapMessage)MessageFactory.createMessage(messageId, reliable, expiration, timestamp, priority, headers, payload,
type);
}
private boolean usingBinaryStream = true;
protected byte[] getBytes(ResultSet rs, String column) throws Exception
{
if (usingBinaryStream)
{
// Get the bytes using a binary stream - likely to be better for large
// byte[]
InputStream is = null;
ByteArrayOutputStream os = null;
final int BUFFER_SIZE = 4096;
try
{
InputStream i = rs.getBinaryStream(column);
if (i == null)
{
return null;
}
is = new BufferedInputStream(rs.getBinaryStream(column), BUFFER_SIZE);
os = new ByteArrayOutputStream(BUFFER_SIZE);
int b;
while ((b = is.read()) != -1)
{
os.write(b);
}
return os.toByteArray();
}
finally
{
if (is != null)
{
is.close();
}
if (os != null)
{
os.close();
}
}
}
else
{
// Get the bytes using getBytes() - better for smaller byte[]
return getVarBinaryColumn(rs, column);
}
}
protected byte[] getVarBinaryColumn(ResultSet rs, String column) throws Exception
{
byte[] bytes = rs.getBytes(column);
if (true)
{
// Get rid of the trailing byte
// http://jira.jboss.org/jira/browse/JBMESSAGING-825 http://jira.jboss.org/jira/browse/JBMESSAGING-825
byte[] newBytes = new byte[bytes.length - 1];
System.arraycopy(bytes, 0, newBytes, 0, bytes.length - 1);
bytes = newBytes;
}
return bytes;
}
protected HashMap bytesToMap(byte[] bytes) throws Exception
{
if (bytes == null) { return new HashMap(); }
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
DataInputStream dais = new DataInputStream(bis);
HashMap map = StreamUtils.readMap(dais, true);
dais.close();
return map;
}
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/727718#727718]
Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 8 months
[JBoss Web Services] - Jboss 6.1.0 + Jboss native WS +Message Signing
by ganesh jadhav
ganesh jadhav [https://community.jboss.org/people/seeaganesh] created the discussion
"Jboss 6.1.0 + Jboss native WS +Message Signing"
To view the discussion, visit: https://community.jboss.org/message/727703#727703
--------------------------------------------------------------
Hi,
Configuration :
Jboss version : Jboss 6.1.0
Jboss WS native lib : jbossws-native-4.0.0.CR1
I have deployed a WS (EJB 3.0 exposed as WS).
EJB Code :
*@WebService (name="TestWSEJBRemote",serviceName = "TestWSEJBService")*
*@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)*
*(a)Remote(TestWSEJBRemote.class)*
*@EndpointConfig(configName = "Standard WSSecurity Endpoint")*
*@SecurityDomain("JBossWS")*
*@Stateless (name = "TestWSEJBRemote")*
*public class TestWSEJB implements TestWSEJBRemote{*
*@WebMethod*
*public String ping (String name)*
*{*
*return "Hello : " + name;*
*}*
*}*
*Remote Interface :*
*@WebService*
*public interface TestWSEJBRemote {*
* public String ping (String name);*
*}*
----------------------------------------------------------
I created keystore, truststore and certificates like this.
*Create the server keystore*
*keytool -genkey -alias serverkeys -keyalg RSA -keystore server.keystore -storepass 123456 -keypass 123456 -dname "CN=localhost, OU=MYOU, O=MYORG, L=MYCITY, ST=MYSTATE, C=MY"*
*Create the server certificate*
*keytool -export -alias serverkeys -keystore server.keystore -storepass 123456 -file server.cer*
*Create the client keystore*
*keytool -genkey -alias clientkeys -keyalg RSA -keystore client.keystore -storepass 123456 -keypass 123456 -dname "CN=localhost, OU=MYOU, O=MYORG, L=MYCITY, S=MYSTATE, C=MY" *
*Create the client certificate*
*keytool -export -alias clientkeys -keystore client.keystore -storepass 123456 -file client.cer*
*Import server certificate into client truststore*
*keytool -import -v -keystore client.truststore -storepass 123456 -file server.cer*
*Import client certificate into server truststore*
*keytool -import -v -keystore server.truststore -storepass 123456 -file client.cer*
*----------------------------------------------------------------------------------------------------------------------------------------------*
Client Code :
*URL url = new URL(*
* " http://XXX:8380/testmewsse/TestWSEJBService/TestWSEJBRemote?wsdl http://XXX:8380/testmewsse/TestWSEJBService/TestWSEJBRemote?wsdl");*
* QName qn = new QName(" http://ejb.wsse.gj.com/ http://ejb.wsse.gj.com/", "TestWSEJBService");*
* System.setProperty("org.jboss.ws.wsse.keyStore","./resources/client.keystore");*
* System.setProperty("org.jboss.ws.wsse.keyStorePassword","123456");*
* System.setProperty("org.jboss.ws.wsse.trustStore","./resources/client.truststore");*
* System.setProperty("org.jboss.ws.wsse.trustStorePassword","123456");*
* System.setProperty("org.jboss.ws.wsse.keyStoreType","jks");*
* System.setProperty("org.jboss.ws.wsse.trustStoreType","jks");*
* Service s = Service.create(url, qn);*
* s.getPorts();*
* TestWSEJBRemote port = s.getPort(TestWSEJBRemote.class);*
* URL securityURL = new File(*
* "resources/jboss-wsse-client.xml").toURL();*
* ((StubExt) port).setSecurityConfig(securityURL.toExternalForm());*
* ((StubExt) port).setConfigName("Standard WSSecurity Client");*
* //((StubExt) port).("Standard WSSecurity Client");*
* ((BindingProvider) port).getRequestContext().put(*
* BindingProvider.USERNAME_PROPERTY, "kermit");*
* ;*
* ((BindingProvider) port).getRequestContext().put(*
* BindingProvider.PASSWORD_PROPERTY, "thefrog");*
* ;*
* System.out.println("Invoking the sayHello operation on the port.");*
* String response = port.ping("ganesh");*
*------------------------------------*
All files keystore and truststore files are placed at right location. The server.log shows the incoming signed message, and the dispatched signed outgoing messages to the above client.
The client is not able to decode the return message. *(it says there is internal WS error please see the log, no log is generated at client side).*
After debugging the native code source, i found it out that the *validateCertificate* method of the *org.jboss.ws.extensions.security.SecurityStore* is getting falied while calling
parameters = new PKIXParameters(trustStore);
I am getting *"the trustAnchors parameters must be non-null" * exception. I inspected the trustStore, it does contain the certificate with proper alias name in my case it is *"clientkeys".*
*Am i correctly creating all keystores and trustores?*
*Regards*
*Ganesh
*
*
*
*
*
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/727703#727703]
Start a new discussion in JBoss Web Services at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 8 months
[JBoss AOP] - Jboss AOP classloading bug
by ud1
ud1 [https://community.jboss.org/people/ud1] created the discussion
"Jboss AOP classloading bug"
To view the discussion, visit: https://community.jboss.org/message/715200#715200
--------------------------------------------------------------
I'm using JBoss 6.0.0 with AOP for logging user actions and function call durations. Functions of interest are marked by our custom @Trace annotation and there is an our tracing aspect, that do all the work. But sometimes, probably after jboss restart, some random functionality of the project becomes unavailable, e.g. some dropdown lists didn't working or some buttons pressing do nothing. After second rebooting everething work fine. I can't reproduce this on my machine, but customers regulary (once or twice a month) reporting about the problem. Here is the typical log with org.jboss.classpool logging on:
http://pastebin.com/f4TEduCB http://pastebin.com/f4TEduCB
When all is functioning properly the log look's like:
http://pastebin.com/zZKPk643 http://pastebin.com/zZKPk643
I have made some investigation and degugging, so probably I have found the cause of the problem.
At first, if you look at ClassPoolToDomainAdapter with a lot of byte array class paths in it, you could see the difference, at normal working this list
contains BaseClassLoader@xxxxxx{vfs:///D:/retailHub/loan/server/default/deploy/myProject.ear} ClassPath at the end, but then the problem is it doesn't.
After deepest code investigation I figured out, that this could happen then something call close() on а ClassPool, and this probably happens inside unregisterClassLoader() function.
During joint point constraction Aspect Manager calls several times unregisterClassLoader() function:
ClassPoolRepository
public void unregisterClassLoader(ClassLoader classLoader)
{
registryHandler.unregisterClassLoader(classLoader); // <-- calls JBossClRegistryHandler.unregisterClassLoader()
if (callbacks != null && callbacks.size() > 0)
{
for (ClassPoolRepositoryCallback callback : callbacks)
{
callback.classLoaderUnregistered(classLoader);
}
}
}
which in turn calls JBossClRegistryHandler.registerClassLoader() functions with possible result of a closing the class pool.
JBossClRegistryHandler
public ClassPool registerClassLoader(ClassLoader classLoader)
{
ScopedClassPool classPool = (ScopedClassPool) successor.registerClassLoader(classLoader);
if (classPool == null) // <-- true
{
// TODO check this works; was delegate before
successor.unregisterClassLoader(classLoader); // <-- calls classLoader.close()
}
else
{
Module module = getModuleForClassLoader(classLoader);
this.registeredModules.put(module, classPool);
}
return classPool;
}
I can't understand what is the purpose of the DefaultClassLoaderRegistryHandler, but it can return null from registerClassLoader() function,
probaly then several jointpoints are generated concurrently from different threads:
ClassPoolRepository$DefaultClassLoaderRegistryHandler
public ClassPool registerClassLoader(ClassLoader classLoader)
{
if (classLoader == null)
{
classLoader = SecurityActions.getContextClassLoader();
}
if (currentClassLoaders.putIfAbsent(classLoader, Boolean.TRUE) != null)
{
return null; // <-- Returns null
}
ScopedClassPool classPool = (ScopedClassPool) ClassPoolRepository.super.registerClassLoader(classLoader);
currentClassLoaders.remove(classLoader);
return classPool;
}
ScopedClassPoolRepositoryImpl:
public void unregisterClassLoader(ClassLoader cl) {
synchronized (registeredCLs) {
ScopedClassPool pool = registeredCLs.remove(cl);
if (pool != null)
pool.close(); // <-- close
}
}
ScopedClassPool:
public void close() {
this.removeClassPath(classPath); // <-- remove BaseClassLoader@xxxxxx{vfs:///D:/retailHub/loan/server/default/deploy/myProject.ear} classpath
classPath.close();
classes.clear();
softcache.clear();
}
During joint point creation the myProject.war class loader is used, it redirects calls to JBossClClassPoolDomain, and in turn to SuperClassesFirstWeavingStrategy, and finally
the reference to the old ClassPool (with a lot of byte array class paths) is used. Is has no myProject.ear ClassLoader any more, so NotFoundException is fired.
I don't know how to fix this, I will appreciate your help.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/715200#715200]
Start a new discussion in JBoss AOP at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 8 months