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

Deploying on wildfly produces “Unable to acquire lock after 15 seconds” exception
JBoss EAP 6.2 running as Window Service with prunsrv - Can't stop service
JBoss 7 as operation unstable
Not able to connect to AS in Docker container
JBoss: Unmatched braces in the pattern
Openshift jbossews cartridge connection refused from outside but reachable from localhost
Failed to create remoting connection in Jboss-eap 6.4 HornetQ
Changing Liferay war file context root on JBoss EAP
How to configure to a role group in LdapExtLoginModule in JBOSS EAP 6.3?
Failed to boot JBoss:java.lang.NullPointerException
jsf faces Inject not working while deploying to wildfly
Keycloak Roles Synchronization Event Listener
Deployment failed in WildFly 8.2.0 Final
Wildfly 9.0.1.Final: EAR deployment failed
WildFly 8.2 unable to configure for external property file
how to download war files from wildfly 8

Categories

HOME
macos-sierra
class
list
matrix
dotnetnuke
seedstack
d3.js
swi-prolog
antd
compilation
gallery
liferay-7
apache-kafka-connect
navigation
dji-sdk
sympy
cisco
amazon-emr
fbloginview
sap-fiori
spring-amqp
bundler
dhcp
texas-instruments
mixpanel
coroutine
nullreferenceexception
scheduled-tasks
multiple-tables
weex
intel
device
fusetools
uilocalnotification
adapter
audit
toad
python-2.x
knights-tour
gnu-classpath
ms-solver-foundation
twilio-php
cheat-engine
sspi
android-n
selenide
reset
flowchart
vb.net-to-c#
viewcontroller
robust
notesview
virtual-memory
qvtkwidget
ol3-google-maps
karabiner
maven-jaxb2-plugin
watir-webdriver
mura
polymaps
business-rules
dymola
front-camera
cognos-tm1
dmarc
traversable
nsdata
yii2-model
powerpoint-2013
gnucash
gwt-syncproxy
wepay
opencyc
wlanapi
sequence-sql
bootstrap-wysiwyg
abstract-factory
erlog
htmltidy
sql-processor
directorysearcher
mft
quickgraph
xalan
coordinate
kaazing
series-40
net-use
getopts
nsrangeexception
uipasteboard
kohana-auth
fragment-identifier
digiflow
fgetc
html-components
eai
jboss-mdb
rendering-engine
service-factory
synthesizer

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