CAN'T LOOKUP SIMPLE ENTITY BEAN : ''JAVAX.NAMING.NAMINGEXCEPTION: LOOKUP ERROR''
Hello, we were forwarded to this forum from TAR section of Metalink. We are facing a problem with JDev-RC2/OC4J-9.0.3 and seems that we are hitting Bug 2276197. The BUG is marked as internal and therefore we can't see it. So, it's not clear where the problem is, if in JDev or OC4J or both ?
Testcase Step-by-step:
1. Invoke JDeveloper 9.0.3.815
2. Create a workspace & a project.
3. Create an default Container-managed Entity Beans frim Tables.
4. Create Sample Java Client with "Connect to OC4J Embedded in Jdeveloper" and run it, it gives above error.
You can download a testcase that is part of TAR-2125538.995, that we opened on Metalink.
Please help. Thanks in advance.
Hi Radim,
Personally, I have played a little with JDeveloper, but I am not
actively using it for my development -- I prefer to do most things
myself. True, the JDeveloper wizards do a lot of the work for you,
but at least (with my way), when something goes wrong, I have a
better idea of where to look.
So I can't help you much on the JDeveloper side, but an app is an
app regardless of how you develop it, so I'll offer a list of things
to check (just in case you haven't already done so :-).
I haven't looked at your test case, but from your description, I
assume you have a standalone java client. Again, I assume JDeveloper
handles the details for you (and it may be doing it wrong -- as
you suggest), but the way you do your JNDI lookup depends on the
type of client you use. For a standalone java client (that is also
deployed to OC4J), your "initial context factory" class should be:
com.evermind.server.ApplicationClientInitialContextFactory
and your "provider URL" should be:
ormi://<host>/<app-name>
where <host> is the name of the computer where OC4J is running
(you can also use "localhost") and <app-name> is the name given
to your application at deployment time. Again, JDeveloper handles
the deployment, but the "app-name" should also appear in the
"server.xml" configuration file which is usually located in the
"config" subdirectory of the OC4J home directory.
The lookup string for your entity bean should be the "logical"
name, meaning the name of your bean prefixed with "java:comp/env".
Again, I guess JDeveloper handles the bean name part for you,
but the bean name appears in the "ejb-jar.xml" file under the
"ejb-name" element.
So if you've already checked all of the above, then please excuse
me for not telling you anything you don't already know.
Good Luck,
Avi.
Similar Messages
-
OpenEJB and javax.naming.NamingException
Hello
I got following error when running my EJB Client
Cannot lookup /Hello: Received error: Error while communicating with server: ; nested exception is:
java.rmi.RemoteException: Cannot read the response from the server.; nested exception is:
java.io.EOFException
This is the part of code
Properties p = new Properties();
p.put("java.naming.factory.initial", "org.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "127.0.0.1:4201");
InitialContext initCtx = new InitialContext(p);
Object object = initCtx.lookup( "/Hello" );
And this the the command line :)
"C:\Program Files\JBuilderX\jdk1.4\bin\javaw" -classpath "D:\Work\test1\classes;C:\Program Files\JBuilderX\thirdparty\jakarta-tomcat-4.1.27-LE-jdk14\common\lib\servlet.jar;D:\Work\test1\WebModule1\myHelloEjb.zip;D:\Work\EJB\ejb-2_1-api.jar;C:\openejb\lib\openejb-core-1.0-20050917.jar;C:\openejb\lib\openejb-itests-client.jar;C:\openejb\lib\openejb-loader-1.0-20050917.jar;D:\Java-Libs\jndi.jar;C:\Program Files\JBuilderX\jdk1.4\demo\jfc\Java2D\Java2Demo.jar;C:\Program Files\JBuilderX\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\Program Files\JBuilderX\jdk1.4\jre\javaws\javaws.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\charsets.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\ext\dnsns.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\ext\ldapsec.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\ext\localedata.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\ext\sunjce_provider.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\im\indicim.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\im\thaiim.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\jce.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\jsse.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\plugin.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\rt.jar;C:\Program Files\JBuilderX\jdk1.4\jre\lib\sunrsasign.jar;C:\Program Files\JBuilderX\jdk1.4\lib\dt.jar;C:\Program Files\JBuilderX\jdk1.4\lib\htmlconverter.jar;C:\Program Files\JBuilderX\jdk1.4\lib\tools.jar" -Dopenejb.home=c:\openejb test1.testEJB
Why I got this error? Please help me.
Thanks.You really are going to kick yourself !!
Looks like a combination of a missing, or non existent OU and a typo !
You are trying to create a subcontext named:"cn=jain,ou=orgunit,DN=praveendomain"I think you meant:"cn=jain,ou=orgunit,DC=praveendomain"Also if the OU"ou=orgunit,DC=praveendomain" does not exist, you will also get an error. In general, the Active Directory DSID error message will identify the incorrect distinguished name javax.naming.NamingException: [LDAP: error code 1 - 000020D6: SvcErr: DSID-031006CC, problem 5012 (DIR_ERROR), data 0
;remaining name 'cn=jain,ou=orgunit,DN=praveendomain' -
Javax.naming.NamingException: Failed in WD JNDI lookup
Hi,
I have deployed wdj applications,some times its working fine ,but some other times its through the following errors.
javax.naming.NamingException: Failed in WD JNDI lookup
Any one please suggest me
Thanks,
VenuHi Friend,
I am not sure what Other Reason can be for this problem mean while check these links. Hope it will help.
/message/6928201#6928201 [original link is broken]
/message/6315352#6315352 [original link is broken]
Regards
Jeetendra -
[persistence] all work, but can't persist new entity bean
Hi,
I have a FacadeBean which is working fine ... I can contact the BD oracle for retrieving my entity beans, update an entity bean etc...
BUT... I can't create an entity bean :( I don't understand why!!!
With the same code, I can create, list, etc... on OC4J and JBoss but the create method won't work with WebLogic :|
Here is the error present in console:
<09-mars-2007 15 h 03 min 47 s CET> <Error> <EJB> <BEA-010026> <Exception occurr
ed during commit of transaction Name=[EJB be.starapic.test.ejb.MyEntityFacadeBea
n.create(be.starapic.test.ejb.MyEntity)],Xid=BEA1-007A82AF3A953057A4BD(30283302)
,Status=Rolled back. [Reason=weblogic.transaction.internal.AppSetRollbackOnlyExc
eption],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=1,seconds
left=30,XAServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(ServerRes
ourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(state=rolledback,assigned=Ad
minServer),xar=weblogic.jdbc.wrapper.JTSXAResourceImpl@110563c,re-Registered = f
alse),SCInfo[base_domain+AdminServer]=(state=rolledback),properties=({weblogic.t
ransaction.name=[EJB be.starapic.test.ejb.MyEntityFacadeBean.create(be.starapic.
test.ejb.MyEntity)], weblogic.jdbc=t3://192.168.100.188:7001}),OwnerTransactionM
anager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=AdminServer+192.168.
100.188:7001+base_domain+t3+, XAResources={weblogic.jdbc.wrapper.JTSXAResourceIm
pl},NonXAResources={})],CoordinatorURL=AdminServer+192.168.100.188:7001+base_dom
ain+t3+): weblogic.transaction.RollbackException: Unknown reason
at weblogic.transaction.internal.TransactionImpl.throwRollbackException(
TransactionImpl.java:1808)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(Se
rverTransactionImpl.java:333)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTran
sactionImpl.java:227)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvoke1(BaseRemo
teObject.java:606)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvokeTxRetry(Ba
seRemoteObject.java:426)
at weblogic.ejb.container.internal.StatefulRemoteObject.postInvokeTxRetr
y(StatefulRemoteObject.java:100)
at be.starapic.test.ejb.myentityfacade_opn58i_MyEntityFacadeRemoteImpl.c
reate(myentityfacade_opn58i_MyEntityFacadeRemoteImpl.java:158)
at be.starapic.test.ejb.myentityfacade_opn58i_MyEntityFacadeRemoteImpl_C
BV.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(Remote
BusinessIntfProxy.java:42)
at $Proxy152.create(Unknown Source)
at be.starapic.test.web.HelloServlet.doGet(HelloServlet.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run
(StubSecurityHelper.java:226)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri
tyHelper.java:124)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:3334)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
ervletContext.java:2081)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
ontext.java:1987)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j
ava:1359)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
.>
<09-mars-2007 15 h 03 min 47 s CET> <Error> <HTTP> <BEA-101020> <[weblogic.servl
et.internal.WebAppServletContext@144a314 - appName: 'testDeploy', name: '/testDe
ploy', context-path: '/testDeploy'] Servlet failed with Exception
javax.ejb.EJBException: nested exception is: weblogic.transaction.internal.AppSe
tRollbackOnlyException
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(Remote
BusinessIntfProxy.java:57)
at $Proxy152.create(Unknown Source)
at be.starapic.test.web.HelloServlet.doGet(HelloServlet.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
Truncated. see log file for complete stacktrace
That say nothing good...
at $Proxy152.create(Unknown Source) is the problem I think but why ...?
Here is the entity bean:
@Entity
@Table(name="table_myentity")
public class MyEntity implements Serializable
private static final long serialVersionUID = -5806278646729410835L;
private int id;
private String name;
private int number;
public void setName(String name) {
this.name = name;
public String getName() {
return name;
public void setNumber(int number) {
this.number = number;
@Column(name="mynumber")
public int getNumber() {
return number;
public void setId(int id) {
this.id = id;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public int getId() {
return id;
May be a problem of auto-generate for the ID...
Here is the facade bean:
@Stateful(name="myentityfacade", mappedName="myentityfacade")
@Remote(MyEntityFacadeRemote.class)
@Local(MyEntityFacadeLocal.class)
public class MyEntityFacadeBean implements MyEntityFacadeRemote, MyEntityFacadeLocal {
@PersistenceContext
private EntityManager em;
public MyEntity create(MyEntity meb) {
em.persist(meb);
return meb;
public void update(MyEntity meb) throws IllegalAccessException {
if (null == em.find(MyEntity.class, meb.getId())) {
throw new IllegalAccessException("Attempt to update a non existing entity");
em.merge(meb);
public void delete(int id) {
MyEntity meb = em.find(MyEntity.class, id);
em.remove(meb);
public void delete(MyEntity meb) {
meb = em.merge(meb);
em.remove(meb);
public MyEntity findById(int id) {
return em.find(MyEntity.class, id);
public List<MyEntity> listAll() {
return em.createQuery("SELECT o FROM MyEntity AS o").getResultList(); //TOPLINK, HIBERNATE
public List<MyEntity> listFiltered(String filter) {
return em.createQuery("SELECT o FROM MyEntity AS o "+filter).getResultList(); //TOPLINK, HIBERNATE
public int getNbMyEntityBean() {
return this.listAll().size();
Sorry for the long post... And finnaly here is the code present in the servlet:
// CREATE
MyEntity meb1 = new MyEntity();
meb1.setName("bbb");
meb1.setNumber(2);
meb1 = remoteMyEntityFacade.create(meb1);
Note that the remoteMyEntityFacade is working, because I can call any other buisness method without crashing the application.. Just the create can't work and so, persistence can't be used :(
Any suggestions ?There is a problem with generated key
that code won't work:
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public int getId() {
return id;
But, if I remove line "GeneratedValue", it can insert into the BD, once only :s
The ID is set to 0 by default, so I can't add more than one entity :s -
I can not fine the Entity Bean's advantage than Java Bean?
I can not fine the Entity Bean's advantage than Java Bean,
can you tell me, thanks a lot?I can not fine the Entity Bean's advantage than Java
Bean,
can you tell me, thanks a lot?I think you should read more of the EJB Spec. You'll find your answer there. But mainly with entities you can have the container manage all the lifecyle of the Bean (transactions, caching, creation, etc...). But entities are not only to map columns in the database, they are supposed to have business code. See more by reading the spec.
MSB -
Can i create an entity bean to part of a table
Hi there,
I am using EJB 2.0.
Can i create an entity bean to part of a table.
Thanks
Edited by: vamseebobby on Nov 5, 2007 11:11 AMof course,provided the other parts left out have not constraints.
sumelong -
Can anyone describe using entity beans for persitance in Software Architect
Can anyone describe using entity beans for persitance in Software Architecture you built for a product?
Although this forum is supposed to help you gain knowledge on entity beans, its not a free rider that's supposed regurgitate everyone's knowledge to you.
Read something first and then clarify your thoughts with this forum. -
EJB Local Interfaces / javax.naming.NamingException
Hi!
I have tried to deploy a very simple (Hello World like)EJB-Application. It contains a simple stateless SessionBean (with local interfaces) and a JSP which is using the EJB.
Opening the JSP i get the following error message:
javax.naming.NamingException: Error instantiating web-app JNDI-context: No location specified and no suitable instance found for the ejb-local-ref 'ejb/TesterEJB', an EJB matching it's ejb-link 'ejb-jar-ic.jar#TesterEJB' was found, but it contained an Entity, not a Session
Here's my ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<display-name>oc4jJAR</display-name>
<enterprise-beans>
<session>
<display-name>TesterEJB</display-name>
<ejb-name>TesterEJB</ejb-name>
<local-home>oc4jtest.TesterHome</local-home>
<local>oc4jtest.Tester</local>
<ejb-class>oc4jtest.TesterBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<security-identity>
<description/>
<use-caller-identity/>
</security-identity>
</session>
</enterprise-beans>
<assembly-descriptor>
<method-permission>
<unchecked/>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>getMessage</method-name>
<method-params/>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>getPrimaryKey</method-name>
<method-params/>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>getEJBLocalHome</method-name>
<method-params/>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>remove</method-name>
<method-params>
<method-param>java.lang.Object</method-param>
</method-params>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>remove</method-name>
<method-params/>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>isIdentical</method-name>
<method-params>
<method-param>javax.ejb.EJBLocalObject</method-param>
</method-params>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>create</method-name>
<method-params/>
</method>
</method-permission>
<container-transaction>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>getMessage</method-name>
<method-params/>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
And here's my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
<display-name>oc4jWAR</display-name>
<filter>
<filter-name>TestFilter</filter-name>
<display-name>TestFilter</display-name>
<description/>
<filter-class>oc4jtest.TestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>TestFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>test</servlet-name>
<display-name>test</display-name>
<jsp-file>/test.jsp</jsp-file>
</servlet>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/test.jsp</welcome-file>
</welcome-file-list>
<ejb-local-ref>
<ejb-ref-name>ejb/TesterEJB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>oc4jtest.TesterHome</local-home>
<local>oc4jtest.Tester</local>
<ejb-link>ejb-jar-ic.jar#TesterEJB</ejb-link>
</ejb-local-ref>
</web-app>
What's wrong?
Comments would be appreciated!
Thanks!
Peter
PS: The application runs fine on Sun's Reference Implementation!Hi!
I have tried to deploy a very simple (Hello World like)EJB-Application. It contains a simple stateless SessionBean (with local interfaces) and a JSP which is using the EJB.
Opening the JSP i get the following error message:
javax.naming.NamingException: Error instantiating web-app JNDI-context: No location specified and no suitable instance found for the ejb-local-ref 'ejb/TesterEJB', an EJB matching it's ejb-link 'ejb-jar-ic.jar#TesterEJB' was found, but it contained an Entity, not a Session
Here's my ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<display-name>oc4jJAR</display-name>
<enterprise-beans>
<session>
<display-name>TesterEJB</display-name>
<ejb-name>TesterEJB</ejb-name>
<local-home>oc4jtest.TesterHome</local-home>
<local>oc4jtest.Tester</local>
<ejb-class>oc4jtest.TesterBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<security-identity>
<description/>
<use-caller-identity/>
</security-identity>
</session>
</enterprise-beans>
<assembly-descriptor>
<method-permission>
<unchecked/>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>getMessage</method-name>
<method-params/>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>getPrimaryKey</method-name>
<method-params/>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>getEJBLocalHome</method-name>
<method-params/>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>remove</method-name>
<method-params>
<method-param>java.lang.Object</method-param>
</method-params>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>remove</method-name>
<method-params/>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>isIdentical</method-name>
<method-params>
<method-param>javax.ejb.EJBLocalObject</method-param>
</method-params>
</method>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>LocalHome</method-intf>
<method-name>create</method-name>
<method-params/>
</method>
</method-permission>
<container-transaction>
<method>
<ejb-name>TesterEJB</ejb-name>
<method-intf>Local</method-intf>
<method-name>getMessage</method-name>
<method-params/>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
And here's my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
<display-name>oc4jWAR</display-name>
<filter>
<filter-name>TestFilter</filter-name>
<display-name>TestFilter</display-name>
<description/>
<filter-class>oc4jtest.TestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>TestFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>test</servlet-name>
<display-name>test</display-name>
<jsp-file>/test.jsp</jsp-file>
</servlet>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/test.jsp</welcome-file>
</welcome-file-list>
<ejb-local-ref>
<ejb-ref-name>ejb/TesterEJB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>oc4jtest.TesterHome</local-home>
<local>oc4jtest.Tester</local>
<ejb-link>ejb-jar-ic.jar#TesterEJB</ejb-link>
</ejb-local-ref>
</web-app>
What's wrong?
Comments would be appreciated!
Thanks!
Peter
PS: The application runs fine on Sun's Reference Implementation! -
I am using WLS5.1 inside visualage environment. I am trying to run
a Simple EJB which connects to the database and executes two simple
queries. The client code is as shown below:
try{
Context ic = getInitialContext();
System.out.println("Initial Context created......"); java.lang.Object
objref = ic.lookup("simpleBean.AtmHome"); System.out.println("objref
created......");
AtmHome home = (AtmHome) PortableRemoteObject.narrow(objref, AtmHome.class);
System.out.println("home created......");
Atm atm = home.create();
System.out.println("atm created......");
atm.transfer(8, 9, 100000);
catch (NamingException ne)
ne.printStackTrace(System.out);
finally {
try {
ic.close();
System.out.println("Closed the connection");
catch (Exception e) {
System.out.println("Exception while closing context....." );
The above code executes fine for the first time but second time
it throws an exception "javax.naming.NamingException.
Root exception is java.lang.NoSuchMethodError"
javax.naming.NamingException. Root exception is java.lang.NoSuchMethodError
java.lang.Throwable()
java.lang.Error()
java.lang.LinkageError()
java.lang.IncompatibleClassChangeError()
java.lang.NoSuchMethodError()
void javax.naming.NameImpl.recordNamingConvention(java.util.Properties)
void javax.naming.NameImpl.recordNamingConvention(java.util.Properties)
javax.naming.NameImpl(java.util.Properties)
javax.naming.CompositeName()
weblogic.jndi.toolkit.NormalName(java.lang.String, javax.naming.NameParser)
weblogic.jndi.toolkit.NormalName weblogic.jndi.toolkit.BasicWLContext.normalizeName(java.lang.String)
java.lang.Object weblogic.jndi.toolkit.BasicWLContext.lookup(java.lang.String)
weblogic.rmi.extensions.OutgoingResponse weblogic.jndi.toolkit.BasicWLContext_WLSkel.invoke(weblogic.rmi.extensions.ServerObjectReference,
int, weblogic.rmi.extensions.IncomingRequest, weblogic.rmi.extensions.OutgoingResponse)
java.lang.Throwable weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(int,
weblogic.rmi.extensions.IncomingRequest)
void weblogic.rmi.extensions.BasicRequestHandler.handleRequest(weblogic.rmi.extensions.IncomingRequest)
void weblogic.rmi.internal.BasicExecuteRequest.execute(weblogic.kernel.ExecuteThread)
void weblogic.kernel.ExecuteThread.run()
--------------- nested within: ------------------
weblogic.rmi.ServerError: A RemoteException occurred in the server
method
- with nested exception:
[java.lang.NoSuchMethodError:
Start server side stack trace:
java.lang.NoSuchMethodError
java.lang.Throwable()
java.lang.Error()
java.lang.LinkageError()
java.lang.IncompatibleClassChangeError()
java.lang.NoSuchMethodError()
void javax.naming.NameImpl.recordNamingConvention(java.util.Properties)
void javax.naming.NameImpl.recordNamingConvention(java.util.Properties)
javax.naming.NameImpl(java.util.Properties)
javax.naming.CompositeName()
weblogic.jndi.toolkit.NormalName(java.lang.String, javax.naming.NameParser)
weblogic.jndi.toolkit.NormalName weblogic.jndi.toolkit.BasicWLContext.normalizeName(java.lang.String)
java.lang.Object weblogic.jndi.toolkit.BasicWLContext.lookup(java.lang.String)
weblogic.rmi.extensions.OutgoingResponse weblogic.jndi.toolkit.BasicWLContext_WLSkel.invoke(weblogic.rmi.extensions.ServerObjectReference,
int, weblogic.rmi.extensions.IncomingRequest, weblogic.rmi.extensions.OutgoingResponse)
java.lang.Throwable weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(int,
weblogic.rmi.extensions.IncomingRequest)
void weblogic.rmi.extensions.BasicRequestHandler.handleRequest(weblogic.rmi.extensions.IncomingRequest)
void weblogic.rmi.internal.BasicExecuteRequest.execute(weblogic.kernel.ExecuteThread)
void weblogic.kernel.ExecuteThread.run()
End server side stack trace
weblogic.rmi.extensions.WRMIInputStream weblogic.rmi.extensions.AbstractRequest.sendReceive()
java.lang.Object weblogic.jndi.toolkit.BasicWLContext_WLStub.lookup(java.lang.String)
java.lang.Object weblogic.jndi.toolkit.WLContextStub.lookup(java.lang.String)
java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)
void simpleBean.AtmClient.main(java.lang.String [])
NamingException is caught....
I found out that it hangs at lookup function in the above code.
Please let me know if I am missing any environment settings.
Thanks
ShailajaThis problem is solved after installing service pack 8 for weblogic
5.1
-shailaja
"shailaja" <[email protected]> wrote:
>
I am using WLS5.1 inside visualage environment. I am trying
to run
a Simple EJB which connects to the database and executes
two simple
queries. The client code is as shown below:
try{
Context ic = getInitialContext();
System.out.println("Initial Context created......"); java.lang.Object
objref = ic.lookup("simpleBean.AtmHome"); System.out.println("objref
created......");
AtmHome home = (AtmHome) PortableRemoteObject.narrow(objref,
AtmHome.class);
System.out.println("home created......");
Atm atm = home.create();
System.out.println("atm created......");
atm.transfer(8, 9, 100000);
catch (NamingException ne)
ne.printStackTrace(System.out);
finally {
try {
ic.close();
System.out.println("Closed the connection");
catch (Exception e) {
System.out.println("Exception while closing context....."
The above code executes fine for the first time but second
time
it throws an exception "javax.naming.NamingException.
Root exception is java.lang.NoSuchMethodError"
javax.naming.NamingException. Root exception is java.lang.NoSuchMethodError
java.lang.Throwable()
java.lang.Error()
java.lang.LinkageError()
java.lang.IncompatibleClassChangeError()
java.lang.NoSuchMethodError()
void javax.naming.NameImpl.recordNamingConvention(java.util.Properties)
void javax.naming.NameImpl.recordNamingConvention(java.util.Properties)
javax.naming.NameImpl(java.util.Properties)
javax.naming.CompositeName()
weblogic.jndi.toolkit.NormalName(java.lang.String, javax.naming.NameParser)
weblogic.jndi.toolkit.NormalName weblogic.jndi.toolkit.BasicWLContext.normalizeName(java.lang.String)
java.lang.Object weblogic.jndi.toolkit.BasicWLContext.lookup(java.lang.String)
weblogic.rmi.extensions.OutgoingResponse weblogic.jndi.toolkit.BasicWLContext_WLSkel.invoke(weblogic.rmi.extensions.ServerObjectReference,
int, weblogic.rmi.extensions.IncomingRequest, weblogic.rmi.extensions.OutgoingResponse)
java.lang.Throwable weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(int,
weblogic.rmi.extensions.IncomingRequest)
void weblogic.rmi.extensions.BasicRequestHandler.handleRequest(weblogic.rmi.extensions.IncomingRequest)
void weblogic.rmi.internal.BasicExecuteRequest.execute(weblogic.kernel.ExecuteThread)
void weblogic.kernel.ExecuteThread.run()
--------------- nested within: ------------------
weblogic.rmi.ServerError: A RemoteException occurred in
the server
method
- with nested exception:
[java.lang.NoSuchMethodError:
Start server side stack trace:
java.lang.NoSuchMethodError
java.lang.Throwable()
java.lang.Error()
java.lang.LinkageError()
java.lang.IncompatibleClassChangeError()
java.lang.NoSuchMethodError()
void javax.naming.NameImpl.recordNamingConvention(java.util.Properties)
void javax.naming.NameImpl.recordNamingConvention(java.util.Properties)
javax.naming.NameImpl(java.util.Properties)
javax.naming.CompositeName()
weblogic.jndi.toolkit.NormalName(java.lang.String, javax.naming.NameParser)
weblogic.jndi.toolkit.NormalName weblogic.jndi.toolkit.BasicWLContext.normalizeName(java.lang.String)
java.lang.Object weblogic.jndi.toolkit.BasicWLContext.lookup(java.lang.String)
weblogic.rmi.extensions.OutgoingResponse weblogic.jndi.toolkit.BasicWLContext_WLSkel.invoke(weblogic.rmi.extensions.ServerObjectReference,
int, weblogic.rmi.extensions.IncomingRequest, weblogic.rmi.extensions.OutgoingResponse)
java.lang.Throwable weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(int,
weblogic.rmi.extensions.IncomingRequest)
void weblogic.rmi.extensions.BasicRequestHandler.handleRequest(weblogic.rmi.extensions.IncomingRequest)
void weblogic.rmi.internal.BasicExecuteRequest.execute(weblogic.kernel.ExecuteThread)
void weblogic.kernel.ExecuteThread.run()
End server side stack trace
weblogic.rmi.extensions.WRMIInputStream weblogic.rmi.extensions.AbstractRequest.sendReceive()
java.lang.Object weblogic.jndi.toolkit.BasicWLContext_WLStub.lookup(java.lang.String)
java.lang.Object weblogic.jndi.toolkit.WLContextStub.lookup(java.lang.String)
java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)
void simpleBean.AtmClient.main(java.lang.String [])
NamingException is caught....
I found out that it hangs at lookup function in the above
code.
Please let me know if I am missing any environment settings.
Thanks
Shailaja -
Quartz in OC4J: javax.naming.NamingException
We are running Quartz inside OC4J.
We start OC4J with -userThreads turned on (e.g. java -jar oc4j.jar -userThreads).
When the Quartz Job fires we do a Context lookup from the inside the Quartz execute() method to find a JMS QueueConnectionFactory and a JMS Queue.
We are getting the following error on the Context lookup:
06/02/15 06:40:30 Not in an application scope - start OC4J with the -userThreads switch if using user-created threads
06/02/15 06:40:30 javax.naming.NamingException: Not in an application scope - start OC4J with the -userThreads switch if using user-created threads
06/02/15 06:40:30 at com.evermind.server.PreemptiveApplicationContext.getContext(PreemptiveApplicationContext.java:30)
06/02/15 06:40:30 at com.evermind.naming.FilterContext.lookup(FilterContext.java:126)
06/02/15 06:40:30 at com.evermind.server.PreemptiveApplicationContext.lookup(PreemptiveApplicationContext.java:42)
06/02/15 06:40:30 at javax.naming.InitialContext.lookup(InitialContext.java:351)
06/02/15 06:40:30 at timers.JmsEndpoint.createQueue(JmsEndpoint.java:404)
06/02/15 06:40:30 at timers.JmsEndpoint.createQueueSender(JmsEndpoint.java:82)
06/02/15 06:40:30 at timers.TaskQueueScheduler.execute(TaskQueueScheduler.java:149)
06/02/15 06:40:30 at org.quartz.core.JobRunShell.run(JobRunShell.java:195)
06/02/15 06:40:30 at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
We have tried the oracle.j2ee.rmi.RMIInitialContextFactory and the oracle.j2ee.naming.ApplicationClientInitialContextFactory naming factories and get the same error with both.
Any ideas?
Thanks, EdAvi
I tried the default Context factory as you suggested and that didn't work either. I think the problem is related to the fact that Quartz is running on it's own thread within the same JVM as OC4J and may not have scope to the same Context object(s) that OC4J has.
I did find a way to make this work. Before calling the Quartz Scheduler I used the OC4J Context object to lookup a JMS Queue and put the JMS QueueSender object into the Quartz JobDataMap object. I then scheduled the Quartz timer passing in the JobDataMap object. When the timer fires and my Quartz Job execute() method is called I retrieve the JMS QueueSender object from the JobDataMap and use it to send a JMS message.
Thanks for your help,
Ed -
Javax.naming.NamingException: Cannot create resource instance (JOTM )
Hi all,
I wanted to create an application with transaction management, first i tired out tyrex but could get a thing out of it now i am trying out JOTM, but i am getting this error "javax.naming.NamingException: Cannot create resource instance ", below is my configuration..
===context.xml===
<Context path="/FYPMS" docBase="FYPMS" debug="1" reloadable="true" crossContext="true" antiResourceLocking="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_crs_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="password" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/fypms?autoReconnect=true"/>
<Resource name="UserTransaction" auth="Container"
type="javax.transaction.UserTransaction"/>
<ResourceParams name="UserTransaction">
<parameter>
<name>factory</name>
<value>org.objectweb.jotm.UserTransactionFactory</value>
</parameter>
<parameter>
<name>jotm.timeout</name>
<value>60</value>
</parameter>
</ResourceParams>
</Context>
===web.xml===
<resource-ref>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
===insert.java===
try{
System.out.println("pass0");
Context ctx = new InitialContext();
Context envCtx = (Context)ctx.lookup("java:comp/env");
DataSource datasource = (javax.sql.DataSource)envCtx.lookup("jdbc/mysql");
UserTransaction ut = (UserTransaction)envCtx.lookup("UserTransaction");
ut.begin();
the dataSource can be retrieve successfully but when i tired to retrieve the UserTransaction i get a "Cannot create resource instance ". Please help mi out with this.. thx
fatmondwe are trying to connect MS Access thru tomcat and it is giving the above exception
i have changed the server.xml
<Resource name="jdbc/Mess" auth="Container" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/Mess">
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>password</name>
<value>admin</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:odbc:Mess</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>sun.jdbc.odbc.JdbcOdbcDriver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>username</name>
<value>admin</value>
</parameter>
</ResourceParams>
web.xml
<resource-ref>
<description>Access Datasource example</description>
<res-ref-name>jdbc/Mess</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
java class
Context initContext = new InitialContext();
DataSource ds = (DataSource)initContext.lookup("java:/comp/env/jdbc/Mess");
con = ds.getConnection();
Please help....... -
Entity bean connection with SQL Server Error! urgent
Hi,
I am working with J2EE tutorial and when i tried SavingsAccount Entity bean to connect with SQL Server 2000(other than default Cloudscape)and I'm also having SQL Server 2K JDBC Driver installed. I also made entries in Server Configuration menu of J2EE deployment tool for this MS JDBC Driver for SQL Server 2K,I will enclose my dbName and connection method in the entity bean , but i am getting error like this.
my data base name in SQL Server 2K is 'rajeshrNew'.
private String dbName="java:comp/env/jdbc/rajeshrNew"; //dbName
private void makeConnection() throws NamingException, SQLException {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
con = ds.getConnection();
and errors receiving are:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: Unable to connect to database. No suitable driver; nested exception is:
javax.ejb.EJBException: Unable to connect to database. No suitable driver
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: Unable to connect to database. No suitable driver; nested exception is:
javax.ejb.EJBException: Unable to connect to database. No suitable driver
javax.ejb.EJBException: Unable to connect to database. No suitable driver <<no stack trace available>>
Please help me to resolve this problem!!
Regards
Rajesh Ryes i do create System DSN with rajeshrNew and my default.properties file look like this..
# maximum size of message driven bean instance
# pool per mdb type
messagebean.pool.size=3
# maximum size of a "bulk" message bean delivery
messagebean.max.serversessionmsgs=1
# message-bean container resource cleanup interval
messagebean.cleanup.interval=600
passivation.threshold.memory=128000000
idle.resource.threshold=600
log.directory=logs
log.output.file=output.log
log.error.file=error.log
log.event.file=event.log
distributed.transaction.recovery=false
transaction.timeout=0
transaction.nonXA.optimization=true
sessionbean.timeout=0
# validating parser values
# validating.perser is used when archive file are loaded by
# any of the J2EE Reference Implementation tools.
# deployment.validating.parser is used when deploying an
# archive on the J2EE AppServer.
validating.parser=false
deployment.validating.parser=true
now u tell me what i have to change..
with regards
Rajesh -
Hi,
I am getting the following error when I try to do a search on an ldap (AD LDS) database:
javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031522C9, problem 2001 (NO_OBJECT), data 0, best match of:
'DC=AppPartFE,DC=com'
]; remaining name 'cn=Users,dc=AppPartFE,dc=com'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.searchAux(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.c_search(Unknown Source)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(Unknown Source)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(Unknown Source)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(Unknown Source)
at javax.naming.directory.InitialDirContext.search(Unknown Source)
at Test.<init>(Test.java:70)
at Test.main(Test.java:118)
I can bind successfully using either the userPrincipalName (UPN) or the Distinguished Name (DN), however my search is failing.
It is almost as if I am connected to the db tree at the wrong place. Do I need a different search scope?
I appreciate any assistance you can provide.
Here is my code:
import java.util.*;
import static java.lang.System.err;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
public class Test
public Test()
Properties prop = new Properties();
prop.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
prop.put("java.naming.provider.url", "ldap://MyHost.Mydomain.labs.CompanyX.com:50004");
String strProviderUrl = "ldap://MyHost.Mydomain.labs.CompanyX.com:50004";
// Can successfully bind with the userPrincipalName in AD LDS
//prop.put("java.naming.security.principal", "[email protected]");
// Can successfully bind with Distinguished Name
// Note: the string is case insensitive and embedded blank after a comma is not a problem
prop.put("java.naming.security.principal", "cn=tst0001,cn=Users,dc=AppPartFE,dc=com");
prop.put("java.naming.security.credentials", "password");
try {
LdapContext ctx = new InitialLdapContext(prop, null);
System.out.println("Bind successful");
//I am successful to this point....
//now try doing a search on another user
String strFilter = "(&(objectClass=userProxy)(sAMAccountName=tst0001))";
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); //works with object class=* to find top partition node
NamingEnumeration<SearchResult> results = ctx.search("cn=Users,dc=AppPartFE,dc=com", strFilter, searchControls);
SearchResult searchResult = null;
if(results.hasMoreElements()) {
searchResult = (SearchResult) results.nextElement();
//make sure there is not another item available, there should be only 1 match
if(results.hasMoreElements()) {
System.err.println("Matched multiple users for the accountName");
catch (NamingException ex) {
ex.printStackTrace();
public static void main(String[] args)
Test ldaptest = new Test();Because you are specifiying a base distinguished name in your ldap url, the ldap context will be rooted at that context and all subsequent objects will be relative to that base distinguished name.//connect to my domain controller
String ldapURL = "ldaps://rhein:636/dc=bodensee,dc=de";andString userName = "CN=verena bit,OU=Lehrer,OU=ASR,DC=bodensee,DC=de";results in an fully distinguished name of:CN=verena bit,OU=Lehrer,OU=ASR,DC=bodensee,DC=de,dc=bodensee,dc=deEither specify your ldap url asString ldapURL = "ldaps://rhein:636";and leave your username as is, or specify the user object relative to the base distinguished name in the ldapurlString userName = "CN=verena bit,OU=Lehrer,OU=ASR"; -
Javax.naming.NameAlreadyBoundException [LDAP: error code 68
I am getting the below Error when I am trying to add the entry into the LPAD Server.
javax.naming.NameAlreadyBoundException: [LDAP: error code 68 - Entry Already Exists]; remaining name 'ou=People,dc=company,dc=co,dc=in'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.c_bind(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.c_bind(Unknown Source)
at com.sun.jndi.toolkit.ctx.ComponentContext.p_bind(Unknown Source)
at com.sun.jndi.toolkit.ctx.PartialCompositeContext.bind(Unknown Source)
at com.sun.jndi.toolkit.ctx.PartialCompositeContext.bind(Unknown Source)
at javax.naming.InitialContext.bind(Unknown Source)
at com.test.CreateUser.main(CreateUser.java:54)
I am using the following sample program to test this.
public class CreateUser {
public static void main(String[] args) {
java.util.Hashtable env = new java.util.Hashtable();
env.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
env.put( javax.naming.Context.PROVIDER_URL, "ldap://c-4966:62260");
env.put( javax.naming.Context.SECURITY_AUTHENTICATION, "simple");
env.put( javax.naming.Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
env.put( javax.naming.Context.SECURITY_CREDENTIALS, "test");
String dn = "ou=People,dc=company,dc=co,dc=in";
try {
// create DirContext
DirContext ctx = new InitialDirContext(env);
// Attributes for new entry
Attributes attrs = new BasicAttributes();
Attribute attr = new BasicAttribute("objectclass");
attr.add( 0, "top" );
attr.add( 1, "person" );
attr.add( 2, "organizationalPerson" );
attr.add( 3, "inetorgperson" );
attrs.put(attr);
System.out.println("1...........");
attrs.put("cn", "Sai Krishna");
attrs.put("sn", "Potluri");
attrs.put("givenName","Sia Potluri");
attrs.put("uid","saipotluri");
attrs.put("userPassword", "balaji");
/*attr = new javax.naming.directory.BasicAttribute("mail");
attr.add( 0, "[email protected]" );
attr.add( 1, "[email protected]" );
attrs.put( attr );
attrs.put( "telephonenumber", "111-1111-3333" );*/
System.out.println("2...........");
ctx.bind(dn, attrs);
} catch ( javax.naming.NamingException ex ) {
System.err.println("Fail to Add Entry\n");
ex.printStackTrace();
Any help is highly appreciated.
Thanks in Advance
DARMAYou're adding the entry "ou=people,dc=company,dc=co,dc=in" and not an entry under "ou=people,dc=company,dc=co,dc=in".
The dn of the new entry should be something like "cn=Sai Krishna,ou=people,dc=company,dc=co,dc=in" when you call ctx.bind(dn,...) -
Sun One Webserver Connection Pooling - javax.naming.NamingException
I'm trying to configure a container managed datasource in Sun One Webserver. I've followed the steps given in the Sun One Webserver Administrator's Guide, however when I try to lookup the datasource I get a "javax.naming.NamingException: Cannot create resource instance" exception (full stack trace below). I have verified the database connection info (URL/user/password) is correct using Squirrel and I've appended the location of classes12.jar to the server's classpath in server.xml. Relevant snippets from the configuration files, my lookup code, and the stack trace are below. I've been beating my head on this for almost two days and I would appreciate any tips on how to debug this.
web.xml
<resource-ref>
<description>JNDI DataSource</description>
<res-ref-name>jdbc/web920</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Sharable</res-sharing-scope>
</resource-ref>
sun-web.xml
<resource-ref>
<res-ref-name>jdbc/web920</res-ref-name>
<jndi-name>jdbc/web920</jndi-name>
</resource-ref>
server.xml
<RESOURCES>
<JDBCCONNECTIONPOOL name="web920" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idletimeout="300" maxwaittime="60000" connectionvalidationrequired="off"
connectionvalidationmethod="auto-commit" validationtablename="" failallconnections="off" transactionisolationlevel="read-uncommitted" isolationlevelguaranteed="off">
<PROPERTY name="URL" value="jdbc:oracle:thin:@d1web920.mydomain.com:1521:d1web920" />
<PROPERTY name="User" value="<username>" />
<PROPERTY name="Password" value="<password>" />
</JDBCCONNECTIONPOOL>
<JDBCRESOURCE jndiname="jdbc/web920" poolname="web920" enabled="on" />
</RESOURCES>
Lookup code
private static DataSource getDataSource(){
DataSource ds = null;
try {
Object o = new InitialContext().lookup("java:comp/env/jdbc/web920");
ds = (DataSource) o;
} catch (NamingException e) {
System.out.println("Error retrieving DataSource.");
e.printStackTrace();
return ds;
Stack Trace
warning: CORE3283: stderr: javax.naming.NamingException: Cannot create resource instance
warning: CORE3283: stderr: at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:167)
warning: CORE3283: stderr: at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
warning: CORE3283: stderr: at org.apache.naming.NamingContext.lookup(NamingContext.java:834)
warning: CORE3283: stderr: at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
warning: CORE3283: stderr: at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
warning: CORE3283: stderr: at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
warning: CORE3283: stderr: at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
warning: CORE3283: stderr: at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
warning: CORE3283: stderr: at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
warning: CORE3283: stderr: at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
warning: CORE3283: stderr: at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
warning: CORE3283: stderr: at javax.naming.InitialContext.lookup(InitialContext.java:351)
warning: CORE3283: stderr: at mil.army.usaac.portal.util.DatabaseConnectionManager.getDataSource(DatabaseConnectionManager.java:99)
warning: CORE3283: stderr: at mil.army.usaac.portal.util.DatabaseConnectionManager.init(DatabaseConnectionManager.java:40)
warning: CORE3283: stderr: at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:921)
warning: CORE3283: stderr: at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813)
warning: CORE3283: stderr: at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3478)
warning: CORE3283: stderr: at org.apache.catalina.core.StandardContext.start(StandardContext.java:3760)
warning: CORE3283: stderr: at com.iplanet.ias.web.WebModule.start(WebModule.java:251)
warning: CORE3283: stderr: at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133)
warning: CORE3283: stderr: at org.apache.catalina.core.StandardHost.start(StandardHost.java:652)
warning: CORE3283: stderr: at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133)
warning: CORE3283: stderr: at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:355)
warning: CORE3283: stderr: at org.apache.catalina.startup.Embedded.start(Embedded.java:995)
warning: CORE3283: stderr: at com.iplanet.ias.web.WebContainer.start(WebContainer.java:431)
warning: CORE3283: stderr: at com.iplanet.ias.web.WebContainer.startInstance(WebContainer.java:500)
warning: CORE3283: stderr: at com.iplanet.ias.server.J2EERunner.confPostInit(J2EERunner.java:161)we are trying to connect MS Access thru tomcat and it is giving the above exception
i have changed the server.xml
<Resource name="jdbc/Mess" auth="Container" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/Mess">
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>password</name>
<value>admin</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:odbc:Mess</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>sun.jdbc.odbc.JdbcOdbcDriver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>username</name>
<value>admin</value>
</parameter>
</ResourceParams>
web.xml
<resource-ref>
<description>Access Datasource example</description>
<res-ref-name>jdbc/Mess</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
java class
Context initContext = new InitialContext();
DataSource ds = (DataSource)initContext.lookup("java:/comp/env/jdbc/Mess");
con = ds.getConnection();
Please help.......
Maybe you are looking for
-
Printing to PDF using Chrome, and then save as a Word doc.
I want to print a webpage using Chrome to PDF, and then save that PDF to a Word document. The problem is occurring when saving the PDF to a Word doc, as the Word document is blank. Im using Adobe Acrobat X, Chrome version 32.0.1700.107 m. (This quest
-
Can't import .RTF into Boris Title Crawl without crashing
I laid out my titles in Word, saved as an .RTF and then when I clicked import in Boris Title Generator (crawl) and selected the .RTF file, FCP crashes. I tried opening a new empty project and doing the title there - same problem. I tried cutting my .
-
Cant create connection Pool for MS SQL Server 2000 with Microsoft Driver
i am using bea weblogic server 6.1, i cant create connection pool while using MS SQL Server 2000. i have installed JDBC Driver SAP1 from microsoft website. when i give the following class name for JDBC driver and the connection url and click apply wh
-
SharePoint Custom New Form with DataForm Webpart SharePoint 2010
Hi Guys, i have a Problem with my Custom NewForm.ASPX. I Created a CustomForm like this Guide: http://www.ilikesharepoint.de/2013/11/sharepoint-create-custom-list-forms-with-visual-studio-part-2/ Problem Now i set the DataFormWebpart for the Webpart
-
Using pre-step callbacks to setup test conditions
I am trying to setup a pre-step callback to verify test conditions and correct them if they do not match the needs of the applicable test step. I was going to assign the test conditions in the pre-expression of each test step, but unfortunately I ha