Problem with JNDI in WLS 5.1
Hi all,
i have a problem with JNDI in WLE 5.1.
i am accessing an LDAP on another machine running Netscape Directory Server.
The host URL is ldap://myhost:65535/o=marco, c=fi
i am always getting back the following exception:
javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.
WLInitialContextFactory. Root exception is java.lang.ClassCastException: weblog
ic.jndi.WLInitialContextFactory
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
58)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242
at javax.naming.InitialContext.init(InitialContext.java:218)
at javax.naming.InitialContext.<init>(InitialContext.java:194)
and my code is this:
Hashtable _environment = new Hashtable();
try {
environment.put(Context.INITIALCONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
environment.put(Context.PROVIDERURL, "ldap://myhost:65535");
if ((principal!=null) || (credentials!=null)) {
environment.put(Context.SECURITYAUTHENTICATION, "simple");
environment.put(Context.SECURITYPRINCIPAL, principal);
environment.put(Context.SECURITYCREDENTIALS, credentials);
context = new InitialContext(environment);
parser = context.getNameParser(initialCtxFactory);
} catch(Exception e) {
e.printStackTrace();
can anyone help me please??
thanx in advance
marco
Take out the "weblogic.jndi.WLInitialContextFactory" and add the respective factory NAME..
environment.put(Context.INITIALCONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
Cheers,
Naggi
Senthil Kumar S wrote:
http://weblogic.com/docs51/classdocs/API_jndi.html#delegate
Marco wrote:
Hi all,
i have a problem with JNDI in WLE 5.1.
i am accessing an LDAP on another machine running Netscape Directory Server.
The host URL is ldap://myhost:65535/o=marco, c=fi
i am always getting back the following exception:
javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.
WLInitialContextFactory. Root exception is java.lang.ClassCastException: weblog
ic.jndi.WLInitialContextFactory
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
58)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242
at javax.naming.InitialContext.init(InitialContext.java:218)
at javax.naming.InitialContext.<init>(InitialContext.java:194)
and my code is this:
Hashtable _environment = new Hashtable();
try {
environment.put(Context.INITIALCONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
environment.put(Context.PROVIDERURL, "ldap://myhost:65535");
if ((principal!=null) || (credentials!=null)) {
environment.put(Context.SECURITYAUTHENTICATION, "simple");
environment.put(Context.SECURITYPRINCIPAL, principal);
environment.put(Context.SECURITYCREDENTIALS, credentials);
context = new InitialContext(environment);
parser = context.getNameParser(initialCtxFactory);
} catch(Exception e) {
e.printStackTrace();
can anyone help me please??
thanx in advance
marco--
http://www.net4tech.com
Similar Messages
-
Please Help me!!!!!! Problems with JNDI and datasouces
Hello Friends.
I'm new in JNDI, sorry for my english
I am working wit java,jsp,struts and connect to Oracle 8i database but with the traditional way.
In this moment i can connect to datasouce with JNDI from jsp or java servlet of this way without problems.
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:comp/env/");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection C = ds.getConnection();
But, When i try to connect from java class compiled out of tomcat is does'nt work, the program show trobles like
"javax.naming.NameNotFoundException: java:comp/env/"
whit this java code:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
try {
Context ctx = new InitialContext(env);
Context envContext = (Context)ctx.lookup("java:comp/env/");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection();
} catch (NamingException e) {
System.err.println(e.getMessage());
i have the jar's file fscontext.jar, providerutil.jar, jndi alocated in WEB-INF/lib/
Please Help me!!!Results using
try{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
Context initContext = new InitialContext(env);
Context envContext = (Context)initContext.lookup("java:comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection C = ds.getConnection();
}catch(Exception E){
System.out.println(E.getMessage()+E.getClass());
Result : Cannot connect to ORBclass javax.naming.CommunicationException -
Problem with JNDI/LDAP AND connection pool
I'm a newbie to Java but am attempting to write a servlet that retrieves info use to populate the contents of drop down menus. I'd like to only have to do this once. The servlet also retrieves other data (e.g. user profile info, etc ...). I'd like to be able to use the connection pool for all of these operations but I'm getting a compile error:
public class WhitePages extends HttpServlet {
ResourceBundle rb = ResourceBundle.getBundle("LocalStrings");
public static String m_servletPath = null;
public static String cattrs = null;
public static String guidesearchlist[] = {};
public static int isLocalAddr = 0;
private int aeCtr;
private String[] sgDNArray;
private HashMap sgDN2DNLabel = new HashMap();
private HashMap sgDN2SearchGuide = new HashMap();
private String strport;
private int ldapport;
private String ldaphost;
private String ldapbinddn;
private String ldapbindpw;
private String ldapbasedn;
private int maxsearchcontainers;
private int maxsearchkeys;
private String guidesearchbases;
private String guidecontainerclass;
private String strlocaladdr;
private String providerurl;
// my init method establishes the connection
// pool and then retrieve menu data
public void init(ServletConfig config) throws ServletException {
super.init(config);
String strport = config.getInitParameter("ldapport");
ldapport = Integer.parseInt(strport);
String strconts = config.getInitParameter("maxsearchcontainers");
maxsearchcontainers = Integer.parseInt(strconts);
String strkeys = config.getInitParameter("maxsearchkeys");
maxsearchkeys = Integer.parseInt(strkeys);
ldaphost = config.getInitParameter("ldaphost");
ldapbinddn = config.getInitParameter("ldapbinddn");
ldapbindpw = config.getInitParameter("ldapbindpw");
ldapbasedn = config.getInitParameter("ldapbasedn");
guidesearchbases = config.getInitParameter("guidesearchbases");
guidecontainerclass = config.getInitParameter("guidecontainerclass");
strlocaladdr = config.getInitParameter("localaddrs");
providerurl = "ldap://" + ldaphost + ":" + ldapport;
/* Set up environment for creating initial context */
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, providerurl.toString());
/* Enable connection pooling */
env.put("com.sun.jndi.ldap.connect.pool", "true");
StringTokenizer st = new StringTokenizer(guidesearchbases, ":" );
String guidesearchlist[] = new String[st.countTokens()];
for ( int i = 0; i < guidesearchlist.length; i++ ) {
guidesearchlist[i] = st.nextToken();
// Get a connection from the connection pool
// and retrieve the searchguides
StringBuffer asm = new StringBuffer(""); // This is the advanced search menu htmlobject buffer
StringBuffer strtmpbuf = new StringBuffer(""); // This is the simple search menu htmlobject buffer
try {
StringBuffer filter = new StringBuffer("");
filter.append("(objectclass=" + guidecontainerclass + ")");
String[] attrList = {"dn","cn","searchguide"};
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes(attrList);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String attrlabelkey;
sgDNArray = new String[guidesearchlist.length];
for( int i = 0; i < guidesearchlist.length; i++ ) {
// Search each of the namingspaces where
// searchguides exist then build
// the dynamic menus from the result
DirContext ctx = new InitialDirContext(env);
NamingEnumeration results = ctx.search(guidesearchlist, filter, ctls);
I get a compile error:
WhitePages.java:164: cannot resolve symbol
symbol : method search (java.lang.String,java.lang.StringBuffer,javax.naming.directory.SearchControls)
location: interface javax.naming.directory.DirContext
NamingEnumeration results = ctx.search(guidesearchlist[i], filter, ctls);
^
WhitePages.java:225: cannot resolve symbol
symbol : variable ctx
location: class OpenDirectory
ctx.close();
^
Can anyone help? If there is someone out there with JNDI connection pool experience I would appreciate your assistance!Manish
The issue may not be related to the number of connections or the initial
connections. Check your heap size (ms, mx). Turn on verbosegc. Your heap may
not be big enough to accept the 25,000 rows.
Bernie
"Manish Kumar Singh" <[email protected]> wrote in message
news:3e6c34ca$[email protected]..
We are creating the result set with 25000 rows(each row has 56 columns) bygetting the connection using data source. With the initial capacity of the
connection pool is 5 and the max capacity as 30 and grow connection as 1,
the server gets out of memory exception, when we issue a new request, even
after closing the previous connections.
Now, if we change the initial capacity to 1 and rest all the things assame, the issue gets resolved and the server works fine.
Could you please help me out in this regard????
thanks in advance
manish -
PROBLEMS WITH JNDI AND NAMEPARSER/URGENT
Hi all,
i am experiencing lot of problems in accessing an LDAP under
NetscapeDirectory Server using WLS.
i can connect to the LDAP (using a delegate provider, the one from Sun),
however, when
i try to get the NameParser from the context, i always got the exception
Exception in thread "main" java.io.IOException: Class
com.sun.jndi.ldap.LdapName
Parser with code=123 does not implement Serializable, Externalizable or
WLSerial
izable
at
weblogic.common.internal.WLObjectOutputStreamBase.writeObjectBody(WLO
bjectOutputStreamBase.java:895)
at
weblogic.common.internal.WLObjectOutputStreamBase.writeObject(WLObjec
tOutputStreamBase.java:1011)
at
weblogic.common.internal.WLObjectOutputStreamBase.writeObjectWL(WLObj
ectOutputStreamBase.java:166)
at
weblogic.rmi.extensions.AbstractOutputStream2.writeObject(AbstractOut
putStream2.java:82)
at
weblogic.jndi.remote.DirContextWrapper_WLSkel.invoke(DirContextWrappe
r_WLSkel.java:299)
at
weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(BasicServerOb
jectAdapter.java, Compiled Code)
at
weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicReques
tHandler.java:69)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:15)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java,
Compiled Code)
--------------- nested within: ------------------
weblogic.rmi.MarshalException: error marshalling return
- with nested exception:
[java.io.IOException: Class com.sun.jndi.ldap.LdapNameParser with
code=123 does
not implement Serializable, Externalizable or WLSerializable]
at
weblogic.jndi.remote.DirContextWrapper_WLSkel.invoke(DirContextWrappe
r_WLSkel.java:301)
at
weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(BasicServerOb
jectAdapter.java, Compiled Code)
at
weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicReques
tHandler.java:69)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:15)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java,
Compiled Code)
--------------- nested within: ------------------
weblogic.rmi.ServerException: A remote exception occurred while
executing the me
thod on the remote object
- with nested exception:
[weblogic.rmi.MarshalException: error marshalling return
- with nested exception:
[java.io.IOException: Class com.sun.jndi.ldap.LdapNameParser with
code=123 does
not implement Serializable, Externalizable or WLSerializable]]
at
weblogic.rmi.extensions.AbstractRequest.sendReceive(AbstractRequest.j
ava:76)
at
weblogic.jndi.remote.DirContextWrapper_WLStub.getNameParser(DirContex
tWrapper_WLStub.java:929)
at
javax.naming.InitialContext.getNameParser(InitialContext.java:499)
at
com.nokia.nsg.admintool.model.DelegateTest.main(DelegateTest.java:43)
--------------- nested within: ------------------
weblogic.rmi.extensions.RemoteRuntimeException: Undeclared checked
exception - w
ith nested exception:
[weblogic.rmi.ServerException: A remote exception occurred while
executing the m
ethod on the remote object
- with nested exception:
[weblogic.rmi.MarshalException: error marshalling return
- with nested exception:
[java.io.IOException: Class com.sun.jndi.ldap.LdapNameParser with
code=123 does
not implement Serializable, Externalizable or WLSerializable]]]
at
weblogic.jndi.remote.DirContextWrapper_WLStub.getNameParser(DirContex
tWrapper_WLStub.java:954)
at
javax.naming.InitialContext.getNameParser(InitialContext.java:499)
Has anyone ever find this exception???
can anyone help me???
thanx in advance and regards
marcoFriend, In LAN the network speed is high so you don't feel the problem. But on real network the speeds becomes slow and when one thread on the reading process is suspended and the other on write is executed the results are ostensible to be unreliable.
One alternative is use synchronization or some synchronization flag, but I suggest you to have one thread for both the task. Though you have a thread for each client connected.
Single thread model will help you to avoid synchronization headches and also the access won't be simultaneous.
You have to change the design a little.
Hope that works,
Ashish -
Problem with JNDI and JSP in Tomcat
Hi,
Basically, what I've done is to use the Tomcat administration web
application to create the DataSource, which looks like it populated the
server.xml (see below). I then try to access the testconn.jsp, and am
getting that "Name java:comp is not bound in this Context" error.
I was wondering if anyone could tell me what I'm doing wrong?
Thanks,
Feri
My Configuration:
- Tomcat 5.0.19
- MySQL 4.0.18-nt
- mysql-connector-java-3.0.15-ga-bin.jar
server.xml:
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
<!--Feri test JNDI-->
<Context crossContext="true" debug="5" docBase="injury" path="/injury" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_injury_log." suffix=".txt" timestamp="true"/>
<Resource name="jdbc/injury" auth="Container"
type="javax.sql.DataSource">
</Resource>
<ResourceParams name="jdbc/injury">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>root</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/injury</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
</ResourceParams>
</Context>
<!--Feri test JNDI end-->
</GlobalNamingResources>
\webapps\injury\WEB-INF\web.xml:
<resource-ref>
<description>Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file.</description>
<res-ref-name>jdbc/injury</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
\webapps\injury\testconn.jsp
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ taglib prefix="ct" uri="/injury" %>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<h1>Connection test</h1>
<ct:connection name="jdbc/injury">
<%
Statement stmt= conn.createStatement();
ResultSet rs;
rs = stmt.executeQuery("select * from user");
while (rs.next()){
%><%=rs.getString(1)%><%=rs.getInt(2) %><br><%
rs.close();
stmt.close();
%>
</ct:connection>
ConnectionTag.java
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import javax.naming.*;
import javax.sql.*;
import javax.sql.DataSource;
public class ConnectionTag extends TagSupport implements TryCatchFinally {
private Connection conn;
// JNDI name of the connection
private String name;
public void setName(String name)
this.name = name;
public int doStartTag()
throws JspException
try {
Context env = (Context) new InitialContext().lookup("java:comp/env");
DataSource ds = (DataSource) env.lookup(name);
if (ds != null)
conn = ds.getConnection();
} catch (Exception e) {
throw new JspException(e);
if (conn == null)
throw new JspException("can't open connection " + name);
pageContext.setAttribute("conn", conn);
return EVAL_BODY_INCLUDE;
public void doCatch(Throwable t)
throws Throwable
throw t;
public void doFinally()
try {
Connection conn = this.conn;
this.conn = null;
pageContext.removeAttribute("conn");
conn.close();
} catch (Exception e) {
Tomcat 5.0\conf\Catalina\localhost\injury.xml
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="Injury" docBase="E:\Tomcat 5.0\webapps\injury" path="/injury" className="org.apache.catalina.core.StandardContext"
cachingAllowed="true" charsetMapperClass="org.apache.catalina .util.CharsetMapper" cookies="true" crossContext="false" debug="0"
mapperClass="org.apache.catalina.core.StandardContextMapper" useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper" >
<Resource auth="Container" description="Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file." name="jdbc/injury" type="javax.sql.DataSource"/>
<ResourceLink global="jdbc/injury" name="injury" type="javax.sql.DataSource"/>
</Context>Hi,
First of all, you can find alot of information about this in the forum about jsp's.
I think a good thing to do is not to put your context tag directly into the server.xml file.
What you should do is create a context.xml file with the context-tag in it, and put it in the META-INF directory of your .war file. Upon deployment to tomcat5 this file will be extracted from the war, copied to the conf\enginename\hostname directory, and it will be renamed to contextName.xml.
I think you are developing directly into the webapps directory, and I believe you should avoid that and use the deployment feature of the manager web-app or you should use the deployertool from you ide or standalone ant.
anyway, for starters try to remove the context tag from the server.xml file as described above, and check out the jsp / jdbc forums for simular problems and answers.
good luck -
Problems with JNDI lookup for java:comp/env/ejb
Hi all,
I'm using OC4J 9.0.3 and I have problems when looking up for the local
EJB context.
I have a SLSB which refers to another SLSB via a JNDI mapping like
shown below. Both services are deployed within one EAR file.
(snippets of ejb-jar.xml and orion-ejb-jar.xml)
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>ServiceABean</ejb-name>
<home>com.coi.ServiceAHome</home>
<remote>com.coi.ServiceA</remote>
<ejb-class>com.coi.ServiceABean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/some/sub/packages/ServiceB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.coi.ServiceBHome</home>
<remote>com.coi.ServiceB</remote>
</ejb-ref>
</session>
</enterprise-beans>
</ejb-jar>
<orion-ejb-jar>
<enterprise-beans>
<session-deployment location="global/some/sub/packages/ServiceA" name="ServiceABean">
<ejb-ref-mapping name="ejb/some/sub/packages/ServiceB" location="global/some/sub/packages/ServiceB" />
</session-deployment>
</enterprise-beans>
</orion-ejb-jar>
The ApplicationInitialContextFactory will be used (prepared by the container),
so the lookup for ServiceB within a method of ServiceA should work as follows:
public class ServiceABean implements SessionBean
public void someMethod()
InitialContext con = new InitialContext(); // will be of class ApplicationContext
Context localEjbContext = (Context)con.lookup( "java:comp/env/ejb" );
ServiceBHome serviceBHome = (ServiceBHome) PortableRemoteObject.narrow(
localEjbContext.lookup( "some/sub/packages/ServiceB" ),
ServiceBHome.class );
The problem is now, that the lookup for "java:comp/env/ejb" doesn't work
and throws a NameNotFoundException.
To figure out what's actually happening during lookup I debugged a little bit and
tried a few things:
1. A lookup for "java:comp" works fine. It returns an instance of class FlatMapContext
which consists of a hash map which itself contains an entry for "env".
2. So a lookup for "env" on that FlatMapContext also works and returns an instance of SubContext.
3. A lookup for "ejb" using this SubContext causes a NameNotFoundException
with message "java:comp/env/ejb not found".
4. A lookup like con.lookup( "java:comp/env" ) throws also a NameNotFoundException
with message "java:comp/env not found (not inside a J2EE module, for instance a Web-App,
EJB, or Application-Client)".
Does anyone know something about this?
Regards
--thomasHi Debu,
Great! 9.0.4 will be released in june/july this year, right? Sorry for my ironical reaction, but does that mean, that I don't have any chance to get my whole stuff running in 9.0.3? I cannot believe that. Isn't there a wordaround I could apply? A setting or whatever to substitute the daft FlatCtx by something else that is implemented according to the spec?
Regards
--thomas -
Problems with JNDI between JSP and EJB
Good morning:
I've got a problem related to EJB and JNDI.
I want to run methods of an EJB that is in Weblogic, from a JSP that runs IPlanet. When I try to execute getInitialContext() I catch a NamingException. The error description is :Cannot instantiate class: weblogic.jndi.T3InitialContextFactory
I have this code in the JSP:
Context initialCtx;
initialCtx = getInitialContext();
private InitialContext getInitialContext() throws NamingException
Properties p = new Properties();
(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.T3InitialContextFactory");
(Context.PROVIDER_URL,"t3://atlas:7001");
InitialContext ctx = null;
ctx = new InitialContext(p);
return ctx;
Configuration:
JSP runs in IPlanet 4.1 SP7
EJB runs in a Weblogic 5.1. Atlas it's the server name
IPlanet and Weblogic runs on differents machines.
Can anybody help me?
Thanks in advance
DavidI have two weblogic jars (weblogicaux.jar and one service pack of weblogic) in the iplanet classpath.
I don't know if I have to configure Weblogic with any special parameter (RMI/IIOP) or something similar in IPlanet.
Can anybody help me?
Thanks. -
Jboss and eclipse, problems with JNDI
Hi, i have managed to deploy my j2ee application (according to jboss), its a simple HelloWorld app, problem is when i try to look it up.
In the client:
System.out.println("starter");
Context context = new InitialContext();
System.out.println("etter context");
Object objref = context.lookup("HelloWorld");
// Stops here and a javax.naming.NoInitialContextException is thrown...
// What is wrong?
The jboss.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 2.4//EN" "http://www.jboss.org/j2ee/dtd/jboss_2_4.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>HelloWorld</ejb-name>
<jndi-name>ejb/HelloWorld</jndi-name>
</session>
</enterprise-beans>
<resource-managers>
</resource-managers>
</jboss>I have managed to run the file now but i had to do it from command prompt and include every jar file from jboss + the files in my project. My problem now is an eclipse problem i think.
I have created a client wich looks up the ejb, but the thing is that i have to manually import a bunch of jboss jar-files to get it to work. isn't there a way i can make eclipse / jboss import those jar's automatically? perhaps create a client automatically or something?
Hope someone can help.. -
hi,
i created my own Queue and QueueConnectionFactory using the j2eeadmin tool. both objects show up just fine when i run j2eeadmin -listXXX
however when i try to lookup either one of these with the runtime api, i get javax.naming.NameAlreadyBoundException
my client code may not be correct, but here's what i have:
InitialContext jndiContext = new InitialContext();
jndiContext.lookup( name );
where name is the name that object is bound to.
if anyone has any idea what i'm doing wrong, please let me know.
thanks,
mark.u can set jndi name during u deploy the EJB ,for example ,after u start the deploytool ,u have built a group of ejb classes such as sessionbean, remote interface ,home interface ,then deploy them as a ejb,after this u can get the menu about alias ,so set the name when u write ur script to call the ejb ,just give the same name as u wrote just now
-
hi,
i am not sure whether this is right forum or not, but could not find more better place. for this i have tried to google a lot, so if you are suggesting google please provide with google key words. and gone through this page as well : http://www.jboss.org/file-access/default/members/jbossweb/freezone/docs/2.1.0/jndi-resources-howto.html
have a small requirement,
=> need to deploy a small JNDI service on JBoss 4.2.3GA and test that service from a simple java desktop client via jnp protocol.
if any one knows how to fulfill this requirement please help...
thanx in advance
AniruddhaHi Aniruddha,
Thanks for responding. However, I'm not clear with your solution. Are you asking me to reboot the machine with a -b option? Its a production system and I can't do it. The client is on the same host and it throws a Connection refused : connect exception. However, the port diagnostic tool shows a connection between the server and client.
Thanks & Regards,
RNE -
JNDI problem with Sun Application Server
I am trying to call a extremely simple EJB from a remote computer. But everytime I run the client I get a Class castException. I have used Weblogic and Jboss in the past and I never had any problem with JNDI. I included all the files except for the descriptor. Please help, this is driving me nut.
Here is the exception i get:
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at clients.testEjbTest.main(testEjbTest.java:42)
The remote Interface :
package ejb.test;
import javax.ejb.*;
public interface Test extends javax.ejb.EJBObject{
public String getResult() throws java.rmi.RemoteException;
The Home interface is:
package ejb.test;
import javax.ejb.*;
public interface TestHome extends javax.ejb.EJBHome{
public Test create() throws java.rmi.RemoteException, CreateException;
The Bean is:
package ejb.test;
import javax.ejb.*;
public class TestBean implements javax.ejb.SessionBean {
public TestBean() {}
public String getResult() { return "hello";}
public void ejbActivate() { }
public void ejbPassivate() { }
public void ejbRemove() { }
public void ejbCreate() throws CreateException { }
public void setSessionContext(javax.ejb.SessionContext sessionContext) { }
The client is:
public class testEjbTest {
public testEjbTest() { }
public static void main(String[] args) {
try{
Properties env = new Properties();
env.setProperty("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory" );
env.setProperty("java.naming.provider.url", "iiop://192.168.0.102:3700");
InitialContext ic = new InitialContext(env);
Object objref = ic.lookup("TestBean");
Object tt = PortableRemoteObject.narrow(objref, ejb.test.TestHome.class);
}catch(Exception e){e.printStackTrace();}Hi,
I am new to this Forum.
I have an application running on Weblogic.
I want to shift to using SunOne as the Webserver and weblogic as application server.
But when I deploy the application I am getting this ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow.
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at com.elsevier.portal.admin.web.proxy.LoginProxy.getLoginSession(LoginProxy.java:156)
at com.elsevier.portal.admin.web.proxy.LoginProxy.authenticateUser(LoginProxy.java:48)
at com.elsevier.portal.admin.web.actions.LoginAction.login(LoginActi
on.java:201)
at com.elsevier.portal.admin.web.actions.LoginAction.execute(LoginAction.java:80)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java
:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:
525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
at org.apache.catalina.core.StandardWrapperValve.invokeServletServic
e(StandardWrapperValve.java:771)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
warning: CORE3283: stderr: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostVal
ve.java:209)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)The code snippet is as follows�.
protected LoginSession getLoginSession() throws ApplicationException {
LoginSessionHome home = null;
LoginSession object = null;
try {
home = (LoginSessionHome) (PortableRemoteObject.narrow(ProxyUtil.getEJBHome(getProperties().getProperty(DataCoreConstants.LOGIN_JNDI_NAME),getProperties()),LoginSessionHome.class));
object = home.create();
catch(ClassCastException cse){
cse.printStackTrace();
logger.error("Class Cast Exception is thrown while casting the Object to LoginSessionHome");
logger.error(cse);
throw new ApplicationException(ExceptionConstants.CLASS_CAST_EXCEPTION);
return object;
}Same method is running on weblogic without any problem�
Help needed urgently.
Regards,
Neha. -
hi all,
i have a problem with JNDI pooling
everything apear to be ok
but when i insert a UTF String into database the string appear a ??????????
I know that i must set the charset for the connection to utf
but i dont know how to set it in JNDI
i use this code to do it :
this code is getConnection() method
Context ctx = new InitialContext();
if(ctx == null ) {
throw new Exception("Boom - No Context");
Connection conn = null;
ds = (DataSource)ctx.lookup("java:comp/env/jdbc/jdbc/myDB");
if (ds != null) {
conn = ds.getConnection(); // get connection from datasource pool
return conn;this the web.xml
<resource-ref>
<description>DBConnection</description>
<res-ref-name>jdbc/myDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>and this the server.xml
<Context path="/myPath" docBase="myDocBase" debug="5" reloadable="true" crossContext="true" source="org.eclipse.jst.j2ee.server:myDocBase">
<Resource name="jdbc/myDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="$$$"
password="$$$"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/myTest" />
</Context>Edited by: daigoor on Jul 1, 2010 5:49 AM
Edited by: daigoor on Jul 1, 2010 5:59 AM
Edited by: daigoor on Jul 1, 2010 7:32 AMthe solution was to set the characterEncoding in the url in server.xml
even i try it before but the server was not started
he tell me that i must insert a ";" after password
finally i found that the xml file does not understand the char "&" as it so the server was not started
i search about this char in xml and found that it must be written as "&"
i try this code and its work fine
<Context path="/myDB"
docBase="myDB"
debug="5"
reloadable="true"
crossContext="true"
source="org.eclipse.jst.j2ee.server:myDB">
<Resource name="jdbc/MYdbcomhDS"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/mydb?user=$$$&password=$$$&characterEncoding=UTF8" />
</Context>thank you for help
Edited by: daigoor on Jul 4, 2010 4:25 AM -
Problem with Application build in JDeveloper 11.1.5 to WLS 10.3.5
Hi to everyone, I have a problem with a application build in JDeveloper 11.1.5 and deployed to a standalone WLS 10.3.5 ( with the JRF template appliied , to run adf applications )
When I try access to the page : localhost:7001/myApp , it show me :
"Error 403 Fordbbiben ".
but when I put :
localhost:7001/myApp/index.jspx, it show me :
Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.
and the log is :
<May 8, 2012 9:06:22 PM BOT> <Warning> <oracle.adf.view.rich.component.fragment.UIXRegion> <BEA-000000> <
java.lang.IllegalStateException: The expression "#{bindings.genRegion.regionModel}" (that was specified for the RegionModel "value" attribute of the region component with id "genRegion_dlg") evaluated to null.
This is typically due to an error in the configuration of the objects referenced by this expression.
If it helps, the expression "#{bindings.genRegion}" evaluates to "null".
If it helps, the expression "#{bindings}" evaluates to "null". Now using an empty RegionModel instead.
at oracle.adf.view.rich.component.fragment.UIXRegion.getRegionModel(UIXRegion.java:450)
at oracle.adf.view.rich.component.fragment.UIXRegion._beginInterruptibleRegion(UIXRegion.java:682)
at oracle.adf.view.rich.component.fragment.UIXRegion.processRegion(UIXRegion.java:498)
at oracle.adfinternal.view.faces.taglib.region.RegionTag.doStartTag(RegionTag.java:127)
What can I do to fix the problem ??
ThanksAnalyzing the problem, I created a new ADF application with only a web page (index.jspx) , and deploy it to the WLS, and I access to URL of page and it runs !! ( http:localhost:7001/myApp/faces/index.jspx ).
But, when I ADD A TASK FLOW to the application and deploy to the WLS newly , and try to access to the URL application's ( http:localhost:7001/myApp/faces/index.jspx ) . It show me again :
Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.
and the log is :
<May 10, 2012 19:02:57 PM BOT> <Warning> <oracle.adf.view.rich.component.fragment.UIXRegion> <BEA-000000> <
java.lang.IllegalStateException: The expression "#{bindings.genRegion.regionModel}" (that was specified for the RegionModel "value" attribute of the region component with id "genRegion_dlg") evaluated to null.
This is typically due to an error in the configuration of the objects referenced by this expression.
If it helps, the expression "#{bindings.genRegion}" evaluates to "null".
If it helps, the expression "#{bindings}" evaluates to "null". Now using an empty RegionModel instead.
at oracle.adf.view.rich.component.fragment.UIXRegion.getRegionModel(UIXRegion.java:450)
at oracle.adf.view.rich.component.fragment.UIXRegion._beginInterruptibleRegion(UIXRegion.java:682)
at oracle.adf.view.rich.component.fragment.UIXRegion.processRegion(UIXRegion.java:498)
at oracle.adfinternal.view.faces.taglib.region.RegionTag.doStartTag(RegionTag.java:127)
Why it show me that error when I ADD a Task Flow to the Application ???
Can Anyone help me please ?? I m varios days with this problem. Thanks -
Oracle XA driver problem with WLS 7.0.1.0, Oracle 9.0.1
We are using simplified chinese, after swith to bea jdriver, it messed up
all the encoding. So we cannot display Chinese character correctly.
We are using WLS 7.0.1.0, Oracle 9.0.1 on both Windows and Solaris 8
environment, BEA supplied JDK 1.3.1_03.
We have many diffrent problems with oracle drivers:
1. We want to use XA driver to support distributed transaction, However:
* bea jdriver xa messes up with encoding
* when using oracle 901 driver, everything works fince except webservices.
Workshop application access the ejb, then the workshp application sets
isolation level, but oracle driver does not support it and gives error. Is
there a way to turn off isolation level in workshop? I tried manually edit
weblogic-ejb-jar.xml, however,workshop cannot redeploy it after that.
2. When not using XA, oracle thin driver works fine. But we lost XA
capability.
Any work around?I did try to change the value in this config file as well, but did not help.
In fact, the installation default setting is with
'<transaction-isolation-level>' commented out.
And when I use bea oracle jdriver, it somehow messed up with database
character set encoding, so our Chinese characters could not be retrieved
correctly. And I try to set the encoding of jdriver to 'GBK', it did not
work.
"Anurag Pareek" <[email protected]> дÈëÏûÏ¢ÐÂÎÅ
:[email protected]..
Hello Ma,
The transaction isolation level value for EJBs backing the JWS files is
specified in the <transaction-isolation-level> tag in the
WEB-INF/weblogic-jws-config.xml file of a Workshop project. You can
manipulate this value to serve your purpose.
Please do let me know how it goes.
Regards,
Anurag
Workshop Support
"Ma Jie" <[email protected]> wrote in message
news:[email protected]..
We are using simplified chinese, after swith to bea jdriver, it messed
up
all the encoding. So we cannot display Chinese character correctly.
We are using WLS 7.0.1.0, Oracle 9.0.1 on both Windows and Solaris 8
environment, BEA supplied JDK 1.3.1_03.
We have many diffrent problems with oracle drivers:
1. We want to use XA driver to support distributed transaction, However:
* bea jdriver xa messes up with encoding
* when using oracle 901 driver, everything works fince exceptwebservices.
Workshop application access the ejb, then the workshp application sets
isolation level, but oracle driver does not support it and gives error.Is
there a way to turn off isolation level in workshop? I tried manuallyedit
weblogic-ejb-jar.xml, however,workshop cannot redeploy it after that.
2. When not using XA, oracle thin driver works fine. But we lost XA
capability.
Any work around? -
Problem with creating Connection pool and JNDI, driver is not detected
Hi,
I have an issue with creating Connection Pool and JNDI.
I'm using:
- JDK 1.6
- OS: Linux(ubuntu 8.10)
- Netbeans IDE 6.5.1
- Java EE 5.0
- Apache Tomcat 6.0.18 Its lib directory contains all necessary jar files for Oracle database driver
- Oracle 11g Enterprise
My problem is that the Oracle database driver is not detected when I want to create a pool (it works pretty well and is detected without any problem when I create ordinary connection by DriverManager)
Therefore after running:
InitialContext ic = new InitialContext();
Context context = (Context)ic.lookup("java:comp/env");
DataSource dataSource = (DataSource)context.lookup("jdbc/oracle11g");
Connection connection = dataSource.getConnection();and right after dataSource.getConnection() I have the following exception:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.OracleDriver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at servlets.Servlet1.doPost(Servlet1.java:47)
at servlets.Servlet1.doGet(Servlet1.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
... 17 more
My application context file (context.xml) is:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/WebApplication3">
<Resource auth="Container"
driverClassName="oracle.jdbc.OracleDriver"
maxActive="8"
maxIdle="4"
name="jdbc/oracle11g"
username="scott"
password="tiger"
type="javax.sql.DataSource"
url="jdbc:oracle:thin:@localhost:1521:database01" />
</Context>and my web.xml is:
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/oracle11g</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...I found similar threads in different forums including sun, such as
http://forums.sun.com/thread.jspa?threadID=567630&start=0&tstart=0
http://forums.sun.com/thread.jspa?threadID=639243&tstart=0
http://forums.sun.com/thread.jspa?threadID=5312178&tstart=0
, but no solution.
As many suggest, I also tried to put context directly in the server.xml (instead of my application context) and referencing it by <ResourceLink /> inside my application context but it didn't work and instead it gave me the following message:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class ' ' for connect URL 'null'
Has anyone succeeded in creating a connection pool with JNDI by using Tomcat 6 or higher ? If yes, could kindly explain about the applied method.
Regards,Hello again,
Finally I managed to run my application also with Tomcat 6.0.18. There was only two lines that had to be modified
in the context.xml file (the context of my application project and not server's)
Instead of writing
<Context antiJARLocking="true" path="/WebApplication2">
type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
</Context>we had to write:
<Context antiJARLocking="true" path="/WebApplication2">
type="oracle.jdbc.pool.OracleDataSource"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
</Context>- No modification was needed to be done at server level (niether server.xml nor server context.xml)
- I just added the ojdbc6.jar in $CATALINA_HOME/lib (I didn't even need to add it in WEB-INF/lib of my project)
- The servlet used to do the test was the same that I presented in my precedent post.
For those who have encountered my problem and are interested in the format of the web.xml and context.xml
with Tomcat 6.0, you can find them below:
Oracle server: Oracle 11g Enterprise
Tomcat server version: 6.0.18
Oracle driver: ojdbc.jar
IDE: Netbeans 6.5.1
The context.xml file of the web application
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/WebApplication2">
<Resource name="jdbc/oracle11g"
type="oracle.jdbc.pool.OracleDataSource"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
url="jdbc:oracle:thin:@localhost:1521:database01"
driverClassName="oracle.jdbc.OracleDriver"
userName="scott"
password="tiger"
auth="Container"
maxActive="100"
maxIdle="30"
maxWait="10000"
logAbandoned="true"
removeAbandoned="true"
removeAbandonedTimeout="60" />
</Context>The web.xml of my web application
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<resource-ref>
<description>Oracle Database 11g DataSource</description>
<res-type>oracle.jdbc.pool.OracleDataSource</res-type>
<res-auth>Container</res-auth>
<res-ref-name>jdbc/oracle11g</res-ref-name>
</resource-ref>
<servlet>
<servlet-name>Servlet1</servlet-name>
<servlet-class>servlets.Servlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet1</servlet-name>
<url-pattern>/Servlet1</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>Ok, now I'm happy as the original problem is completely solved
Regards
Maybe you are looking for
-
How do I copy music from ipod touch to new laptop (windows 7)
My computer has broken and cannot be fixed, I have now got a new laptop with windows 7, unfortunately my music didnt have a back up, and I have managed to copy my apps to the new itunes but I just cant figure out how I copy over my music? Thank you v
-
Problem with Action buttons in Presenter8
Hi, I have included 3 action buttons on a slide and set each to go to a different HIDDEN slide. When I view in regular slideshow mode, everythingworks fine, but if I publish, the FIRST time I click ANY of the action buttons, it goes past the 3 hidden
-
PSE 9 PC to MAC transfer catalog connection problem
I am transferring PSE 9 from PC to MAC and each time end up with all the photos disconnected. I'd appreciate any tips on PC to MAC catalog placement.
-
Class not found because browsers need newer runtime environment - or this
For all who are experiencing the same problem! Problem: You're compiling your applets with a quiet modern compiler (i.e. Netbeans Version 3.5.1) You are able to compile your applets without any problems but if you try your applets in "real life", the
-
Hi Friends, Is there any posibility to print Arabic fonts in Smartforms. Actually i am logging in EN Language. I had a text element which is a combination of English and Arabic word. Generally English is a LTR Language (Left to Right) and Arabic is a