jboss ejb-client example: Exception in thread “main” javax.naming.NoInitialContextException:
I am trying to run the following example for a quite sometime in eclipse.
https://github.com/jboss-developer/jboss-eap-quickstarts/tree/master/ejb-remote
I have created an ejb project and imported all the class files and put .properties files in META-INF. now there is no error in code and ejbs are deployed on JBoss server successfully. When I try to run RemoteEJBClient.java, I am getting following exception, which I am not able to fix.
Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.lookupRemoteStatelessCalculator(RemoteEJBClient.java:131)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:50)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.main(RemoteEJBClient.java:37)
please help me in sort out this issue
main standalone class:
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.as.quickstarts.ejb.remote.client;
import org.jboss.as.quickstarts.ejb.remote.stateful.RemoteCounter;
import org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;
/**
* A sample program which acts a remote client for a EJB deployed on AS7 server.
* This program shows how to lookup stateful and stateless beans via JNDI and
* then invoke on them
*
* @author Jaikiran Pai
*/
public class RemoteEJBClient {
public static void main(String args) throws Exception {
// Invoke a stateless bean
invokeStatelessBean();
// Invoke a stateful bean
// invokeStatefulBean();
}
/**
* Looks up a stateless bean and invokes on it
*
* @throws NamingException
*/
private static void invokeStatelessBean() throws NamingException {
// Let's lookup the remote stateless calculator
final RemoteCalculator statelessRemoteCalculator = lookupRemoteStatelessCalculator();
System.out
.println("Obtained a remote stateless calculator for invocation");
// invoke on the remote calculator
int a = 204;
int b = 340;
System.out
.println("Adding "
+ a
+ " and "
+ b
+ " via the remote stateless calculator deployed on the server");
int sum = statelessRemoteCalculator.add(a, b);
System.out.println("Remote calculator returned sum = " + sum);
if (sum != a + b) {
throw new RuntimeException(
"Remote stateless calculator returned an incorrect sum "
+ sum + " ,expected sum was " + (a + b));
}
// try one more invocation, this time for subtraction
int num1 = 3434;
int num2 = 2332;
System.out
.println("Subtracting "
+ num2
+ " from "
+ num1
+ " via the remote stateless calculator deployed on the server");
int difference = statelessRemoteCalculator.subtract(num1, num2);
System.out.println("Remote calculator returned difference = "
+ difference);
if (difference != num1 - num2) {
throw new RuntimeException(
"Remote stateless calculator returned an incorrect difference "
+ difference + " ,expected difference was "
+ (num1 - num2));
}
}
/**
* Looks up a stateful bean and invokes on it
*
* @throws NamingException
*/
private static void invokeStatefulBean() throws NamingException {
// Let's lookup the remote stateful counter
final RemoteCounter statefulRemoteCounter = lookupRemoteStatefulCounter();
System.out.println("Obtained a remote stateful counter for invocation");
// invoke on the remote counter bean
final int NUM_TIMES = 5;
System.out.println("Counter will now be incremented " + NUM_TIMES
+ " times");
for (int i = 0; i < NUM_TIMES; i++) {
System.out.println("Incrementing counter");
statefulRemoteCounter.increment();
System.out.println("Count after increment is "
+ statefulRemoteCounter.getCount());
}
// now decrementing
System.out.println("Counter will now be decremented " + NUM_TIMES
+ " times");
for (int i = NUM_TIMES; i > 0; i--) {
System.out.println("Decrementing counter");
statefulRemoteCounter.decrement();
System.out.println("Count after decrement is "
+ statefulRemoteCounter.getCount());
}
}
/**
* Looks up and returns the proxy to remote stateless calculator bean
*
* @return
* @throws NamingException
*/
private static RemoteCalculator lookupRemoteStatelessCalculator()
throws NamingException {
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
/*
* remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=
* false
*
* remote.connections=default
*
* remote.connection.default.host=localhost
* remote.connection.default.port = 4447
* remote.connection.default.connect
* .options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
*/
jndiProperties
.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED",
false);
jndiProperties.put("remote.connections", "default");
jndiProperties.put("remote.connection.default.host", "localhost");
jndiProperties.put("remote.connection.default.port", "4447");
jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS",false);
final Context context = new InitialContext(jndiProperties);
// The JNDI lookup name for a stateless session bean has the syntax of:
// ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>
//
// <appName> The application name is the name of the EAR that the EJB is
// deployed in
// (without the .ear). If the EJB JAR is not deployed in an EAR then
// this is
// blank. The app name can also be specified in the EAR's
// application.xml
//
// <moduleName> By the default the module name is the name of the EJB
// JAR file (without the
// .jar suffix). The module name might be overridden in the ejb-jar.xml
//
// <distinctName> : AS7 allows each deployment to have an (optional)
// distinct name.
// This example does not use this so leave it blank.
//
// <beanName> : The name of the session been to be invoked.
//
// <viewClassName>: The fully qualified classname of the remote
// interface. Must include
// the whole package name.
// let's do the lookup
return (RemoteCalculator) context
.lookup("java:global/ejb-remote/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator");
}
/**
* Looks up and returns the proxy to remote stateful counter bean
*
* @return
* @throws NamingException
*/
private static RemoteCounter lookupRemoteStatefulCounter()
throws NamingException {
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
// The JNDI lookup name for a stateful session bean has the syntax of:
// ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful
//
// <appName> The application name is the name of the EAR that the EJB is
// deployed in
// (without the .ear). If the EJB JAR is not deployed in an EAR then
// this is
// blank. The app name can also be specified in the EAR's
// application.xml
//
// <moduleName> By the default the module name is the name of the EJB
// JAR file (without the
// .jar suffix). The module name might be overridden in the ejb-jar.xml
//
// <distinctName> : AS7 allows each deployment to have an (optional)
// distinct name.
// This example does not use this so leave it blank.
//
// <beanName> : The name of the session been to be invoked.
//
// <viewClassName>: The fully qualified classname of the remote
// interface. Must include
// the whole package name.
// let's do the lookup
return (RemoteCounter) context
.lookup("ejb:/jboss-ejb-remote-server-side/CounterBean!"
+ RemoteCounter.class.getName() + "?stateful");
}
}
jboss-ejb-client.properties
#
# JBoss, Home of Professional Open Source
# Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
# contributors by the @authors tag. See the copyright.txt in the
# distribution for a full listing of individual contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
running pom.xml, is also full of errors. which probably is saying that jboss provided pom.xml will not work also
[ERROR] Non-resolvable import POM: Failure to find org.jboss.spec:jboss-javaee-6.0:pom:3.0.2.Final-redhat-4 in http://repo.maven.apache.
org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or update
s are forced @ line 72, column 22 -> [Help 2]
[ERROR] Non-resolvable import POM: Failure to find org.jboss.as:jboss-as-ejb-client-bom:pom:7.2.1.Final-redhat-10 in http://repo.maven.a
pache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or
updates are forced @ line 80, column 22 -> [Help 2]
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar is missing. @ line 94,
column 19
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:jar is missing. @ line 102, column 19
[ERROR] 'dependencies.dependency.version' for org.jboss:jboss-ejb-client:jar is missing. @ line 118, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.xnio:xnio-api:jar is missing. @ line 125, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.xnio:xnio-nio:jar is missing. @ line 131, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.remoting3:jboss-remoting:jar is missing. @ line 138, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.sasl:jboss-sasl:jar is missing. @ line 145, column 21
[ERROR] 'dependencies.dependency.version' for org.jboss.marshalling:jboss-marshalling-river:jar is missing. @ line 152, column 21
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
java eclipse java-ee jboss ejb-3.0
add a comment |
I am trying to run the following example for a quite sometime in eclipse.
https://github.com/jboss-developer/jboss-eap-quickstarts/tree/master/ejb-remote
I have created an ejb project and imported all the class files and put .properties files in META-INF. now there is no error in code and ejbs are deployed on JBoss server successfully. When I try to run RemoteEJBClient.java, I am getting following exception, which I am not able to fix.
Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.lookupRemoteStatelessCalculator(RemoteEJBClient.java:131)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:50)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.main(RemoteEJBClient.java:37)
please help me in sort out this issue
main standalone class:
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.as.quickstarts.ejb.remote.client;
import org.jboss.as.quickstarts.ejb.remote.stateful.RemoteCounter;
import org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;
/**
* A sample program which acts a remote client for a EJB deployed on AS7 server.
* This program shows how to lookup stateful and stateless beans via JNDI and
* then invoke on them
*
* @author Jaikiran Pai
*/
public class RemoteEJBClient {
public static void main(String args) throws Exception {
// Invoke a stateless bean
invokeStatelessBean();
// Invoke a stateful bean
// invokeStatefulBean();
}
/**
* Looks up a stateless bean and invokes on it
*
* @throws NamingException
*/
private static void invokeStatelessBean() throws NamingException {
// Let's lookup the remote stateless calculator
final RemoteCalculator statelessRemoteCalculator = lookupRemoteStatelessCalculator();
System.out
.println("Obtained a remote stateless calculator for invocation");
// invoke on the remote calculator
int a = 204;
int b = 340;
System.out
.println("Adding "
+ a
+ " and "
+ b
+ " via the remote stateless calculator deployed on the server");
int sum = statelessRemoteCalculator.add(a, b);
System.out.println("Remote calculator returned sum = " + sum);
if (sum != a + b) {
throw new RuntimeException(
"Remote stateless calculator returned an incorrect sum "
+ sum + " ,expected sum was " + (a + b));
}
// try one more invocation, this time for subtraction
int num1 = 3434;
int num2 = 2332;
System.out
.println("Subtracting "
+ num2
+ " from "
+ num1
+ " via the remote stateless calculator deployed on the server");
int difference = statelessRemoteCalculator.subtract(num1, num2);
System.out.println("Remote calculator returned difference = "
+ difference);
if (difference != num1 - num2) {
throw new RuntimeException(
"Remote stateless calculator returned an incorrect difference "
+ difference + " ,expected difference was "
+ (num1 - num2));
}
}
/**
* Looks up a stateful bean and invokes on it
*
* @throws NamingException
*/
private static void invokeStatefulBean() throws NamingException {
// Let's lookup the remote stateful counter
final RemoteCounter statefulRemoteCounter = lookupRemoteStatefulCounter();
System.out.println("Obtained a remote stateful counter for invocation");
// invoke on the remote counter bean
final int NUM_TIMES = 5;
System.out.println("Counter will now be incremented " + NUM_TIMES
+ " times");
for (int i = 0; i < NUM_TIMES; i++) {
System.out.println("Incrementing counter");
statefulRemoteCounter.increment();
System.out.println("Count after increment is "
+ statefulRemoteCounter.getCount());
}
// now decrementing
System.out.println("Counter will now be decremented " + NUM_TIMES
+ " times");
for (int i = NUM_TIMES; i > 0; i--) {
System.out.println("Decrementing counter");
statefulRemoteCounter.decrement();
System.out.println("Count after decrement is "
+ statefulRemoteCounter.getCount());
}
}
/**
* Looks up and returns the proxy to remote stateless calculator bean
*
* @return
* @throws NamingException
*/
private static RemoteCalculator lookupRemoteStatelessCalculator()
throws NamingException {
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
/*
* remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=
* false
*
* remote.connections=default
*
* remote.connection.default.host=localhost
* remote.connection.default.port = 4447
* remote.connection.default.connect
* .options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
*/
jndiProperties
.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED",
false);
jndiProperties.put("remote.connections", "default");
jndiProperties.put("remote.connection.default.host", "localhost");
jndiProperties.put("remote.connection.default.port", "4447");
jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS",false);
final Context context = new InitialContext(jndiProperties);
// The JNDI lookup name for a stateless session bean has the syntax of:
// ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>
//
// <appName> The application name is the name of the EAR that the EJB is
// deployed in
// (without the .ear). If the EJB JAR is not deployed in an EAR then
// this is
// blank. The app name can also be specified in the EAR's
// application.xml
//
// <moduleName> By the default the module name is the name of the EJB
// JAR file (without the
// .jar suffix). The module name might be overridden in the ejb-jar.xml
//
// <distinctName> : AS7 allows each deployment to have an (optional)
// distinct name.
// This example does not use this so leave it blank.
//
// <beanName> : The name of the session been to be invoked.
//
// <viewClassName>: The fully qualified classname of the remote
// interface. Must include
// the whole package name.
// let's do the lookup
return (RemoteCalculator) context
.lookup("java:global/ejb-remote/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator");
}
/**
* Looks up and returns the proxy to remote stateful counter bean
*
* @return
* @throws NamingException
*/
private static RemoteCounter lookupRemoteStatefulCounter()
throws NamingException {
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
// The JNDI lookup name for a stateful session bean has the syntax of:
// ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful
//
// <appName> The application name is the name of the EAR that the EJB is
// deployed in
// (without the .ear). If the EJB JAR is not deployed in an EAR then
// this is
// blank. The app name can also be specified in the EAR's
// application.xml
//
// <moduleName> By the default the module name is the name of the EJB
// JAR file (without the
// .jar suffix). The module name might be overridden in the ejb-jar.xml
//
// <distinctName> : AS7 allows each deployment to have an (optional)
// distinct name.
// This example does not use this so leave it blank.
//
// <beanName> : The name of the session been to be invoked.
//
// <viewClassName>: The fully qualified classname of the remote
// interface. Must include
// the whole package name.
// let's do the lookup
return (RemoteCounter) context
.lookup("ejb:/jboss-ejb-remote-server-side/CounterBean!"
+ RemoteCounter.class.getName() + "?stateful");
}
}
jboss-ejb-client.properties
#
# JBoss, Home of Professional Open Source
# Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
# contributors by the @authors tag. See the copyright.txt in the
# distribution for a full listing of individual contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
running pom.xml, is also full of errors. which probably is saying that jboss provided pom.xml will not work also
[ERROR] Non-resolvable import POM: Failure to find org.jboss.spec:jboss-javaee-6.0:pom:3.0.2.Final-redhat-4 in http://repo.maven.apache.
org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or update
s are forced @ line 72, column 22 -> [Help 2]
[ERROR] Non-resolvable import POM: Failure to find org.jboss.as:jboss-as-ejb-client-bom:pom:7.2.1.Final-redhat-10 in http://repo.maven.a
pache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or
updates are forced @ line 80, column 22 -> [Help 2]
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar is missing. @ line 94,
column 19
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:jar is missing. @ line 102, column 19
[ERROR] 'dependencies.dependency.version' for org.jboss:jboss-ejb-client:jar is missing. @ line 118, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.xnio:xnio-api:jar is missing. @ line 125, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.xnio:xnio-nio:jar is missing. @ line 131, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.remoting3:jboss-remoting:jar is missing. @ line 138, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.sasl:jboss-sasl:jar is missing. @ line 145, column 21
[ERROR] 'dependencies.dependency.version' for org.jboss.marshalling:jboss-marshalling-river:jar is missing. @ line 152, column 21
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
java eclipse java-ee jboss ejb-3.0
add a comment |
I am trying to run the following example for a quite sometime in eclipse.
https://github.com/jboss-developer/jboss-eap-quickstarts/tree/master/ejb-remote
I have created an ejb project and imported all the class files and put .properties files in META-INF. now there is no error in code and ejbs are deployed on JBoss server successfully. When I try to run RemoteEJBClient.java, I am getting following exception, which I am not able to fix.
Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.lookupRemoteStatelessCalculator(RemoteEJBClient.java:131)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:50)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.main(RemoteEJBClient.java:37)
please help me in sort out this issue
main standalone class:
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.as.quickstarts.ejb.remote.client;
import org.jboss.as.quickstarts.ejb.remote.stateful.RemoteCounter;
import org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;
/**
* A sample program which acts a remote client for a EJB deployed on AS7 server.
* This program shows how to lookup stateful and stateless beans via JNDI and
* then invoke on them
*
* @author Jaikiran Pai
*/
public class RemoteEJBClient {
public static void main(String args) throws Exception {
// Invoke a stateless bean
invokeStatelessBean();
// Invoke a stateful bean
// invokeStatefulBean();
}
/**
* Looks up a stateless bean and invokes on it
*
* @throws NamingException
*/
private static void invokeStatelessBean() throws NamingException {
// Let's lookup the remote stateless calculator
final RemoteCalculator statelessRemoteCalculator = lookupRemoteStatelessCalculator();
System.out
.println("Obtained a remote stateless calculator for invocation");
// invoke on the remote calculator
int a = 204;
int b = 340;
System.out
.println("Adding "
+ a
+ " and "
+ b
+ " via the remote stateless calculator deployed on the server");
int sum = statelessRemoteCalculator.add(a, b);
System.out.println("Remote calculator returned sum = " + sum);
if (sum != a + b) {
throw new RuntimeException(
"Remote stateless calculator returned an incorrect sum "
+ sum + " ,expected sum was " + (a + b));
}
// try one more invocation, this time for subtraction
int num1 = 3434;
int num2 = 2332;
System.out
.println("Subtracting "
+ num2
+ " from "
+ num1
+ " via the remote stateless calculator deployed on the server");
int difference = statelessRemoteCalculator.subtract(num1, num2);
System.out.println("Remote calculator returned difference = "
+ difference);
if (difference != num1 - num2) {
throw new RuntimeException(
"Remote stateless calculator returned an incorrect difference "
+ difference + " ,expected difference was "
+ (num1 - num2));
}
}
/**
* Looks up a stateful bean and invokes on it
*
* @throws NamingException
*/
private static void invokeStatefulBean() throws NamingException {
// Let's lookup the remote stateful counter
final RemoteCounter statefulRemoteCounter = lookupRemoteStatefulCounter();
System.out.println("Obtained a remote stateful counter for invocation");
// invoke on the remote counter bean
final int NUM_TIMES = 5;
System.out.println("Counter will now be incremented " + NUM_TIMES
+ " times");
for (int i = 0; i < NUM_TIMES; i++) {
System.out.println("Incrementing counter");
statefulRemoteCounter.increment();
System.out.println("Count after increment is "
+ statefulRemoteCounter.getCount());
}
// now decrementing
System.out.println("Counter will now be decremented " + NUM_TIMES
+ " times");
for (int i = NUM_TIMES; i > 0; i--) {
System.out.println("Decrementing counter");
statefulRemoteCounter.decrement();
System.out.println("Count after decrement is "
+ statefulRemoteCounter.getCount());
}
}
/**
* Looks up and returns the proxy to remote stateless calculator bean
*
* @return
* @throws NamingException
*/
private static RemoteCalculator lookupRemoteStatelessCalculator()
throws NamingException {
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
/*
* remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=
* false
*
* remote.connections=default
*
* remote.connection.default.host=localhost
* remote.connection.default.port = 4447
* remote.connection.default.connect
* .options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
*/
jndiProperties
.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED",
false);
jndiProperties.put("remote.connections", "default");
jndiProperties.put("remote.connection.default.host", "localhost");
jndiProperties.put("remote.connection.default.port", "4447");
jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS",false);
final Context context = new InitialContext(jndiProperties);
// The JNDI lookup name for a stateless session bean has the syntax of:
// ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>
//
// <appName> The application name is the name of the EAR that the EJB is
// deployed in
// (without the .ear). If the EJB JAR is not deployed in an EAR then
// this is
// blank. The app name can also be specified in the EAR's
// application.xml
//
// <moduleName> By the default the module name is the name of the EJB
// JAR file (without the
// .jar suffix). The module name might be overridden in the ejb-jar.xml
//
// <distinctName> : AS7 allows each deployment to have an (optional)
// distinct name.
// This example does not use this so leave it blank.
//
// <beanName> : The name of the session been to be invoked.
//
// <viewClassName>: The fully qualified classname of the remote
// interface. Must include
// the whole package name.
// let's do the lookup
return (RemoteCalculator) context
.lookup("java:global/ejb-remote/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator");
}
/**
* Looks up and returns the proxy to remote stateful counter bean
*
* @return
* @throws NamingException
*/
private static RemoteCounter lookupRemoteStatefulCounter()
throws NamingException {
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
// The JNDI lookup name for a stateful session bean has the syntax of:
// ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful
//
// <appName> The application name is the name of the EAR that the EJB is
// deployed in
// (without the .ear). If the EJB JAR is not deployed in an EAR then
// this is
// blank. The app name can also be specified in the EAR's
// application.xml
//
// <moduleName> By the default the module name is the name of the EJB
// JAR file (without the
// .jar suffix). The module name might be overridden in the ejb-jar.xml
//
// <distinctName> : AS7 allows each deployment to have an (optional)
// distinct name.
// This example does not use this so leave it blank.
//
// <beanName> : The name of the session been to be invoked.
//
// <viewClassName>: The fully qualified classname of the remote
// interface. Must include
// the whole package name.
// let's do the lookup
return (RemoteCounter) context
.lookup("ejb:/jboss-ejb-remote-server-side/CounterBean!"
+ RemoteCounter.class.getName() + "?stateful");
}
}
jboss-ejb-client.properties
#
# JBoss, Home of Professional Open Source
# Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
# contributors by the @authors tag. See the copyright.txt in the
# distribution for a full listing of individual contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
running pom.xml, is also full of errors. which probably is saying that jboss provided pom.xml will not work also
[ERROR] Non-resolvable import POM: Failure to find org.jboss.spec:jboss-javaee-6.0:pom:3.0.2.Final-redhat-4 in http://repo.maven.apache.
org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or update
s are forced @ line 72, column 22 -> [Help 2]
[ERROR] Non-resolvable import POM: Failure to find org.jboss.as:jboss-as-ejb-client-bom:pom:7.2.1.Final-redhat-10 in http://repo.maven.a
pache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or
updates are forced @ line 80, column 22 -> [Help 2]
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar is missing. @ line 94,
column 19
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:jar is missing. @ line 102, column 19
[ERROR] 'dependencies.dependency.version' for org.jboss:jboss-ejb-client:jar is missing. @ line 118, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.xnio:xnio-api:jar is missing. @ line 125, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.xnio:xnio-nio:jar is missing. @ line 131, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.remoting3:jboss-remoting:jar is missing. @ line 138, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.sasl:jboss-sasl:jar is missing. @ line 145, column 21
[ERROR] 'dependencies.dependency.version' for org.jboss.marshalling:jboss-marshalling-river:jar is missing. @ line 152, column 21
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
java eclipse java-ee jboss ejb-3.0
I am trying to run the following example for a quite sometime in eclipse.
https://github.com/jboss-developer/jboss-eap-quickstarts/tree/master/ejb-remote
I have created an ejb project and imported all the class files and put .properties files in META-INF. now there is no error in code and ejbs are deployed on JBoss server successfully. When I try to run RemoteEJBClient.java, I am getting following exception, which I am not able to fix.
Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.lookupRemoteStatelessCalculator(RemoteEJBClient.java:131)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:50)
at org.jboss.as.quickstarts.ejb.remote.client.RemoteEJBClient.main(RemoteEJBClient.java:37)
please help me in sort out this issue
main standalone class:
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.as.quickstarts.ejb.remote.client;
import org.jboss.as.quickstarts.ejb.remote.stateful.RemoteCounter;
import org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;
/**
* A sample program which acts a remote client for a EJB deployed on AS7 server.
* This program shows how to lookup stateful and stateless beans via JNDI and
* then invoke on them
*
* @author Jaikiran Pai
*/
public class RemoteEJBClient {
public static void main(String args) throws Exception {
// Invoke a stateless bean
invokeStatelessBean();
// Invoke a stateful bean
// invokeStatefulBean();
}
/**
* Looks up a stateless bean and invokes on it
*
* @throws NamingException
*/
private static void invokeStatelessBean() throws NamingException {
// Let's lookup the remote stateless calculator
final RemoteCalculator statelessRemoteCalculator = lookupRemoteStatelessCalculator();
System.out
.println("Obtained a remote stateless calculator for invocation");
// invoke on the remote calculator
int a = 204;
int b = 340;
System.out
.println("Adding "
+ a
+ " and "
+ b
+ " via the remote stateless calculator deployed on the server");
int sum = statelessRemoteCalculator.add(a, b);
System.out.println("Remote calculator returned sum = " + sum);
if (sum != a + b) {
throw new RuntimeException(
"Remote stateless calculator returned an incorrect sum "
+ sum + " ,expected sum was " + (a + b));
}
// try one more invocation, this time for subtraction
int num1 = 3434;
int num2 = 2332;
System.out
.println("Subtracting "
+ num2
+ " from "
+ num1
+ " via the remote stateless calculator deployed on the server");
int difference = statelessRemoteCalculator.subtract(num1, num2);
System.out.println("Remote calculator returned difference = "
+ difference);
if (difference != num1 - num2) {
throw new RuntimeException(
"Remote stateless calculator returned an incorrect difference "
+ difference + " ,expected difference was "
+ (num1 - num2));
}
}
/**
* Looks up a stateful bean and invokes on it
*
* @throws NamingException
*/
private static void invokeStatefulBean() throws NamingException {
// Let's lookup the remote stateful counter
final RemoteCounter statefulRemoteCounter = lookupRemoteStatefulCounter();
System.out.println("Obtained a remote stateful counter for invocation");
// invoke on the remote counter bean
final int NUM_TIMES = 5;
System.out.println("Counter will now be incremented " + NUM_TIMES
+ " times");
for (int i = 0; i < NUM_TIMES; i++) {
System.out.println("Incrementing counter");
statefulRemoteCounter.increment();
System.out.println("Count after increment is "
+ statefulRemoteCounter.getCount());
}
// now decrementing
System.out.println("Counter will now be decremented " + NUM_TIMES
+ " times");
for (int i = NUM_TIMES; i > 0; i--) {
System.out.println("Decrementing counter");
statefulRemoteCounter.decrement();
System.out.println("Count after decrement is "
+ statefulRemoteCounter.getCount());
}
}
/**
* Looks up and returns the proxy to remote stateless calculator bean
*
* @return
* @throws NamingException
*/
private static RemoteCalculator lookupRemoteStatelessCalculator()
throws NamingException {
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
/*
* remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=
* false
*
* remote.connections=default
*
* remote.connection.default.host=localhost
* remote.connection.default.port = 4447
* remote.connection.default.connect
* .options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
*/
jndiProperties
.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED",
false);
jndiProperties.put("remote.connections", "default");
jndiProperties.put("remote.connection.default.host", "localhost");
jndiProperties.put("remote.connection.default.port", "4447");
jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS",false);
final Context context = new InitialContext(jndiProperties);
// The JNDI lookup name for a stateless session bean has the syntax of:
// ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>
//
// <appName> The application name is the name of the EAR that the EJB is
// deployed in
// (without the .ear). If the EJB JAR is not deployed in an EAR then
// this is
// blank. The app name can also be specified in the EAR's
// application.xml
//
// <moduleName> By the default the module name is the name of the EJB
// JAR file (without the
// .jar suffix). The module name might be overridden in the ejb-jar.xml
//
// <distinctName> : AS7 allows each deployment to have an (optional)
// distinct name.
// This example does not use this so leave it blank.
//
// <beanName> : The name of the session been to be invoked.
//
// <viewClassName>: The fully qualified classname of the remote
// interface. Must include
// the whole package name.
// let's do the lookup
return (RemoteCalculator) context
.lookup("java:global/ejb-remote/CalculatorBean!org.jboss.as.quickstarts.ejb.remote.stateless.RemoteCalculator");
}
/**
* Looks up and returns the proxy to remote stateful counter bean
*
* @return
* @throws NamingException
*/
private static RemoteCounter lookupRemoteStatefulCounter()
throws NamingException {
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES,
"org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
// The JNDI lookup name for a stateful session bean has the syntax of:
// ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful
//
// <appName> The application name is the name of the EAR that the EJB is
// deployed in
// (without the .ear). If the EJB JAR is not deployed in an EAR then
// this is
// blank. The app name can also be specified in the EAR's
// application.xml
//
// <moduleName> By the default the module name is the name of the EJB
// JAR file (without the
// .jar suffix). The module name might be overridden in the ejb-jar.xml
//
// <distinctName> : AS7 allows each deployment to have an (optional)
// distinct name.
// This example does not use this so leave it blank.
//
// <beanName> : The name of the session been to be invoked.
//
// <viewClassName>: The fully qualified classname of the remote
// interface. Must include
// the whole package name.
// let's do the lookup
return (RemoteCounter) context
.lookup("ejb:/jboss-ejb-remote-server-side/CounterBean!"
+ RemoteCounter.class.getName() + "?stateful");
}
}
jboss-ejb-client.properties
#
# JBoss, Home of Professional Open Source
# Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
# contributors by the @authors tag. See the copyright.txt in the
# distribution for a full listing of individual contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
running pom.xml, is also full of errors. which probably is saying that jboss provided pom.xml will not work also
[ERROR] Non-resolvable import POM: Failure to find org.jboss.spec:jboss-javaee-6.0:pom:3.0.2.Final-redhat-4 in http://repo.maven.apache.
org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or update
s are forced @ line 72, column 22 -> [Help 2]
[ERROR] Non-resolvable import POM: Failure to find org.jboss.as:jboss-as-ejb-client-bom:pom:7.2.1.Final-redhat-10 in http://repo.maven.a
pache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or
updates are forced @ line 80, column 22 -> [Help 2]
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar is missing. @ line 94,
column 19
[ERROR] 'dependencies.dependency.version' for org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:jar is missing. @ line 102, column 19
[ERROR] 'dependencies.dependency.version' for org.jboss:jboss-ejb-client:jar is missing. @ line 118, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.xnio:xnio-api:jar is missing. @ line 125, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.xnio:xnio-nio:jar is missing. @ line 131, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.remoting3:jboss-remoting:jar is missing. @ line 138, column 20
[ERROR] 'dependencies.dependency.version' for org.jboss.sasl:jboss-sasl:jar is missing. @ line 145, column 21
[ERROR] 'dependencies.dependency.version' for org.jboss.marshalling:jboss-marshalling-river:jar is missing. @ line 152, column 21
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
java eclipse java-ee jboss ejb-3.0
java eclipse java-ee jboss ejb-3.0
edited Nov 22 '18 at 3:54
Cœur
18.2k9108148
18.2k9108148
asked Nov 15 '13 at 11:09
vickyvicky
46921437
46921437
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Your EJB client is a java standalone, therefore, in order to connect to JNDI service and lookup the ejb reference you need to provide some configuration to the InitialContext object.
The exception is telling you that this configuration is not provided, so the InitialContext instance can't be created.
Here you can see (in general terms) how to set InitialConext properties. Takes in mind that this configuration is vendor-dependet.
Searching through the tutorial, I can see a file that seems to contains the properties suitable for this tutorial. I seems to be that this file is no available to RemoteEJBClient.java class.
thanks. i have tried two things, one copied the .properites file whate main calss was, but it was not picking up. then i set the values in main class initialcontext, but still getting the same error. any idea ?
– vicky
Nov 15 '13 at 15:04
is your jboss version the same as the tutorial (or at least similar)?
– Gabriel Aramburu
Nov 15 '13 at 15:32
i am running this version: jboss-as-7.1.1.Final
– vicky
Nov 15 '13 at 15:34
from here try to set also this propertie: endpoint.name=client-endpoint
– Gabriel Aramburu
Nov 15 '13 at 16:06
ok, I am going to try, lets see and thanks
– vicky
Nov 15 '13 at 16:09
|
show 4 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19999709%2fjboss-ejb-client-example-exception-in-thread-main-javax-naming-noinitialconte%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your EJB client is a java standalone, therefore, in order to connect to JNDI service and lookup the ejb reference you need to provide some configuration to the InitialContext object.
The exception is telling you that this configuration is not provided, so the InitialContext instance can't be created.
Here you can see (in general terms) how to set InitialConext properties. Takes in mind that this configuration is vendor-dependet.
Searching through the tutorial, I can see a file that seems to contains the properties suitable for this tutorial. I seems to be that this file is no available to RemoteEJBClient.java class.
thanks. i have tried two things, one copied the .properites file whate main calss was, but it was not picking up. then i set the values in main class initialcontext, but still getting the same error. any idea ?
– vicky
Nov 15 '13 at 15:04
is your jboss version the same as the tutorial (or at least similar)?
– Gabriel Aramburu
Nov 15 '13 at 15:32
i am running this version: jboss-as-7.1.1.Final
– vicky
Nov 15 '13 at 15:34
from here try to set also this propertie: endpoint.name=client-endpoint
– Gabriel Aramburu
Nov 15 '13 at 16:06
ok, I am going to try, lets see and thanks
– vicky
Nov 15 '13 at 16:09
|
show 4 more comments
Your EJB client is a java standalone, therefore, in order to connect to JNDI service and lookup the ejb reference you need to provide some configuration to the InitialContext object.
The exception is telling you that this configuration is not provided, so the InitialContext instance can't be created.
Here you can see (in general terms) how to set InitialConext properties. Takes in mind that this configuration is vendor-dependet.
Searching through the tutorial, I can see a file that seems to contains the properties suitable for this tutorial. I seems to be that this file is no available to RemoteEJBClient.java class.
thanks. i have tried two things, one copied the .properites file whate main calss was, but it was not picking up. then i set the values in main class initialcontext, but still getting the same error. any idea ?
– vicky
Nov 15 '13 at 15:04
is your jboss version the same as the tutorial (or at least similar)?
– Gabriel Aramburu
Nov 15 '13 at 15:32
i am running this version: jboss-as-7.1.1.Final
– vicky
Nov 15 '13 at 15:34
from here try to set also this propertie: endpoint.name=client-endpoint
– Gabriel Aramburu
Nov 15 '13 at 16:06
ok, I am going to try, lets see and thanks
– vicky
Nov 15 '13 at 16:09
|
show 4 more comments
Your EJB client is a java standalone, therefore, in order to connect to JNDI service and lookup the ejb reference you need to provide some configuration to the InitialContext object.
The exception is telling you that this configuration is not provided, so the InitialContext instance can't be created.
Here you can see (in general terms) how to set InitialConext properties. Takes in mind that this configuration is vendor-dependet.
Searching through the tutorial, I can see a file that seems to contains the properties suitable for this tutorial. I seems to be that this file is no available to RemoteEJBClient.java class.
Your EJB client is a java standalone, therefore, in order to connect to JNDI service and lookup the ejb reference you need to provide some configuration to the InitialContext object.
The exception is telling you that this configuration is not provided, so the InitialContext instance can't be created.
Here you can see (in general terms) how to set InitialConext properties. Takes in mind that this configuration is vendor-dependet.
Searching through the tutorial, I can see a file that seems to contains the properties suitable for this tutorial. I seems to be that this file is no available to RemoteEJBClient.java class.
edited May 23 '17 at 12:28
Community♦
11
11
answered Nov 15 '13 at 14:26
Gabriel AramburuGabriel Aramburu
2,71121218
2,71121218
thanks. i have tried two things, one copied the .properites file whate main calss was, but it was not picking up. then i set the values in main class initialcontext, but still getting the same error. any idea ?
– vicky
Nov 15 '13 at 15:04
is your jboss version the same as the tutorial (or at least similar)?
– Gabriel Aramburu
Nov 15 '13 at 15:32
i am running this version: jboss-as-7.1.1.Final
– vicky
Nov 15 '13 at 15:34
from here try to set also this propertie: endpoint.name=client-endpoint
– Gabriel Aramburu
Nov 15 '13 at 16:06
ok, I am going to try, lets see and thanks
– vicky
Nov 15 '13 at 16:09
|
show 4 more comments
thanks. i have tried two things, one copied the .properites file whate main calss was, but it was not picking up. then i set the values in main class initialcontext, but still getting the same error. any idea ?
– vicky
Nov 15 '13 at 15:04
is your jboss version the same as the tutorial (or at least similar)?
– Gabriel Aramburu
Nov 15 '13 at 15:32
i am running this version: jboss-as-7.1.1.Final
– vicky
Nov 15 '13 at 15:34
from here try to set also this propertie: endpoint.name=client-endpoint
– Gabriel Aramburu
Nov 15 '13 at 16:06
ok, I am going to try, lets see and thanks
– vicky
Nov 15 '13 at 16:09
thanks. i have tried two things, one copied the .properites file whate main calss was, but it was not picking up. then i set the values in main class initialcontext, but still getting the same error. any idea ?
– vicky
Nov 15 '13 at 15:04
thanks. i have tried two things, one copied the .properites file whate main calss was, but it was not picking up. then i set the values in main class initialcontext, but still getting the same error. any idea ?
– vicky
Nov 15 '13 at 15:04
is your jboss version the same as the tutorial (or at least similar)?
– Gabriel Aramburu
Nov 15 '13 at 15:32
is your jboss version the same as the tutorial (or at least similar)?
– Gabriel Aramburu
Nov 15 '13 at 15:32
i am running this version: jboss-as-7.1.1.Final
– vicky
Nov 15 '13 at 15:34
i am running this version: jboss-as-7.1.1.Final
– vicky
Nov 15 '13 at 15:34
from here try to set also this propertie: endpoint.name=client-endpoint
– Gabriel Aramburu
Nov 15 '13 at 16:06
from here try to set also this propertie: endpoint.name=client-endpoint
– Gabriel Aramburu
Nov 15 '13 at 16:06
ok, I am going to try, lets see and thanks
– vicky
Nov 15 '13 at 16:09
ok, I am going to try, lets see and thanks
– vicky
Nov 15 '13 at 16:09
|
show 4 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19999709%2fjboss-ejb-client-example-exception-in-thread-main-javax-naming-noinitialconte%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown