Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EJB3 test client: javax.naming.NameNotFoundException for JDev 11.1.1.3

NickAivaMay 24 2010 — edited May 28 2010
Dear experts!

The test client code,(given below) JDev 11.1.1.3 generated for a stateful ejb3 (code also given below) threw:

actionbazaar.buslogic.BidderAccountCreatorWLClient
+javax.naming.NameNotFoundException: While trying to lookup 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar.buslogic.BidderAccountCreator' didn't find subcontext 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar.buslogic.BidderAccountCreator' didn't find subcontext 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar'. Resolved '']; remaining name 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar/buslogic/BidderAccountCreator'+
+ at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)+
+ at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)+
+ at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)+
+ at weblogic.jndi.internal.ServerNamingNode_1033_WLStub.lookup(Unknown Source)+
+ at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:405)+
+ at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:393)+
+ at javax.naming.InitialContext.lookup(InitialContext.java:392)+
+ at actionbazaar.buslogic.BidderAccountCreatorWLClient.main(BidderAccountCreatorWLClient.java:13)+
Caused by: javax.naming.NameNotFoundException: While trying to lookup 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar.buslogic.BidderAccountCreator' didn't find subcontext 'ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar'. Resolved ''
+ at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)+
+ at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)+
+ at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)+
+ at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)+
+ at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)+
+ at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)+
+ at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)+
+ at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)+
+ at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)+
+ at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)+
+ at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)+
+ at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)+
+ at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)+
+ at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)+
Process exited with exit code 0.

The ejb is not found in the JNDI tree.

Deployments table shows an exclamation mark at Health column.

The closest match I found was:

3237508

Any helping hand available?
Thank you very much indeed in advance!

GENERATED CODE FOLLOWS:
package actionbazaar.buslogic;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class BidderAccountCreatorWLClient {
public static void main(String [] args) {
try {
final Context context = getInitialContext();
BidderAccountCreator bidderAccountCreator = (BidderAccountCreator)context.lookup("ejb3inaction-Chapter3-BidderAccountCreator#actionbazaar.buslogic.BidderAccountCreator");
...
} catch (Exception ex) {
ex.printStackTrace();
}
}

private static Context getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
// WebLogic Server 10.x connection details
env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
env.put(Context.PROVIDER_URL, "t3://127.0.0.1:7101");
return new InitialContext( env );
}
}
CODE OF EJB FOLLOWS:

package actionbazaar.buslogic;

import actionbazaar.persistence.BillingInfo;
import actionbazaar.persistence.BiographicalInfo;
import actionbazaar.persistence.LoginInfo;

import java.sql.Connection;

import java.sql.SQLException;

import java.sql.Statement;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

import javax.ejb.PostActivate;
import javax.ejb.PrePassivate;
import javax.ejb.Remote;
import javax.ejb.Remove;
import javax.ejb.Stateful;

import javax.sql.DataSource;

@Stateful(name = "BidderAccountCreator", mappedName = "ejb3inaction-Chapter3-BidderAccountCreator")
@Remote
public class BidderAccountCreatorBean implements BidderAccountCreator {
@Resource(name = "jdbc/ActionBazaarDS", mappedName="ActionBazaarDS")
private DataSource dataSource;
private LoginInfo loginInfo;
private BiographicalInfo biographicalInfo;
private BillingInfo billingInfo;
private Connection connection;

public BidderAccountCreatorBean() {
}

@PostConstruct
@PostActivate
public void openConnection() {
try {
connection = dataSource.getConnection();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
public void addLoginInfo(LoginInfo loginInfo) {
this.loginInfo = loginInfo;
}


public void addBiographicalInfo(BiographicalInfo biographicalInfo)
throws WorkflowOrderViolationException {
if (loginInfo == null) {
throw new WorkflowOrderViolationException(
"Login info must be set before biographical info");
}

this.biographicalInfo = biographicalInfo;
}


public void addBillingInfo(BillingInfo billingInfo)
throws WorkflowOrderViolationException {
if (biographicalInfo == null) {
throw new WorkflowOrderViolationException(
"Biographical info must be set before billing info");
}

this.billingInfo = billingInfo;
}


@PrePassivate
@PreDestroy
public void cleanup() {
try {
connection.close();
connection = null;
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}


@Remove
public void cancelAccountCreation() {
loginInfo = null;
biographicalInfo = null;
billingInfo = null;
}


@Remove
public void createAccount() {
try {
Statement statement = connection.createStatement();
String sql = "INSERT INTO BIDDERS(" + "username, " + "first_name, "
+ "credit_card_type" + ") VALUES (" + "'"
+ loginInfo.getUsername() + "', " +

"'" + biographicalInfo.getFirstName() + "', " +

"'" + billingInfo.getCreditCardType() + "'" +

")";
statement.execute(sql);
statement.close();
System.out.println("Bidder successfully created ..");
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 25 2010
Added on May 24 2010
4 comments
2,481 views