[JBoss AOP] - Re: IllegalAccessException using reflection on private field
by flavia.rainone@jboss.com
Hello,
I've taken a look at your problem and at the bug report you added to Jira (issue JBAOP-405).
The cause of your problem is not the fact that setAccessible doesn't take place. On the contrary, it does take place and has the desired effect (it allows calls to Field.get() and Field.set() methods). But, in your code, setting the field as accessible is unnecessary, since JBoss AOP will call a wrapper method it has generated instead of Field.set() and Field.get() methods. JBoss AOP will do this in order to trigger your TestAspect.
The problem here is that this wrapper is generated as a private method inside TestObject class, and therefore it is not accessible from ReflectionAspect, which is a bug.
While we take a look at the problem, you can intercept reflection calls using the other approach ReflectionAspect provides: to extend ReflectionAspect and override interceptFieldWrite and interceptFieldRead methods.
| // TestAspect.java
| package test;
|
| public class TestAspect extends ReflectionAspect
| {
| public Object interceptFieldRead(Invocation invocation, Field field, Object instance) throws Throwable
| {
| System.out.println(instance.getClass().getName() + "." + field.getName() + " being read on instance " + instance);
| return invocation.invokeNext();
| }
|
| public Object interceptFieldWrite(Invocation invocation, Field field, Object instance, Object arg) throws Throwable
| {
| System.out.println(instance.getClass().getName() + "." + field.getName() + " being set on instance " + instance + " with the following value \"" + arg + "\"");
| return invocation.invokeNext();
| }
| }
|
With the approach above, just replace your jboss-aop.xml file by the following:
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
| <aop>
| <aspect name="MyReflectionAspect" class="MyReflectionAspect" scope="PER_VM"/>
|
| <bind pointcut="call(* java.lang.reflect.Field->get*(..))">
| <advice name="interceptFieldGet" aspect="MyReflectionAspect"/>
| </bind>
|
| <bind pointcut="call(* java.lang.reflect.Field->set*(..))">
| <advice name="interceptFieldSet" aspect="MyReflectionAspect"/>
| </bind>
| </aop>
|
This way, JBoss AOP won't perform a call to the wrapper method; it will proceed to Field.set() and Field.get() executions. Notice that, because of this, you need to keep your setAccessible calls.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048060#4048060
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048060
18 years, 11 months
[JBoss Messaging] - Queue MessageCount - JMX Help
by kemplin
I am attempting to get access to a Queue via JMX so I can check to see the number of messages (MessageCount).
I created the queue upon startup of JBoss by copying the default demo Queues in destinations-service.xml
<mbean code="org.jboss.jms.server.destinatiosn.QueueService"
name="jboss.messaging.destination:service=Queue,name=myqueue xmbean-dd="xmdesc/Queue-xmbean.xml">
<depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer
jboss.message:service=PostOffice
Inside my code I have the following:
Properties props = new Propeties();
| props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
| props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
|
| InitialContext ctx = new InitialContext(props);
|
| Object o = ctx.lookup("jmx/rmi/RMIAdaptor");
the object that is returned is a JRMPInvokerProxy, when I expected to get back an RMIAdaptor (as per all the examples I've seen).
Does anyone know why I'm getting this class? I expected to get an RMIAdaptor.
If I cast it as an RMIAdaptor and then invoke the method:
rmiAdaptor.getAttribute("jboss.messaging.destination:service=Queue,name=myqueue", "MessageCount")
|
I get an UnmarshalException....ClassNotFoundException org.jboss.jmx.connector.invoker.client.InvokerAdaptorException (no security manager: RMI class loader disabled).
If someone can help, I'd really appreciate it. As you can tell, I'm new to JMX and trying to figure this out. If you have an example of getting the message count, I'd *really* appreciate it :-)
| In my classpath, I have jboss-messaging-client.jar.
| I'm using JBoss 4.0.5,
| messaging 1.2.0sp1,
| and JDK 6.
|
|
| thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048058#4048058
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048058
18 years, 11 months
[Management, JMX/JBoss] - " No ClassLoaders found " error when deploying a startup cla
by mohali
I am trying to deploy a simple start up class at JBoss startup time and it keeps giving the following error:
[java] Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: com.acme.common.business.taskmanagement.TaskTimerStartup
| [java] at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306
| )
| [java] at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(Repo
| sitoryClassLoader.java:514)
| [java] at org.jboss.mx.loading.RepositoryClassLoader.loadClass(Reposito
| ryClassLoader.java:408)
| [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
| [java] at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerIm
| pl.java:1204)
| [java] at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerIm
| pl.java:286)
| [java] at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerIm
| pl.java:344)
| [java] at org.jboss.system.ServiceCreator.install(ServiceCreator.java:1
| 57)
| [java] at org.jboss.system.ServiceConfigurator.internalInstall(ServiceC
| onfigurator.java:449)
| [java] at org.jboss.system.ServiceConfigurator.install(ServiceConfigura
| tor.java:171)
The TaskTimerStartup class extends ServiceMBeanSupport and implements TaskTimerMBean interface.
I have put both these classes and jboss-service.xml in a sar file and deployed it with my ear file. I also added the following entry to application.xml
<module><java>timer.sar</java></module>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048055#4048055
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048055
18 years, 11 months
[JBoss Portal] - Re: LDAP Authentication & Authorization to eDirectory
by bdaw
a lot of questions in your posts :)
... lets start from the beginning. I'm sure that the issue with disabled account should be resolved in newest sources. Did you flush the database content? Please try to redeploy portal from the newest sources, start with clean database, and let me know if you have still issues.
To have admin account portal needs to resolve account 'admin' with role 'Admin'. So I beleive that if you change 'Administrators' to 'Admin' in your LDAP you should get proper privilages.
You can workaround this by uncommenting following lines in login-config.xml:
anonymous wrote :
| <login-module code = "org.jboss.portal.identity.auth.DBIdentityLoginModule" flag="sufficient">
| <module-option name="dsJndiName">java:/PortalDS</module-option>
| <module-option name="principalsQuery">SELECT jbp_password FROM jbp_users WHERE jbp_uname=?</module-option>
| <module-option name="rolesQuery">SELECT jbp_roles.jbp_name, 'Roles' FROM jbp_role_membership INNER JOIN jbp_roles ON jbp_role_membership.jbp_rid = jbp_roles.jbp_rid INNER JOIN jbp_users ON jbp_role_membership.jbp_uid = jbp_users.jbp_uid WHERE jbp_users.jbp_uname=?</module-option>
| <module-option name="hashAlgorithm">MD5</module-option>
| <module-option name="hashEncoding">HEX</module-option>
| <module-option name="additionalRole">Authenticated</module-option>
| </login-module>
|
and remove admin account from your LDAP. This will enable portal to use built in 'admin' account from the database. Please look at "Authentication and Authorization' chapter in latest 2.6 Reference Guide to learn more about this configuration.
If you update to latest portal sources:
svn co http://anonsvn.jboss.org/repos/portal/trunk/ jboss-portal-2.6
Then you can edit those configuration files directly in:
portal-sources/core/src/resources/portal-core-sar/ ...
then simply set JBOSS_HOME env and deploy whole using
portal-sources/build/build.sh deploy-all
I hope this will help you to avoid unpacking the jars :)
If you have issues with 'seeAlso' attribute just remove related 'ldap' mapping from profile-config.xml file.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048050#4048050
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048050
18 years, 11 months