Javax.naming.NamingException
When I run the following deployment. . .
java -jar ../../admin.jar ormi://localhost admin 123456 -deploy -file csldc.ear
I get this . . .
Error: javax.naming.NamingException: Lookup error: java.net.ConnectException: Co
nnection refused: connect; nested exception is: java.net.ConnectException: Connection refused: connect
any ideas???????
First, make sure oc4j is started. oc4j ships with default configuration which starts http listener at port 8888. Browse to http://localhost:8888 and you should see oc4j default website. If not, check default-web-site to see if the port is any different.
Also, ormi runs at port 23791 by default. If you have changed the port 23791 in rmi.xml, you must use java -jar admin.jar ormo://localhost:<port> .... to deploy your file
null
Similar Messages
-
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 -
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! -
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....... -
Error while starting Instance -javax.naming.NamingException: Cannot bind nu
Kindly help!!!!!
Application gets deployed on Oracle Weblogic Server 11g. But while starting its gives the Error
javax.naming.NamingException: Cannot bind null object to jndi with name.
All the things seems to be in place. Kindly helpNo I am not getting this error while deploying the application. Application gets successfully deployed.
Once I start the application I get this error
<Apr 17, 2010 5:28:46 PM IST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating
<Apr 17, 2010 5:28:46 PM IST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: Could not setup environment
at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1361)
at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:408)
at weblogic.application.internal.flow.ModuleStateDriver$2.next(ModuleStateDriver.java:182)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.ModuleStateDriver.activate(ModuleStateDriver.java:48)
Truncated. see log file for complete stacktrace
javax.naming.NamingException: Cannot bind null object to jndi with name jms/queue/EodBodQueueJNDI
at weblogic.jndi.internal.BasicNamingNode.bind(BasicNamingNode.java:311)
at weblogic.jndi.internal.WLEventContextImpl.bind(WLEventContextImpl.java:277)
at weblogic.deployment.EnvironmentBuilder.addConnectorRef(EnvironmentBuilder.java:233)
at weblogic.deployment.EnvironmentBuilder.addResourceReferences(EnvironmentBuilder.java:152)
at weblogic.servlet.internal.CompEnv.activate(CompEnv.java:138)
Truncated. see log file for complete stacktrace -
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 -
Javax.naming.NamingException Please Helppppp !!
Hi,
There is my code :
"PropertyResourceBundle namingProperties =
(PropertyResourceBundle) PropertyResourceBundle.getBundle("MyAppNaming");
Hashtable properties = getPropertyFromRB(namingProperties);
initContext = new javax.naming.InitialContext(properties);
java.lang.Object obj = initialContext.lookup(jndiName);"
The last line returns an Exception :
javax.naming.NamingException: Error during resolve [Root exception is java.lang.NullPointerException]
The Application server containing the EJBs is well started, and the JNDI name for the EJbs in the application server and in my application are the same...
Where am i wrong ??
Thanks in advance for your help
SteveHelp me please, i become crazy with this problem !!
Thanks
Steve -
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: when deploying to OC4J using admin.jar
Additional details to posting (Problem Deploying to OC4J from Jbuilder8)
Jul 8 2003 @3:27
enter:-
java -jar "\ora9ias\j2ee\home\admin.jar" ormi://myhost:23791 admin password
and you get the error message:-
javax.naming.NamingException: Lookup error: java.net.ConnectException: Connection refused: connect; nested exception is:
java.net.ConnectionException: Connection refused: connect
My server.xml contains entry <rmi-config path="./rmi.xml" />
and my rmi.xml reads:-
<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE rmi-server (View Source for full doctype...)>
- <rmi-server port="23791" host="[ALL]">
- <log>
<file path="../log/rmi.log" />
</log>
</rmi-server>
I have repeatedly checked my hostname port user name and password
along with the statements in the server.xml and rmi.xml as above, but with no
success.
Regards
Gary.I am facing the same problem from this morning. I was able to start oc4j jvm without any problem today in the morning and i could deploy the war file and was able to test the web pages. But due to some unavoidable reasons i had to restart my machine and ever since then i am running into the following error.
My server.xml has a reference to rmi.xml.
Any help is highly appreciated.
Regards
Kiran
D:\Java\JDev9i\j2ee\home>java -jar oc4j.jar
Node started with id=647722646
Error initializing web-site at ./http-web-site.xml: default-web-app not specifie
d for Oracle9iAS Containers for J2EE HTTP Web Site
Oracle9iAS (9.0.3.0.0) Containers for J2EE initialized -
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: 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....... -
Javax.naming.NamingException: Could not obtain InitialContext for URL
Hello Folks,
I am getting an error
"javax.naming.NamingException: Could not obtain InitialContext for URL" when I am trying to call a servlet(deployed in an ear file in weblogic server) from a client.
Any help or suggestion would be highly appeciable. Please let me know if any further information is required
Regards
PankajI encounter the same issues when using the TimerTask to access the JNDI tree. I have found success when I move my business logic to an EJB and call my EJB from my TimerTask. It's a bit more work, but not much. The EJB inherits it's identity based on it's configuration and has no trouble accessing the JNDI tree whenever it's called. Try this and see if your problem doesn't go away.
Hope this helps,
Perry Tew -
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. -
EJB ERR: Namingexception caught:javax.naming.NoInitialContextException
Hi,
I am trying to deploy a sample ejb on Jboss and trying to call it from a client.
I am getting the following error.
*********Before LookUP*********
Namingexception caught:javax.naming.NoInitialContextException: Need to specify c
lass name in environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
This is my client code for the ejb where I have specified the INITIAL_CONTEXT_FACTORY and PROVIDER_URL..
Am I missing something here?
Is there any other way to go about this. Any help would be greatly appreciated.
Thanks and Regards,
Ajith
THE CLIENT CODE IS AS GIVEN BELOW
package simple_bean_client;
import javax.ejb.*;
import simpleBean.*;
import javax.naming.Context;
import java.util.Properties;
import java.util.Hashtable;
import javax.naming.InitialContext;
class SalaryClient
public static void main(String args[])
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
/*Properties pro = System.getProperties();
pro.put( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory" );
pro.put( "java.naming.provider.url","localhost:1099" );*/
try{
InitialContext ctx=new InitialContext();
System.out.println("*********Before LookUP*********");
Object objRef=ctx.lookup("SalaryHome");
System.out.println("*********After LookUP*********");
SalaryHome home=(SalaryHome)javax.rmi.PortableRemoteObject.narrow(
objRef,SalaryHome.class);
Salary bean=home.create();
System.out.println("monthly net salary:"+bean.calculateSalary(28000,2,500));
}catch(javax.naming.NamingException ne){
System.out.println("Namingexception caught:"+ne);
}catch(javax.ejb.CreateException ce){
System.out.println("Create exeption caught:"+ce);
}catch(java.rmi.RemoteException re){
System.out.println("Remote Exception caught:"+re);
}//closing main
}//closing the classFound this . . .
The following works for JBOSS, jndi.properties -file:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://your.host.com:1099
The client code is as follows:
Properties prop = new Properties();
InputStream is = this.getClass().getClassLoader().getResourceAsStream(jndi_property_file);
prop.load(is);
Context ctx = new InitialContext(prop);
anEJBHome =(EJBHome)PortableRemoteObject.narrow(ctx.lookup(homeClass.getName()),homeClass); -
Javax.naming.NameNotFoundException plz guys help
hi am try to create simple ejb prj and i got this exception iam beginner so can u plz help me to knwow hats wrong
this is my entity bean
working on netbean 6 glassfish v2
* To change this template, choose Tools | Templates
* and open the template in the editor.
package doctor;
import java.io.Serializable;
import java.math.BigInteger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.transaction.UserTransaction;
* @author kriem
@Entity
@Table(name = "DOCTOR")
@NamedQueries({@NamedQuery(name = "Doctor.findByDocFname", query = "SELECT d FROM Doctor d WHERE d.docFname = :docFname"), @NamedQuery(name = "Doctor.findByDocId", query = "SELECT d FROM Doctor d WHERE d.docId = :docId"), @NamedQuery(name = "Doctor.findByDocLname", query = "SELECT d FROM Doctor d WHERE d.docLname = :docLname"), @NamedQuery(name = "Doctor.findByDocPhone", query = "SELECT d FROM Doctor d WHERE d.docPhone = :docPhone"), @NamedQuery(name = "Doctor.findByDocAddress", query = "SELECT d FROM Doctor d WHERE d.docAddress = :docAddress"), @NamedQuery(name = "Doctor.findByDocMobileNo", query = "SELECT d FROM Doctor d WHERE d.docMobileNo = :docMobileNo"), @NamedQuery(name = "Doctor.findByDocSpecialty", query = "SELECT d FROM Doctor d WHERE d.docSpecialty = :docSpecialty"), @NamedQuery(name = "Doctor.findByDocTitle", query = "SELECT d FROM Doctor d WHERE d.docTitle = :docTitle")})
public class Doctor implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "DOC_FNAME", nullable = false)
private String docFname;
@Id
@Column(name = "DOC_ID", nullable = false)
private String docId;
@Column(name = "DOC_LNAME", nullable = false)
private String docLname;
@Column(name = "DOC_PHONE")
private BigInteger docPhone;
@Column(name = "DOC_ADDRESS", nullable = false)
private String docAddress;
@Column(name = "DOC_MOBILE_NO")
private BigInteger docMobileNo;
@Column(name = "DOC_SPECIALTY", nullable = false)
private String docSpecialty;
@Column(name = "DOC_TITLE", nullable = false)
private String docTitle;
public Doctor() {
public Doctor(String docId) {
this.docId = docId;
public Doctor(String docId, String docFname, String docLname, String docAddress, String docSpecialty, String docTitle) {
this.docId = docId;
this.docFname = docFname;
this.docLname = docLname;
this.docAddress = docAddress;
this.docSpecialty = docSpecialty;
this.docTitle = docTitle;
public String getDocFname() {
return docFname;
public void setDocFname(String docFname) {
this.docFname = docFname;
public String getDocId() {
return docId;
public void setDocId(String docId) {
this.docId = docId;
public String getDocLname() {
return docLname;
public void setDocLname(String docLname) {
this.docLname = docLname;
public BigInteger getDocPhone() {
return docPhone;
public void setDocPhone(BigInteger docPhone) {
this.docPhone = docPhone;
public String getDocAddress() {
return docAddress;
public void setDocAddress(String docAddress) {
this.docAddress = docAddress;
public BigInteger getDocMobileNo() {
return docMobileNo;
public void setDocMobileNo(BigInteger docMobileNo) {
this.docMobileNo = docMobileNo;
public String getDocSpecialty() {
return docSpecialty;
public void setDocSpecialty(String docSpecialty) {
this.docSpecialty = docSpecialty;
public String getDocTitle() {
return docTitle;
public void setDocTitle(String docTitle) {
this.docTitle = docTitle;
@Override
public int hashCode() {
int hash = 0;
hash += (docId != null ? docId.hashCode() : 0);
return hash;
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Doctor)) {
return false;
Doctor other = (Doctor) object;
if ((this.docId == null && other.docId != null) || (this.docId != null && !this.docId.equals(other.docId))) {
return false;
return true;
@Override
public String toString() {
return "doctor.Doctor[docId=" + docId + "]";
public void persist(Object object) {
/* Add this to the deployment descriptor of this module (e.g. web.xml, ejb-jar.xml):
* <persistence-context-ref>
* <persistence-context-ref-name>persistence/LogicalName</persistence-context-ref-name>
* <persistence-unit-name>simple-ejbPU</persistence-unit-name>
* </persistence-context-ref>
* <resource-ref>
* <res-ref-name>UserTransaction</res-ref-name>
* <res-type>javax.transaction.UserTransaction</res-type>
* <res-auth>Container</res-auth>
* </resource-ref> */
try {
Context ctx = new InitialContext();
UserTransaction utx = (UserTransaction) ctx.lookup("java:comp/env/UserTransaction");
utx.begin();
EntityManager em = (EntityManager) ctx.lookup("java:comp/env/persistence/LogicalName");
em.persist(object);
utx.commit();
} catch (Exception e) {
java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", e);
throw new RuntimeException(e);
}my session bean
* To change this template, choose Tools | Templates
* and open the template in the editor.
package doctor;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
* @author kriem
@Stateless
public class DoctorFacade implements DoctorFacadeRemote {
@PersistenceContext
(unitName="simple-ejbPU")
private EntityManager em;
public void create(Doctor doctor) {
em.persist(doctor);
public void edit(Doctor doctor) {
em.merge(doctor);
public void remove(Doctor doctor) {
em.remove(em.merge(doctor));
public Doctor find(Object id) {
return em.find(doctor.Doctor.class, id);
public List<Doctor> findAll() {
return em.createQuery("select object(o) from Doctor as o").getResultList();
public void persist(Object object) {
em.persist(object);
}myremote interface
* To change this template, choose Tools | Templates
* and open the template in the editor.
package doctor;
import java.util.List;
import javax.ejb.Remote;
* @author kriem
@Remote
public interface DoctorFacadeRemote {
void create(Doctor doctor);
void edit(Doctor doctor);
void remove(Doctor doctor);
Doctor find(Object id);
List<Doctor> findAll();
}and for the clinet side its simple java aplication
* To change this template, choose Tools | Templates
* and open the template in the editor.
package doctor;
import java.util.Properties;
import javax.naming.Context;
import javax.rmi.PortableRemoteObject;
* @author kriem
public class client extends test {
public static void main(String [] args) {
try {
// NewServiceLocator obj=new NewServiceLocator();
test simple=new test();
simple.getDataSource("doctor");
simple.getSession("DoctorFaca");
Context jndiContext = getInitialContext( );
Object ref = jndiContext.lookup("DoctorFacade/remote");
DoctorFacadeRemote dao = (DoctorFacadeRemote)
PortableRemoteObject.narrow(ref,DoctorFacadeRemote.class);
Doctor doc=new Doctor();
doc.setDocFname("test");
doc.setDocAddress("bla bla");
doc.setDocId("D1005");
doc.setDocLname("mohamedd");
// doc.setDocMobileNo(121112223);
doc.setDocTitle("MD");
//doc.getDocPhone(2);
dao.create(doc);
Doctor doc2 = dao.find("D1002");
System.out.println(doc2.getDocSpecialty());
System.out.println(doc2.getDocFname());
System.out.println(doc2.getDocLname());
System.out.println(doc2.getDocAddress());
System.out.println(doc2.getDocMobileNo());
System.out.println(doc2.getDocPhone());
System.out.println(doc2.getDocSpecialty());
System.out.println(doc2.getDocTitle());
catch (javax.naming.NamingException ne)
{ne.printStackTrace( );
public static Context getInitialContext( )
throws javax.naming.NamingException {
Properties p = new Properties( );
// ... Specify the JNDI properties specific to the vendor.
return new javax.naming.InitialContext(p);
}and i got this exception knowing that am using entity bean from existing database that i had created
javax.naming.NameNotFoundException:
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:129)
at sun.reflect.GeneratedMethodAccessor121.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
run-simple-app-client:guys anyhelp am really lost in this
Edited by: marwacs on May 19, 2008 9:32 PMhey guys i made some updates on my sample and i figure out that as long as am creating enterprise application on netbeans 6 that contain both ejb module and client module i don`t need to write mapedName i only put the @ejb in the client side and it creates an instance of the remote interface
here is what i have done in the client code /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
package enterpriseapplication4;
import ejb.Doctor;
import ejb.DoctorFacadeRemote;
import javax.ejb.EJB;
import java.math.BigInteger;
* @author kriem
public class Main {
@EJB
private static DoctorFacadeRemote doctorFacade;
* @param args the command line arguments
public static void main(String[] args) {
// TODO code application logic here
// Object id="D1002";
// Doctor find = doctorFacade.find(id);
// find.toString();
// System.out.println(find.getDocSpecialty());
// System.out.println(find.getDocFname());
// System.out.println(find.getDocLname());
// System.out.println(find.getDocAddress());
// System.out.println(find.getDocMobileNo());
// System.out.println(find.getDocPhone());
// System.out.println(find.getDocSpecialty());
// System.out.println(find.getDocTitle());
Doctor doc=new Doctor();
BigInteger bi = BigInteger.valueOf(123);
BigInteger bh = BigInteger.valueOf(111);
doc.setDocFname("test");
doc.setDocAddress("bla bla");
System.err.print("doc Fname and address");
doc.setDocId("D1005");
doc.setDocLname("mohamedd");
doc.setDocMobileNo(bh);
doc.setDocTitle("MD");
doc.setDocMobileNo (bi);
doctorFacade.create(doc);
System.err.print("doc was added");
}but when i run i found this
May 21, 2008 6:37:08 PM com.sun.enterprise.appclient.MainWithModuleSupport <init>
WARNING: ACC003: Application threw an exception.
javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:243)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:205)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
at ejb.__DoctorFacadeRemote_Remote_DynamicStub.create(ejb/__DoctorFacadeRemote_Remote_DynamicStub.java)
at ejb._DoctorFacadeRemote_Wrapper.create(ejb/_DoctorFacadeRemote_Wrapper.java)
at enterpriseapplication4.Main.main(Main.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
at com.sun.enterprise.appclient.Main.main(Main.java:200)
Caused by: java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:251)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1386)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:210)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
at $Proxy82.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Caused by: javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:440)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:371)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3571)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
... 19 more
javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
at ejb._DoctorFacadeRemote_Wrapper.create(ejb/_DoctorFacadeRemote_Wrapper.java)
at enterpriseapplication4.Main.main(Main.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
at com.sun.enterprise.appclient.Main.main(Main.java:200)
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:461)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
at com.sun.enterprise.appclient.Main.main(Main.java:200)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
... 2 more
Caused by: javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
javax.transaction.RollbackException: Transaction marked for rollback.
at ejb._DoctorFacadeRemote_Wrapper.create(ejb/_DoctorFacadeRemote_Wrapper.java)
at enterpriseapplication4.Main.main(Main.java:50)
... 8 morethe thing is am connecting my sample with oracle db and i debuged my sample it breaks when i try to create(doc) last line in the client code ,i guess its about connecting with the database,i don`t know i also working on netbean 6
so plaz me guys another question is it possible to create statfule web services and if its plz can u send me examples
Maybe you are looking for
-
SSRS- report builder showing recent sites and server as blank
Hi All, A client of ours when executes Report builder is not able to see Report models as report builder just gets open but do not create connection to server. We have done the following settings for same: Used both name and IP of system and added th
-
Problem getting IMac G5 1.6 17" OS X10.3.9 to load...
On the Topic on Operating Systems I asked how to upgrade my OS 10.3.9 to 10.4 Tiger. I purchased the incorrect discs and they would not load in my computer. I now understand what discs to use. However, since I attempted to load one of the disks and w
-
No Browser on 8830 World Edition
My wife has inherited an 8830 World Edition on the Sprint network. It was formerly in use for a business and has some of the features blocked such as the web browser. She would like to now use it for personal use such as email (which works) and web
-
Blocked due to a physical inventory. Counts need to be entered.
Hello Experts, I am trying to move from "stock provided to vendor" to unrestricted to write off. but the Error states blocked due to a physical inventory. Counts need to be entered. I went into MI24 (See below) and there is actually a physical inven
-
Has nobody noticed, that the latest totem (1.0.4) doesn't work with the latest hal (0.5.2-3) ? totem: error while loading shared libraries: libhal.so.0: cannot open shared object file: No such file or directory I bumped on that something like one mon