[JBoss AOP] - Is there a static vs. dynamic binding problem with jboss aop
by manu4ever
Further to my question below, here's another example where something really seriously screwy is happening. The basic infrastructure comes from the docs/aspect-framework/examples/annotation example, but some of the files are modified and there is one new file:
Driver.java
=======
public class Driver {
public static void main(String[] args) {
SUBPOJO spojo = new SUBPOJO(2);
spojo.someMethod();
}
}
POJO.java
=======
public class POJO {
@trace int field;
public POJO() {
}
public POJO(int i) {
field = i;
}
@billable public void someMethod() {
System.out.println("someMethod");
System.out.println("FIELD = " + field);
}
}
SUBPOJO.java
=========
public class SUBPOJO extends POJO {
private int field;
public SUBPOJO() {
}
public SUBPOJO(int i) {
super(i/2);
field = i;
}
public void someMethod() {
System.out.println("ENTERING SUBPOJO:someMethod");
super.someMethod();
System.out.println("LEAVING SUBPOJO:someMethod");
}
}
Here is the jboss-aop.xml file:
<?xml version="1.0" encoding="UTF-8"?>
| <aop>
| <bind pointcut="execution(POJO->@billable(..))">
| <interceptor class="BillingInterceptor"/>
| </bind>
| <bind pointcut="execution(* POJO->@billable(..))">
| <interceptor class="BillingInterceptor"/>
| </bind>
| <bind pointcut="all(@trace)">
| <interceptor class="TraceInterceptor"/>
| </bind>
| </aop>
If I remove the "@trace" from the definition of field "field" in POJO.java then this works almost as expected:
run:
[java] ENTERING SUBPOJO:someMethod
[java] billing...[advisedMethod=public void POJO.someMethod(), unadvisedMethod=public void POJO.POJO$someMethod$aop(), metadata=null, targetObject=SUBPOJO@a4e743, arguments=null]
[java] someMethod
[java] FIELD = 1
[java] LEAVING SUBPOJO:someMethod
FIELD is correctly displayed as 1 (the value of POJO.field). I say "almost" because I don't expect "billable" to be applied but suspect there's some means of making that happen.
However if I put back the "@trace" in the definition of "field" in POJO.java then this is what happens:
run:
[java] <<< Trace : write field name: int POJO.field
[java] >>> Leaving Trace
[java] <<< Trace : write field name: int POJO.field
[java] >>> Leaving Trace
[java] ENTERING SUBPOJO:someMethod
[java] billing...[advisedMethod=public void POJO.someMethod(), unadvisedMethod=public void POJO.POJO$someMethod$aop(), metadata=null, targetObject=SUBPOJO@1112783, arguments=null]
[java] someMethod
[java] <<< Trace : read field name: int POJO.field
[java] >>> Leaving Trace
[java] FIELD = 2
[java] LEAVING SUBPOJO:someMethod
Now the value read for field is WRONG. It is reading SUBPOJO.field rather than POJO.field. This appears to be because of the way that jboss aop rewrites the accessor method, switching from static to dynamic binding.
Even more oddly, if I change jboss-aop.xml to look like this:
<?xml version="1.0" encoding="UTF-8"?>
| <aop>
| <bind pointcut="call(POJO->@billable(..))">
| <interceptor class="BillingInterceptor"/>
| </bind>
| <bind pointcut="call(* POJO->@billable(..))">
| <interceptor class="BillingInterceptor"/>
| </bind>
| <bind pointcut="all(@trace)">
| <interceptor class="TraceInterceptor"/>
| </bind>
| </aop>
Then this is what happens:
run:
[java] <<< Trace : write field name: int POJO.field
[java] >>> Leaving Trace
[java] <<< Trace : write field name: int POJO.field
[java] >>> Leaving Trace
[java] ENTERING SUBPOJO:someMethod
[java] billing...SUBPOJO_1_MByMInvocation@1989f84
[java] ENTERING SUBPOJO:someMethod
[java] billing...SUBPOJO_1_MByMInvocation@110c424
[java] ENTERING SUBPOJO:someMethod
[java] billing...SUBPOJO_1_MByMInvocation@1bd2664
[java] ENTERING SUBPOJO:someMethod
[java] billing...SUBPOJO_1_MByMInvocation@1238bd2
[java] ENTERING SUBPOJO:someMethod
[java] billing...SUBPOJO_1_MByMInvocation@b0bad7
etc etc....
Ad infinitum, or at least until there is a stack overflow. This also appears to be down to a code rewrite that replaces static binding with dynamic binding.
Is there some configuration mechanism to avoid these errors - which are about as fundamental as I can imagine - or do I switch to aspectj which seems to get this right?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968029#3968029
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3968029
19 years, 8 months
[JNDI/Naming/Network] - Re: JNDI datasource not available in one webapp while its av
by wfenthusiast
sorry I had been trying to get the datasource using both OracleDS and was checking with MyDS and hence got the the code and stacktrace mixed up here's how its gotta look
15:57:43,414 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:name=MyDS,service=DataSourceBinding' to JNDI name 'java:MyDS'
InitialContext ctxt = new InitialContext();
| Object o = ctxt.lookup("java:/MyDS");
| DataSource ds = (DataSource) PortableRemoteObject.narrow(o, DataSource.class);
javax.naming.NameNotFoundException: MyDS not bound
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
| at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:281)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
| at javax.naming.InitialContext.lookup(InitialContext.java:347)
| at org.foo.bar.db.DataSourceAccess.retrieveDataSource(DataSourceAccess.java:143)
myds-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
| <datasources>
| <local-tx-datasource>
| <jndi-name>MyDS</jndi-name>
| <connection-url>jdbc:oracle:thin:@oradev:1521:dev</connection-url>
| <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
| <user-name>dev</user-name>
| <password>dev</password>
| <exception-sorter-class-name>
| org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
| </exception-sorter-class-name>
| <min-pool-size>10</min-pool-size>
| <max-pool-size>50</max-pool-size>
| <idle-timeout-minutes>10</idle-timeout-minutes>
| <track-statements>true</track-statements>
| <metadata>
| <type-mapping>Oracle10g</type-mapping>
| </metadata>
| </local-tx-datasource>
| </datasources>
|
thanks jaikiran for pointing that out but, I assure you its certainly not because of using mixed up names
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968027#3968027
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3968027
19 years, 8 months
[JBoss jBPM] - Re: Migration from Vitria to jBPM
by tom.baeyens@jboss.com
there is a very important aspect that you have to keep in mind when converting processes from one language to another.
writing executable business processes (like the vitria processes) is writing software in the sense that you are specifying how the BPMS software should behave. this is different from analysing and describing how people and systems work together (= the actual business process). when creating the vitria processes, you have already made a mapping between the actual business processes to executable vitria processes with the constructs available in vitria process language.
it might not always be the best approach to just try and convert the processes automatically. as the design of the vitria processes was influenced by the available constructs in the vitria language.
overall, jPDL will be quite flexible to accomodate such a conversion. but you should take into account that you probably would have created different processes when using jPDL for your initial process langauge. so practically, the best approach i think is to create a simplistic conversion that doesn't include all the details. Then take that as a starting point. This will include a manually revision since there is no standard process language yet.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968023#3968023
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3968023
19 years, 8 months