jboss


Issue with application where EJB connection is left open and subsequent connections are opened and closed


Is it common or acceptable to keep and ejb connection opened while opening and closing other ejb connections or should connections be closed as soon as the client is done with it and a new one opened for subsequent tasks?
I'm currently working on a Swing application that uses EJBs (JBoss AS 7.1.1.final). The application opens an ejb connection (i.e. creates an InitialContext instance) and then uses that InitialContext for common tasks for the as long as the application is left running. There are a number of long running operations where an additional ejb connection (and InitialContext) is created. This connection is used for the single long running process and is then closed.
On JBoss, after about the 40th connection is opened and closed I get the exception shown below.
2017 May 15, 16:29:03 INFO - (JBossEJBClient.java:121) initialize - JNDI context initialized.
java.lang.IllegalStateException: No EJB receiver available for handling [appName:dtsjboss,modulename:dtsserverejb,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext#4e692639
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
at com.sun.proxy.$Proxy4.getAuthorities(Unknown Source)
at com.apelon.dts.examples.errors.ejb.EjbConnectionNotClosedErrorExample.doTest(EjbConnectionNotClosedErrorExample.java:53)
at com.apelon.dts.examples.errors.ejb.EjbConnectionNotClosedErrorExample.bothCasesShouldSucceed(EjbConnectionNotClosedErrorExample.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
If I run the code below, the case where the ejb connections are used and closed works but the case where a single connection is left open fails with the above stack trace.
package com.myCompany.myApp.examples.errors.ejb;
import java.util.List;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.apache.log4j.Logger;
import org.junit.Test;
import com.myCompany.myApp.client.jboss.JBossEJBClient;
import com.myCompany.myApp.dao.client.myAppServiceClient;
import com.myCompany.myApp.dao.client.myAppServiceClientParams;
import com.myCompany.myApp.testing.util.logging.LoggerForIntegrationTests;
import com.myCompany.myAppserver.dao.remote.AuthorityDao;
import com.myCompany.myAppserver.types.TAuthority;
import com.myCompany.install.util.ejb.ejbclient.myAppServiceClientFactory;
public class EjbConnectionNotClosedErrorExample {
private static Logger logger = LoggerForIntegrationTests.get();
private static final int COUNT = 100;
#Test
public void bothCasesShouldSucceed() {
try {
logger.debug("Doing case that works");
doTest(true);
logger.debug("Done with case that works.");
logger.debug("\n\n\n");
logger.debug("********************* DOING CASE THAT FAILS *********************");
doTest(false);
logger.debug("Done with use case that didn't work.");
} catch (Exception exp) {
exp.printStackTrace();
throw new RuntimeException(exp);
}
}
private void doTest(boolean closeConnection) {
myAppServiceClientParams params = myAppServiceClientFactory.getDefaultClientParams();
JBossEJBClient blocker = new JBossEJBClient();
blocker.initialize(params);
if (closeConnection == true) {
blocker.close();
}
int max = COUNT;
for (int i = 0; i < max; i++) {
myAppServiceClient client = myAppServiceClientFactory.getDefaultClient();
AuthorityDao dao = client.createAuthorityDao();
List<TAuthority> list = dao.getAuthorities();
logger.debug("CONNECTION " + (i + 1) + " ------------------------------------------------");
logger.debug("Got " + list.size() + " authorities.");
client.close();
}
System.out.println("");
}
public void initialize(myAppServiceClientParams params) {
this.initialize(params.getHost(), params.getPort(), params.getInstance(), params.getUid(), params.getPwd());
}
public void initialize(String host, int port, String instance, String user, String password) {
final Properties jndiProperties = new Properties();
String providerURL = "remote://" + host + ":" + port;
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
jndiProperties.put(Context.PROVIDER_URL, providerURL);
jndiProperties.put("jboss.naming.client.ejb.context", true);
jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
// Explicitly specify STARTTLS = false for connecting to Wildfly v10
jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SSL_STARTTLS", "false");
jndiProperties.put(Context.SECURITY_PRINCIPAL, user);
jndiProperties.put(Context.SECURITY_CREDENTIALS, password);
try {
InitialContext ctx = new InitialContext(jndiProperties);
ctx.getEnvironment();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Is this a bug that is specific to JBoss AS 7.1.1.final?

Related Links

Exception : java.lang.NoClassDefFoundError: IllegalName: org/jibx/binding/Compile
EJB Server Detection
How to run a drools planner project on jboss as?
Running OSGI from within jboss invoking jax-ws service
configuring jboss to send an email
JBoss 7.1.1 and JBoss Web Native
Jboss default deployer war size is more than the same export using eclipse .why?
JBoss Drools verifier with custom evaluators
Action not triggered in seam
How do I start/stop JBoss on system startup on Mac Lion?
LHS condition about duration how I can
JBPM workflow deployment into alfresco error
jBPM and JBoss web app
Trying to deploy a JBoss Seam application to WebSphere CE
how to set jboss.bind.address.management and jboss.bind.address.unsecure to the same value as jboss.bind.address?
On JBoss 4.2.3.GA - JSP response header transfer-encoding:chunked makes it so I can't cache jsp content on load balancer

Categories

HOME
nam
keyboard
ant
initialization
openlayers-3
odata
apk
google-play-services
dronekit-python
nsis
hyperledger
firebase-dynamic-links
native-base
clickable-image
yahoo
parsley.js
jquery-file-upload
powermock
varnish-vcl
spam
libgit2
yii2-basic-app
neo4j.rb
qa
perfino
pyopencl
crud
uilocalnotification
oracleforms
microprocessors
locks
google-play-developer-api
cloveretl
db2-luw
express-session
transform
grails-2.5
bluemixtools
testlink
code-rally
cartopy
unification
microkernel
plane
fluid-mac-app-engine
zend-form
music21
adblock
section508
nonlinear-functions
sonicmq
jgrapht
amazon-elastic-beanstalk
karabiner
simple-schema
gnome-terminal
mpmovieplayercontroller
wildfly-9
ndk-build
persistent-object-store
as3-api
univocity
management-studio-express
wif4.5
arbre
fanotify
enaml
featuretoggle
postal-code
fantom
componentart
tree-structure
shell-extensions
nsmutabledata
maven-shade-plugin
tkx
image-rotation
zend-mail
distributed-r
network-printers
screwturn
neo4jphp
reference-counting
map
profiles
django-sites
lsa
saga
iirf
spiral
reentrancy
2d-vector
office-app
email-verification
semantic-merge
thejit
kaazing
zotonic
prototypal-inheritance
nsfont
netstream
servercontrol
mongrel
3270
processors
source-code-protection
motif
prism-2
levels
community-server

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App