Hello,
i tried to create a pojo and load it to Guvnor which would call an EJB on
the same Jboss AS 7.1.
Below code works in another app without problem.
public class Calculation implements IFCalculation {
IFRemoteCalculation remoteCalculation;
public Calculation() {
final String jndiName =
"java:global/remoteejb/CalculationBean!com.gp.IFRemoteCalculation";
try {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jboss.as.naming.InitialContextFactory");
env.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
Context ic = new InitialContext(env);
System.out.println("about to look up jndi name " + jndiName);
Object obj = ic.lookup(jndiName);
System.out.println("lookup returned " + obj);
remoteCalculation = (IFRemoteCalculation) obj;
} catch (NamingException e) {
System.out.println("Nem talatam meg a calculation beant! " + e);
}
}
public void add(String s, int faktor) {
remoteCalculation.add(s, faktor);
}
public String getItems() {
return remoteCalculation.getItems();
}
public void setItems() {
remoteCalculation.setItems();
}
}
When i load this as a POJO and try to use it in a Guvnor test scenario with
my rules i get following error:
12:47:17,673 ERROR [org.drools.guvnor.server.RepositoryAssetService]
(http--127.0.0.1-8080-5) Unable to run the scenario.: [Error: could not
instantiate class: null]
[Near : {... new com.gp.Calculation() ....}]
^
[Line: 1, Column: 5]
at org.mvel2.ast.NewObjectNode.getReducedValue(NewObjectNode.java:294)
[mvel2-2.1.0.drools4.jar:]
at
org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:106)
[mvel2-2.1.0.drools4.jar:]
at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:49)
[mvel2-2.1.0.drools4.jar:]
at org.mvel2.MVEL.eval(MVEL.java:92) [mvel2-2.1.0.drools4.jar:]
at
org.drools.testframework.ScenarioRunner.runScenario(ScenarioRunner.java:162)
[droolsjbpm-ide-common-5.3.0.Final.jar:5.3.0.Final]
at org.drools.testframework.ScenarioRunner.<init>(ScenarioRunner.java:89)
[droolsjbpm-ide-common-5.3.0.Final.jar:5.3.0.Final]
at
org.drools.guvnor.server.RepositoryPackageService.runScenario(RepositoryPackageService.java:696)
[classes:]
at
org.drools.guvnor.server.RepositoryPackageService.runScenario(RepositoryPackageService.java:559)
[classes:]
at
org.drools.guvnor.server.RepositoryPackageService.runScenario(RepositoryPackageService.java:540)
[classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[rt.jar:1.6.0_20]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[rt.jar:1.6.0_20]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.6.0_20]
at java.lang.reflect.Method.invoke(Method.java:616) [rt.jar:1.6.0_20]
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:163)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.drools.guvnor.server.RepositoryPackageService_$$_javassist_seam_5.runScenario(RepositoryPackageService_$$_javassist_seam_5.java)
[classes:]
at
org.drools.guvnor.server.RepositoryServiceServlet.runScenario(RepositoryServiceServlet.java:364)
[classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[rt.jar:1.6.0_20]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[rt.jar:1.6.0_20]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.6.0_20]
at java.lang.reflect.Method.invoke(Method.java:616) [rt.jar:1.6.0_20]
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
[gwt-servlet-2.3.0.jar:]
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
[gwt-servlet-2.3.0.jar:]
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
[gwt-servlet-2.3.0.jar:]
at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
[gwt-servlet-2.3.0.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
[jbossweb-7.0.10.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.10.Final.jar:]
at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:65)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
[jboss-seam-2.2.2.Final.jar:2.2.2.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.10.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.10.Final.jar:]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.10.Final.jar:]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.10.Final.jar:]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154)
[jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.10.Final.jar:]
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.10.Final.jar:]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.10.Final.jar:]
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
[jbossweb-7.0.10.Final.jar:]
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.10.Final.jar:]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
[jbossweb-7.0.10.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
[jbossweb-7.0.10.Final.jar:]
at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_20]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[rt.jar:1.6.0_20]
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[rt.jar:1.6.0_20]
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[rt.jar:1.6.0_20]
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
[rt.jar:1.6.0_20]
at org.mvel2.ast.NewObjectNode.getReducedValue(NewObjectNode.java:268)
[mvel2-2.1.0.drools4.jar:]
... 56 more
Caused by: java.lang.NullPointerException
at
com.sun.naming.internal.VersionHelper12$InputStreamEnumeration$1.run(VersionHelper12.java:214)
[rt.jar:1.6.0_20]
at java.security.AccessController.doPrivileged(Native Method)
[rt.jar:1.6.0_20]
at
com.sun.naming.internal.VersionHelper12$InputStreamEnumeration.getNextElement(VersionHelper12.java:211)
[rt.jar:1.6.0_20]
at
com.sun.naming.internal.VersionHelper12$InputStreamEnumeration.hasMore(VersionHelper12.java:231)
[rt.jar:1.6.0_20]
at
com.sun.naming.internal.ResourceManager.getApplicationResources(ResourceManager.java:487)
[rt.jar:1.6.0_20]
at
com.sun.naming.internal.ResourceManager.getInitialEnvironment(ResourceManager.java:176)
[rt.jar:1.6.0_20]
at javax.naming.InitialContext.init(InitialContext.java:236)
[rt.jar:1.6.0_20]
at javax.naming.InitialContext.<init>(InitialContext.java:214)
[rt.jar:1.6.0_20]
at com.gp.Calculation.<init>(Calculation.java:23)
[drools-core-5.3.0.Final.jar:]
... 61 more
It seems it is not possible to get InitialContext in a pojo uploaded to
Guvnor - or is there any way?
Peter
--
View this message in context:
http://drools.46999.n3.nabble.com/Guvnor-pojo-InitialConext-tp3756527p375...
Sent from the Drools: User forum mailing list archive at
Nabble.com.