JNDI generic example
Hello. I am trying to execute a generic javax.naming.Context example, which reads the env variable to initialize the Context from a jndi.properties file. I am aware the at runtime Java looks at the class path for the prop file and I have changed my classpath to reflect the prop file such as classpath=JAVA_HOME\lib\jndi.properties, where JAVA_HOME is where my java lib exists.
The program is:
import javax.naming.*;
class AppList {
public static void main(String[] args) {
String target = "";
try {
Context ctx = new InitialContext();
NamingEnumeration enum = ctx.list(target);
while (enum.hasMore()) {
System.out.println(enum.next());
} catch (NamingException e) {
e.printStackTrace();
However when I execute it I get the following error:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.list(Unknown Source)
at AppList.main(AppList.java:54)
I am aware that this error means that environment variables could not be found to initalize the Context.
I have tried changing my classpath, my JAVA_HOME, and my path to reflect the jndi.properties file, but nothing seem to work and I keep gettign he above exception.
I would apprecaite if someone could shed some light on this matter.
Thank you.
I have not tried that but -
This is a standard example from my code.
It is not exactly what you want but it may help.
The following variables are initialized elsewhere by reading from a control file.
LDAPPROVIDER = "ldap://192.168.1.103:636";
LDAPAUTHENTICATION = "simple";
LADPPROTOCOL = "ssl";
LDAPPRINCIPAL = "cn=wim,ou=roles,dc=wim,dc=ca";
LDAPCREDENTIALS = "Test1234";
// global variable to hold context
public static DirContext ctx = null;
public static DirContext openLDAPContext() {
// set up the environment
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, LDAPPROVIDER);
env.put(Context.SECURITY_AUTHENTICATION,LDAPAUTHENTICATION);
env.put(Context.SECURITY_PROTOCOL, LADPPROTOCOL);
env.put(Context.SECURITY_PRINCIPAL,LDAPPRINCIPAL);
env.put(Context.SECURITY_CREDENTIALS,LDAPCREDENTIALS);
env.put(Context.REFERRAL,"ignore");
ctx = null;
try {
ctx = new InitialDirContext(env);
// if here LDAP connection successfully
catch (NamingException ex) {
// *** LDAP SYSTEM ERROR
// if return null connection failed
return ctx;
}[b[With a search I got these - any help?[/b]
http://forum.java.sun.com/thread.jspa?forumID=51&threadID=91031
http://forum.java.sun.com/thread.jspa?forumID=51&threadID=238059
http://forum.java.sun.com/thread.jspa?forumID=51&threadID=222762
http://forum.java.sun.com/thread.jspa?forumID=48&threadID=184798
http://forum.java.sun.com/thread.jspa?forumID=48&threadID=445564
rykk
Similar Messages
-
Reading a global variable from tomcat with JNDI. Example not working
Hi you can help me to make this example work?
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
Object o = envCtx.lookup("testvariable");
<GlobalNamingResources>
<Environment name="testvariable" type="java.lang.Boolean" value="false"/>
Nice greetings ChristianI found out that in addition to having the JNDI lookup code, you have to
- have the environment variable declared in the app server configuration
- have a resource-env-ref entry in your webapp module
- have the application container bind your named variable with the global variable
I am using tomcat 5.5, and have done the following. with success.
the following example uses the default sample environment variable in the tomcat server.xml
in tomcat server.xml:
<GlobalNamingResources>
<Environment
name="simpleValue"
type="java.lang.Integer"
value="30"/>
</GlobalNamingResources>
in my application's web.xml:
<resource-env-ref>
<description>Test read resource environment variable</description>
<resource-env-ref-name>simpleValue</resource-env-ref-name>
<resource-env-ref-type>java.lang.Integer</resource-env-ref-type>
</resource-env-ref>
in my META-INF/context.xml (or otherwise, in tomcat's context deployment configuration)
<ResourceLink name="simpleValue" global="simpleValue"
type="java.lang.Integer"/>
Note: in theory, the named resource by your web app could be different from the global environment variable, but here they are the same 'simpleValue'
This is the really important step, that with out it, nothing works.,
the context.xml is known to work with tomcat when it exists in META-INF/context.xml inside the .war file (i use war files to deploy, but you should be able to create META-INF/context in an unpacked webapp directory too, and tomcat will find it.,
I can not say what it is like for other app servers, but this mapping step is the critical point that i discovered after A LOT of hair pulling.
then, make use of it, i created a jndiTest.jsp:
<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.NamingException" %>
<%
try {
Context initCtx = new InitialContext();
Context ctx = (Context) initCtx.lookup("java:/comp/env");
Object o = ctx.lookup("simpleValue");
%>
<%=o%><br>
<%
catch (NamingException ex) {
System.err.println(ex);
%>
since my server.xml defines the value for 'simpleValue' to be 30, this page displays 30 -
Please tell me a generic datasource with scenario. I want to learn how to put join condition.
Hi deepthi,
Independently of application, you can create and maintain generic DataSources for transaction data, master data attributes or texts from any kinds of transparent tables, database views, InfoSets of the SAP query or using a function module. As a result, you can make use of the generic extraction of data.
Procedure
Creating a Generic DataSource
1. Select the DataSource type and give it a technical name.
2. Choose Create.
The creating a generic DataSource screen appears.
3. Choose an application component to which the DataSource is to be assigned.
4. Enter the descriptive texts. You can choose any text.
5. Choose from which datasets the generic DataSource is to be filled.
a. Choose Extraction from View, if you want to extract data from a transparent table or a database view. Enter the name of the table or the database view.
After generation, you get a DataSource whose extract structure is congruent with the database view or the transparent table view.
For more information about creating and maintaining database views and tables, see the ABAP Dictionary Documentation.
b. Choose Extraction from Query, if you want to use a SAP query InfoSet as the data source. Select the required InfoSet from the InfoSet catalog.
Notes on Extraction Using SAP Query
After generation, you now have a DataSource whose extract structure matches the InfoSet.
For more information about maintaining the InfoSet, see the System Administration documentation.
c. Choose Extraction using FM, if you want to extract data using a function module. Enter the function module and extract structure.
The data must be transferred by the function module in an interface table E_T_DATA.
Interface Description and Extraction Process Flow
For information about the function library, see the ABAP Workbench: Tools documentation.
d. With texts, you also have the option of extraction from domain fixed values.
6. Maintain the settings for delta transfer where appropriate.
7. Choose Save.
When extracting, look at SAP Query: Assigning to a User Group.
Note when extracting from a transparent table or view:
If the extract structure contains a key figure field, that references to a unit of measure or currency unit field, this unit field must appear in the same extract structure as the key figure field.
A screen appears in which you can edit the fields of the extract structure.
8. Editing the DataSource:
 Selection
When scheduling a data request in the BW Scheduler, you can enter the selection criteria for the data transfer. For example, you may want to determine that data requests are only to apply to data from the previous month.
If you set the Selection indicator for a field within the extract structure, the data for this field is transferred in correspondence with the selection criteria in the scheduler.
Hide field
You should set this indicator to exclude an extract structure field from the data transfer. As a result of your action, the field is no longer made available in BW when setting the transfer rules and generating the transfer structure.
 Inversion
Reverse postings are possible for customer-defined key figures. For this reason, inversion is only possible for certain transaction data DataSources. These include DataSources that have a field that is indicated as an inversion field, for example, the field update mode in the DataSource 0FI_AP_3. If this field has a value, then the data records are interpreted as reverse records in BW.
Set the Inversion indicator if you want to carry out a reverse posting for a customer-defined field (key figure). The value of the key figure is then transferred in inverted form (multiplied by 1) into BW.
Field only known in exit
You can enhance data by extending the extract structure for a DataSource using fields in append structures.
The indicator Field only known in Exit is set for fields of an append structure. In other words, by default these fields are not passed onto the extractor from the field list and selection table.
Deselect the indicator Field Only Known in Exit to enable the Service API to pass on the append structure field to the extractor together with the fields of the delivered extract structures in the field list as well as in the selection table.
9. Choose DataSource ® Generate.
The DataSource is now saved in the source system.
Maintaining Generic DataSources
Change the DataSource
To change a generic DataSource, in the initial screen of DataSource maintenance, enter the name of the DataSource and choose Change.
You can change the assignment of a DataSource to an application component as well as the texts of a DataSource. Double-clicking on the name of the table, view, InfoSet or extract structure takes you to the appropriate maintenance screen. Here you can make changes required to add new fields. You can fully swap transparent tables and database views, but not InfoSets. If you return to the DataSource maintenance and choose Create, the screen for editing a DataSource appears. To save the DataSource in the SAP source system, choose DataSource ® Generate.
If you want to test extraction in the source system independently of a BW system, choose DataSource ® Test Extraction.
Delta DataSource
In the Change Generic DataSource screen, you can delete any DataSources that are no longer relevant. If you are extracting data from an InfoSet, delete the associated query. If you want to delete a DataSource, this must not be connected to a BW system.
For more information about extracting using SAP Query, see Extraction using the SAP Query.
Plz assign points if helpful. This is the only way to say thanks.
And give me ur ID i send u some helpful documents...
Regards
Rakesh Jangir -
Help with SUN JNDI tutorial example
HI guys there's an example of how to bound an object along with its codebase in the sun jndi tutorial
import javax.naming.*;
import javax.naming.directory.*;
import java.util.Hashtable;
* Demonstrates how to bind a Serializable object to a directory
* with a codebase.
* (Use Unbind to remove binding.)
* usage: java SerObjWithCodebase <codebase URL>
class SerObjWithCodebase {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("usage: java SerObjWithCodebase <codebase URL>");
System.exit(-1);
String codebase = args[0];
// 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, "ldap://localhost:389/o=JNDITutorial");
try {
// Create the initial context
DirContext ctx = new InitialDirContext(env);
// Create object to be bound
Flower f = new Flower("rose", "pink");
// Perform bind and specify codebase
ctx.bind("cn=Flower", f, new BasicAttributes("javaCodebase", codebase));
// Check that it is bound
Flower f2 = (Flower)ctx.lookup("cn=Flower");
System.out.println(f2);
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
System.out.println("Operation failed: " + e);
So in therory you should be able to retrieve an object in through doing a look up, and then cast it... but in this approach the client that performs the look up shouldn't need to include the class definition of the object that is being retrieved, because it's being included in the code base of the context, but then how do you avoid compilation errors such:
SerObjWithCodebase.java:73: cannot resolve symbol
symbol : class Flower
location: class SerObjWithCodebase
Flower f2 = (Flower)ctx.lookup("cn=Flower");
in the client code that is attepting to perform the look up?... is there a work-around for this problem? please let me know, thanks in advance.As far as I am aware, there is no possible way to compile or execute code without the client knowing it's definition.
The client will always need the class definition if it want's to use it.
If you don't want this coupling, then you could look at using an EJB container (which still requires the client to have skeleton code) or using something like web services -
Help with running sun jndi tutorial example LookUp.class
I am learning JNDI,and when I run LookUp.java available in JNDI TUTORIAL ,souce code here:
* @(#)Lookup.java 1.3 99/08/12
* Copyright 1997, 1998, 1999 Sun Microsystems, Inc. All Rights
* Reserved.
* Sun grants you ("Licensee") a non-exclusive, royalty free,
* license to use, modify and redistribute this software in source and
* binary code form, provided that i) this copyright notice and license
* appear on all copies of the software; and ii) Licensee does not
* utilize the software in a manner which is disparaging to Sun.
* This software is provided "AS IS," without a warranty of any
* kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
* HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
* MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN
* NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
* CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT
* OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* This software is not designed or intended for use in on-line
* control of aircraft, air traffic, aircraft navigation or aircraft
* communications; or in the design, construction, operation or
* maintenance of any nuclear facility. Licensee represents and warrants
* that it will not use or redistribute the Software for such purposes.
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;
class Lookup {
public static void main(String[] args) {
// Check that user has supplied name of file to lookup
if (args.length != 1) {
System.err.println("usage: java Lookup <filename>");
System.exit(-1);
String name = args[0];
// Identify service provider to use
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
try {
// Create the initial context
Context ctx = new InitialContext(env);
// Look up an object
Object obj = ctx.lookup(name);
// Print it out
System.out.println(name + " is bound to: " + obj);
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
System.err.println("Problem looking up " + name + ": " + e);
after I compiled it sucessfully,I typed
java LookUp d:/test.java ,error message shown following:
Problem looking up LookUp.java: javax.naming.NoInitialContextException: Cannot i
nstantiate class: com.sun.jndi.fscontext.RefFSContextFactory [Root exception is
java.lang.ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory]
please help me!Read the Preparations chapter of the tutorial.
It tells you to download and install the file
system service provider from
http://java.sun.com/products/jndi/#download -
Synchronizer Token Pattern - Generic example
Hi
We have web applications not developped with struts or JSF, it's just a servlet/JSP design.
We have big troubles with multiple forms submitted at the login-form, so our intention it's to "protect" this page with the synchronizer token pattern.
Where i have to handle the request? In a filter? When do i put the token into the session and many more questions?
Do you hava me a concrete example of this pattern? Thanks very much!
Kind regards
MichaelThere is already a components - Shale Token [1] that helps you solve double submit issue. The wiki is here [2]. The component is in shale-core.jar which you can find in the sample apps [3]
[1] http://shale.apache.org/
[2] http://wiki.apache.org/shale/Token
[3] http://people.apache.org/builds/shale/nightly/ -
Do you know how to get Tomcat's JNDI example to work? - Help!
With regards to the example for JNDI Datasource How-To found on Apache's site at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
I did the example as they explained to. But I keep getting "foo - not connected" when I run the "test.jsp" page on my Tomcat server.
I made the following changes to the example
1) don't know if this bears any importance, but I've changed wherever it says "TestDB" to "DBTest"
2) I changed the portion in bold text in this parameter ---
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
</parameter>
in the server.xml file to localhost:8080 as this is my port # for the tomcat server.
3) they had the <value> attribute set to org.gjt.mm.mysql.Driver so I changed it to the following...was this incorrect for me to do?
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
Questions and noticeable problems
1) I'm getting a **END NESTED EXCEPTION ** Attempted reconnect 3 times. Giving up.
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1780)
at com.mysql.jdbc.Connection.<init>(Connection.java:427)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:395)
and the list continues (this is in the dos-prompt window that pops up after starting Tomcat). Unforntunately I'm unable to copy and paste it all into this forum. It also has lines similar to above relating to org.apache.commons.dbcp.DriverConnectionFactory etc.
2)What am I doing wrong? I really want to get this to work....I'm hoping to eventually learn and apply connection pooling to an application....
3) is there something somewhere that I'm not "configuring" properly?
Ask me for any information pertinent to this problem I'm having, and I'll try to post a reply with whatever is requested.
can anybody help me out??With regards to the example for JNDI Datasource How-To
found on Apache's site at
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-da
asource-examples-howto.html
I did the example as they explained to. But I keep
getting "foo - not connected" when I run the
"test.jsp" page on my Tomcat server.
I made the following changes to the
example
1) don't know if this bears any importance, but I've
changed wherever it says "TestDB" to "DBTest"This ought to reflect the name of the database you're connecting to in MySQL.
>
2) I changed the portion in bold text in this
parameter ---
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?auto
econnect=true</value>
</parameter>
in the server.xml file to localhost:8080 as
this is my port # for the tomcat server.No, the port number in this case should be the one that the database listener is attached to, not the Tomcat server. Think about what this is doing: it's setting up the database URL, not the Tomcat listener.
>
3) they had the <value> attribute set to
org.gjt.mm.mysql.Driver so I changed it to the
following...was this incorrect for me to do?
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>That looks like the name of the MySQL JDBC driver class.
>
Questions and noticeable problems
1) I'm getting a **END NESTED EXCEPTION **
Attempted reconnect 3 times. Giving up.
at
com.mysql.jdbc.Connection.createNewIO(Connection.java:1
80)
at
com.mysql.jdbc.Connection.<init>(Connection.java:427)
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegister
ngDriver.java:395)
and the list continues (this is in the dos-prompt
window that pops up after starting Tomcat).
Unforntunately I'm unable to copy and paste it all
into this forum. It also has lines similar to above
relating to
org.apache.commons.dbcp.DriverConnectionFactory etc.
2)What am I doing wrong? I really want to get this to
work....I'm hoping to eventually learn and apply
connection pooling to an application....
3) is there something somewhere that I'm not
"configuring" properly?
Ask me for any information pertinent to this problem
I'm having, and I'll try to post a reply with whatever
is requested.
can anybody help me out??Did you put the MySQL JDBC JARs in your WEB-INF/lib? How 'bout the database connection pool JAR?
This works. If it's not happening, that means you're doing something wrong. The good news is that you'll find it eventually if you keep digging. -
Hi ,
I am creating a POC for my project.Its using ATG and spring frameworks using RAD 6.first I have created ATG sample project in that same EAR file i created sample Spring project.Both are running in the same EAR.
I want to use spring classes from ATG components to use those methods.that is i should pass parameters to spring project methods and i should get the return value after executing those methods.
I heard that using JNDI look up I can get spring project class objects using that I can invoke spring project methods.
My requirement is two projects will be running in the same EAR.But one project will not be having information about other projects.both are independent from other.Using JNDI look up i need to invoke Spring project methods.
Please anyone help me how to do this.
I used java:comp/env/com/dao/EmpDAO to get instance of my class EmpDAO.But i am getting naming exception.Can anyone help me how to do this
Thanks in advance.If Tomcat is your servlet/JSP engine, they have a nice bit about how to do it:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
MOD -
How to use JNDI lookup from a JSP
Hello,
I know I should not be doing this (writing the lookup code in a JSP) but have to do it for some reasons.
I am using this code in my JSP:
try
Context ctx = new InitialContext();
dataSource = (DataSource)ctx.lookup("jdbc/mybillingora");
conn = dataSource.getConnection();
statement = conn.createStatement();
catch(Exception excep)
Is this code enough for a JNDI look up?? When I use this code, I get an exception:
"javax.naming.NameNotFound exception:jdbc/mybillingora"
Do I need to do something else??
Why do we use :
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"<some_context_factory>");
env.put(Context.PROVIDER_URL, PROVIDER_URL);
env.put(Context.SECURITY_PRINCIPAL, JNDI_USER);
env.put(Context.SECURITY_CREDENTIALS, JNDI_PWD);
InitialContext = new InitialDirContext(env);
where JNDI_USER is the userid If ACL is configured at the JNDI server
where JNDI_PWD is the password If ACL is configured at the JNDI server
Context.INITIAL_CONTEXT_FACTORY is the initial Context factory and depends on ur JNDI service provider.
PROVIDER_URL is the url of the JNDI server containing protocol/ip/port
do i need to use this??
would appreciate your help on this....
ThanksIf Tomcat is your servlet/JSP engine, they have a nice bit about how to do it:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
MOD -
Can not get ejb20\basic\beanManaged example work with Oracle?
This is the problem I encount when switch DB from Pointbase to Oracle. Most of the examples work when I with necessary change of configuration, DD and redeployment of applications except this one:
I follow all the steps for Oracle 9i DB. But keep getting the following errors. I don't understand why the system still lookups jdbc/demoPool even I modified DD and system configuration to jdbc/oraclePool (I validate it after successfully deployed to exampleServer).
The server is WLS 8.1 running on Windows XP professional.
ant runBuildfile: build.xml
run:
[java] Beginning beanManaged.Client...
[java] Creating account ID: 0 with a balance of 0.0...
[java] java.rmi.RemoteException: EJB Exception:; nested exception is:
[java] There was an exception while creating and using the Accounts.
[java] This indicates that there was a problem communicating with the serve
r: java.rmi.RemoteException: EJB Exception:; nested exception is:
[java] javax.ejb.EJBException: nested exception is: javax.naming.NameNo
tFoundException: While trying to look up comp/env/jdbc/demoPool in /app/ejb/ejb2
0_basic_beanManaged.jar#beanManaged.; remaining name 'comp/env/jdbc/demoPool'
[java] at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundR
equest.java:108)
[java] javax.ejb.EJBException: nested exception is: javax.naming.NameNo
tFoundException: While trying to look up comp/env/jdbc/demoPool in /app/ejb/ejb2
0_basic_beanManaged.jar#beanManaged.; remaining name 'comp/env/jdbc/demoPool'
[java] at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwar
eRemoteRef.java:284)
[java] at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwar
eRemoteRef.java:244)
[java] at examples.ejb20.basic.beanManaged.beanManaged_biy1g2_HomeImpl_
813_WLStub.create(Unknown Source)
[java] at examples.ejb20.basic.beanManaged.Client.createAccount(Client.
java:157)
[java] at examples.ejb20.basic.beanManaged.Client.example(Client.java:8
6)
[java] at examples.ejb20.basic.beanManaged.Client.main(Client.java:57)
[java] Caused by: javax.ejb.EJBException: nested exception is: javax.naming
.NameNotFoundException: While trying to look up comp/env/jdbc/demoPool in /app/e
jb/ejb20_basic_beanManaged.jar#beanManaged.; remaining name 'comp/env/jdbc/demoP
ool'
[java] at examples.ejb20.basic.beanManaged.AccountBean.getConnection(Ac
countBean.java:396)
[java] at examples.ejb20.basic.beanManaged.AccountBean.ejbCreate(Accoun
tBean.java:177)
[java] at examples.ejb20.basic.beanManaged.beanManaged_biy1g2_Impl.ejbC
reate(beanManaged_biy1g2_Impl.java:195)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at weblogic.ejb20.manager.DBManager.create(DBManager.java:1180)
[java] at weblogic.ejb20.manager.DBManager.remoteCreate(DBManager.java:
1129)
[java] at weblogic.ejb20.internal.EntityEJBHome.create(EntityEJBHome.ja
va:246)
[java] at examples.ejb20.basic.beanManaged.beanManaged_biy1g2_HomeImpl.
create(beanManaged_biy1g2_HomeImpl.java:76)
[java] at examples.ejb20.basic.beanManaged.beanManaged_biy1g2_HomeImpl_
WLSkel.invoke(Unknown Source)
[java] at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.ja
va:477)
[java] at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwar
eServerRef.java:108)
[java] at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.jav
a:420)
[java] at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Auth
enticatedSubject.java:363)
[java] at weblogic.security.service.SecurityManager.runAs(SecurityManag
er.java:144)
[java] at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServe
rRef.java:415)
[java] at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecut
eRequest.java:30)
[java] at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
[java] at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
[java] Exception in thread "main"
BUILD FAILED
attached are modified DD:
<?xml version="1.0"?>
<!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>
<enterprise-beans>
<entity>
<ejb-name>beanManaged</ejb-name>
<home>examples.ejb20.basic.beanManaged.AccountHome</home>
<remote>examples.ejb20.basic.beanManaged.Account</remote>
<ejb-class>examples.ejb20.basic.beanManaged.AccountBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<res-ref-name>jdbc/oraclePool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>beanManaged</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
<ejb-client-jar>ejb20_basic_beanManaged_client.jar</ejb-client-jar>
</ejb-jar>
and
<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN'
'http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>beanManaged</ejb-name>
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/oraclePool</res-ref-name>
<jndi-name>examples-dataSource-oracleXAPool</jndi-name>
</resource-description>
</reference-descriptor>
<jndi-name>ejb20-beanManaged-AccountHome</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
----------------------------------------------------There must be a reference to demoPool lurking around somewhere, I normally do a search inside all the files in the project to solve things like this.
Also clean up all temporary files and deployments before trying a redeploy.
If this does not work you can always try configuring the demoPool to use your oracle database, ugly, I know but it may help if your in a hurry to get your code working. -
Step by step example needed.
To generate documentation for all classes of project laing in the specified dir.
More detail is needed. -- which version of Javadoc are you using? Where are the package names (do they all start at the same top-level package)? Generic examples are given at:
http://java.sun.com/j2se/1.4/docs/tooldocs/solaris/javadoc.html#examples
-Doug -
Tomcat 5.0.* global JNDI database connect pooling. complex config question
Ok. I can't get global connection pooling to work in tomcat 5.0.24. (I am running windows xp pro)
I am using MySQL (installed on the same machine) and I have succesfully worked through the tutorial titled "MySQL DBCP Example" found at http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
This example does not demonstrate global connection pooling, however. I want to share a single connection pool across all my web applications. I don't want a different connection pool for each webapp.
So I define the connection pool JDBC resource in the conf/server.xml file under the <GlobalNamingResources> element.
Here is the entire <GlobalNamingResources> element lifted from conf/server.xml:
(Please overlook some of the formatting mistakes due to the <code> tag interpreting the xml as java.)
<!-- Global JNDI resources -->
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource name="UserDatabase"
auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<Resource name="jdbc/MySQL"
auth="Container"
type="javax.sql.DataSource"/>
<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>
<ResourceParams name="jdbc/MySQL">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>20000</value>
</parameter>
<parameter>
<name>username</name>
<value>webapp</value>
</parameter>
<parameter>
<name>password</name>
<value>******</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>3000</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>I am still trying to get the DBTest example (described in the link to the tomcat 5 docs above) to work, only now I want it to work using a global connection pool. So here is the contents of webapps/DBTest/WEB-INF/web.xml: (again, please overlook formatting difficulties :)
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/MySQL</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>The last thing I need to do, I think, is to include a <resourceLink> element in the context.xml file for this webapp. Now in tomcat 5.0.* it is not recommended that the <context> element appear in the conf/server.xml file. Instead, as I understand it, it should appear in either of the two following places (for a webapp called DBTest):
$CATALINA_HOME/conf/[engine_name]/[host_name]/DBTest.xml
$CATALINA_HOME/webapps/DBTest/META-INF/context.xmlSince I would eventually like to package each webapp in its own war file, I prefer the second option above. This will enable me to place the context.xml file within the .war file. Currently, however, I am not using .war files.
For the DBTest webapp I have the following <context> element in webapps/DBTest/META-INF/context.xml:
<context path="/DBTest" docBase="/DBTest" debug="1">
<ResourceLink global="jdbc/MySQL" name="jdbc/MySQL" type="javax.sql.DataSource" />
</context>Now, when I point my browser to http://localhost:8080/DBTest/test.jsp I get the following message:
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause: No suitable driver"
For those who are interested, here is test.jsp:
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<sql:query var="rs" dataSource="jdbc/MySQL">
select id, foo, bar from javatest.testdata
</sql:query>
<html>
<head>
<title>DB Test</title>
</head>
<body>
<h2>Results</h2>
<c:forEach var="row" items="${rs.rows}">
Foo ${row.foo}<br/>
Bar ${row.bar}<br/>
</c:forEach>
</body>
</html>Now I know that this is a very long and detailed question and that it is unlikely that anyone is even going to read down this far, let alone take the time to study all that XML, but if anyone is able to tell me why this setup does not allow global connection pooling, I will be pretty *@&$**% impressed. I only wish I had duke dollars to give.
JonOkay, I went back and double checked that I can get the DBTest example working. It is described here: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
I was not able to get it working exactly according to the tutorial, though. I was required to put the <context> element not in the conf/server.xml but in conf/Catalina/localhost/DBTest.xml. Then, with the DBTest/WEB-INF/web.xml as above, I was able to get the DBTest example working. The output of test.jsp (described above also) is the following:
Results
Foo hello
Bar 12345I would like to be able to put the <context> element in webapps/DBTest/META-INF/context.xml (as I think should be allowed) because then I would be able to include it in a war file that encompassed the entire web application. If I am forced to put the <context> element in a subdirectory of the conf directory, then I cannot include it in a war file and I will be unable to just drop my war files in the webapps directory and go. Instead I will have to drop my war files in the webapps directory, then go and fiddle around with the xml files in conf/Catalina/localhost/
But if I move the <context> element into webapps/DBTest/META-INF/context.xml then the example stops working. When I put it back in conf/Catalina/localhost/DBTest.xml everything is fine again.
Ok, no big deal. I guess my war file deployment will just have to be a little more complicated.
But what if I want the resource to be global??? If I remove the <Resource> and <ResourceParams> elements from the webapp-specific <context> element and put them in the <GlobalNamingResource> element in the conf/server.xml file I should have a global resource, right? I did this, then added a resource link to the <context> element (see above), however, the example stops working. I have tried both with and without the <resource-ref> element in web.xml.
Can some remarkably intelligent and knowledgeable person please explain to me how global resources work in tomcat 5.0, especially global JDBC connection pooling.
Thanks,
Jon -
Regarding database access through jndi
Hi All,
Plz tell me the steps.
I want to access data from MS Access, and i want to do it using JNDI .
what should be added in struts-config.xml, web.xml .
if any one have example code that will be better to understand.Nothing necessary added to struts-config.xml
What server are you using? The JNDI configuration for each server is slightly different.
The page for Tomcat is here: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
I would follow that apart from instead of editing server.xml, put the JNDI configuration in a "mycontext.xml" file as defined here:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/host.html#Automatic%20Application%20Deployment
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html
Cheers,
evnafets -
Examples of Add and Delete buttons in Forms
Hello, I have group project and we are having a hard time finding examples of how to add and delete records.
We have tried for the add:
INSERT INTO order_line VALUES
(:orders.o_id,
:order_line.inv_id,
:order_line.ol_quantity);
COMMIT;
And this for the Delete:
DELETE FROM order_line WHERE
o_id = :orders.o_id
AND inv_id = :order_line.inv_id;
COMMIT:
We are just looking for a generic example of how the code should look. Please ignore any errors I may have typed I copied it from a print off.Please ask this question in the Forms discussion area instead of the Database discussion area.
Thanks. -
could any of you helpful folks who have example code communicating with the dde server of another application please post some 'generic' example code here? (or any related tips) -6.0.2-
Thanks, Paul.SHave you looked here and at the Access DDE example that ships with LabVIEW?
Maybe you are looking for
-
Windows 8 Consumer Preview: AMD Switchable Graphics - Unswitchable
Hello everyone, I have a HP Pavillion dv6-6004tx notebook computer, and I recently upgraded it to the Windows 8 Consumer Preview (Build 8250). I would like some troubleshooting from those who have/are experiencing this and may have found a way around
-
How do I stop iTunes from automatically importing the songs I download?
I usually end up deleting a bunch of songs, but iTunes is automatically importing/adding the songs I download which then creates a lot of missing file links. How do I stop iTunes from doing that, I just want to be able to add them manually by folders
-
I want to import bookmarks from Explorer and I go to File Tab and the IMPORT link is not working or not illuminated?
-
Changing column name in Line chart
Hello All, We are BO 4.0 SP6. We are creating WEBI reports which includes charts as well. We have two columns " Current Period" and "Last Period" and using them in WEBI report and Line chart. In the table I am displaying the column name " Current per
-
New MacBook Pro, late 2013, specs
How much usable disk space remains on 15"/8gb/256 gb Flash Macbook Pro as delivered? I'm not sure I need the 512 gb flash memory version but would like to know what I'm working with after Apple installs their system and apps. Thanks.