Using Datasources with Weblogic 7.2
Hi everyone,
I am using Weblogic 7.2 with Db2 8.1 fp3(Type 4 Drivers). I am wanting
to set up a Datasource that would allow my application to connect to
DB2 using the JNDI lookup for that data-source.
My question is: what additions/changes I need to make to config.xml in
order to set this up.Looking at the Websphere Admin Doc, it seems to
me that I need to atleast add 2 elements to my domain in config.xml:
1. JDBCConnectionPool
2. JDBCDataSource(and link it to the above pool)
I have previously set-up datasources on WAS 5.0. What is confusing me
w.r.t Weblogic is that there seems to be no way to specify the
implementing class for the DataSource. e.g. WAS5.0 allows you to
specify the implementationClassName of the
datasource(com.ibm.db2.jcc.DB2ConnectionPoolDataSource in my case) while
defining the DataSource.JDBCConnectionPool element in Weblogic does
have an attribute called "DriverName" but per the documentation it
should be set to an implementor of java.sql.Driver interface: there
seems to be no way to set an implementor of javax.sql.DataSource
anywhere.
Could anyone please shed some light on how to set this up?
Thanks much in advance,
Sachin
Mitesh,
Many thanks for the reply. If you don't mind, I have a couple of follow-up questions
for you.
1> Does this mechanism work with Type 4 Pure Java Drivers?
e.g. if I specified the connection pool as
<JDBCConnectionPool DriverName="com.ibm.db2.jcc.DB2ConnectionPoolDataSource" Name="IBM-db2"
Password="MYPASSWORD" Properties="user=USERNAME;DatabaseName=DATABASE" Targets="MYSERVER"
TestTableName="SQL SELECT COUNT(*) FROM SYSIBM.SYSTABLES" URL="jdbc:db2:DATABASE"/>
==> I changed the DriverName to "com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
which
is what I believe is the Type-4 version
2> Setting the DriverName to a javax.sql.DataSource extension seems to suggest
that the documentation in the "BEA Server Configuration Reference" guide is incorrect:
-- For the DriverName attribute of the Connection Pool, the guide says that "DriverName
must be the name of a class that implements the java.sql.Driver interface"
Thanks again
Sachin
Mitesh Patel <[email protected]> wrote:
<JDBCConnectionPool DriverName="COM.IBM.db2.jdbc.DB2XADataSource"
Name="IBM-db2-xa"
Password="MYPASSWORD"
Properties="user=USERNAME;DatabaseName=DATABASE"
Targets="MYSERVER"
TestTableName="SQL SELECT COUNT(*) FROM SYSIBM.SYSTABLES"
URL="jdbc:db2:DATABASE"/>
<JDBCConnectionPool DriverName="COM.IBM.db2.jdbc.app.DB2Driver"
Name="IBM-db2"
Password="MYPASSWORD"
Properties="user=USERNAME;DatabaseName=DATABASE"
Targets="MYSERVER"
TestTableName="SQL SELECT COUNT(*) FROM SYSIBM.SYSTABLES"
URL="jdbc:db2:DATABASE"/>
Then setup your datasource using one of this connection pools in your
config.xml. Also, make sure your driver zip files are in the classpath.
Thanks,
Mitesh
Sachin Arora wrote:
Hi everyone,
I am using Weblogic 7.2 with Db2 8.1 fp3(Type 4 Drivers). I am wanting
to set up a Datasource that would allow my application to connect to
DB2 using the JNDI lookup for that data-source.
My question is: what additions/changes I need to make to config.xmlin
order to set this up.Looking at the Websphere Admin Doc, it seems to
me that I need to atleast add 2 elements to my domain in config.xml:
1. JDBCConnectionPool
2. JDBCDataSource(and link it to the above pool)
I have previously set-up datasources on WAS 5.0. What is confusingme
w.r.t Weblogic is that there seems to be no way to specify the
implementing class for the DataSource. e.g. WAS5.0 allows you to
specify the implementationClassName of the
datasource(com.ibm.db2.jcc.DB2ConnectionPoolDataSource in my case)while
defining the DataSource.JDBCConnectionPool element in Weblogic does
have an attribute called "DriverName" but per the documentation it
should be set to an implementor of java.sql.Driver interface: there
seems to be no way to set an implementor of javax.sql.DataSource
anywhere.
Could anyone please shed some light on how to set this up?
Thanks much in advance,
Sachin
Similar Messages
-
Has anyone used JAAS with WebLogic?
Has anyone used JAAS with Weblogic? I was looking at their example, and I have a bunch of questions about it. Here goes:
Basically the problem is this: the plug-in LoginModule model of JAAS used in WebLogic (with EJB Servers) seems to allow clients to falsely authenticate.
Let me give you a little background on what brought me to this. You can find the WebLogic JAAS example (to which I refer below) in the pdf: http://e-docs.bea.com/wls/docs61/pdf/security.pdf . (I believe you want pages 64-74) WebLogic, I believe goes about this all wrong. They allow the client to use their own LoginModules, as well as CallBackHandlers. This is dangerous, as it allows them to get a reference (in the module) to the LoginContext's Subject and authenticate themselves (i.e. associate a Principal with the subject). As we know from JAAS, the way AccessController checks permissions is by looking at the Principal in the Subject and seeing if that Principal is granted the permission in the "policy" file (or by checking with the Policy class). What it does NOT do, is see if that Subject
has the right to hold that Principal. Rather, it assumes the Subject is authenticated.
So a user who is allowed to use their own Module (as WebLogic's example shows) could do something like:
//THEIR LOGIN MODULE (SOME CODE CUT-OUT FOR BREVITY)
public class BasicModule implements LoginModule
private NameCallback strName;
private PasswordCallback strPass;
private CallbackHandler myCB;
private Subject subj;
//INITIALIZE THIS MODULE
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
try
//SET SUBJECT
subj = subject; //NOTE: THIS GIVES YOU REFERENCE
TO LOGIN CONTEXT'S SUBJECT
// AND ALLOWS YOU TO PASS
IT BACK TO THE LOGIN CONTEXT
//SET CALLBACKHANDLERS
strName = new NameCallback("Your Name: ");
strPass = new PasswordCallback("Password:", false);
Callback[] cb = { strName, strPass };
//HANDLE THE CALLBACKS
callbackHandler.handle(cb);
} catch (Exception e) { System.out.println(e); }
//LOG THE USER IN
public boolean login() throws LoginException
//TEST TO SEE IF SUBJECT HOLDS ANYTHING YET
System.out.println( "PRIOR TO AUTHENTICATION, SUBJECT HOLDS: " +
subj.getPrincipals().size() + " Principals");
//SUBJECT AUTHENTICATED - BECAUSE SUBJECT NOW HOLDS THE PRINCIPAL
MyPrincipal m = new MyPrincipal("Admin");
subj.getPrincipals().add(m);
return true;
public boolean commit() throws LoginException
return true;
}(Sorry for all that code)
I tested the above code, and it fully associates the Subject (and its principal) with the LoginContext. So my question is, where in the process (and code) can we put the LoginContext and Modules so that a client cannot
do this? With the above example, there is no Security. (a call to: myLoginContext.getSubject().doAs(...) will work)
I think the key here is to understand JAAS's plug-in security model to mean:
(Below are my words)
The point of JAAS is to allow an application to use different ways of authenticating without changing the application's code, but NOT to allow the user to authenticate however they want.
In WebLogic's example, they unfortunately seem to have used the latter understanding, i.e. "allow the user to authenticate however they want."
That, as I think I've shown, is not security. So how do we solve this? We need to put JAAS on the server side (with no direct JAAS client-side), and that includes the LoginModules as well as LoginContext. So for an EJB Server this means that the same internal permission
checking code can be used regardless of whether a client connects through
RMI/RMI-IIOP/JEREMIE (etc). It does NOT mean that the client gets to choose
how they authenticate (except by choosing YOUR set ways).
Before we even deal with a serialized subject, we need to see how JAAS can
even be used on the back-end of an RMI (RMI-IIOP/JEREMIE) application.
I think what needs to be done, is the client needs to have the stubs for our
LoginModule, LoginContext, CallBackHandler, CallBacks. Then they can put
their info into those, and everything is handled server-side. So they may
not even need to send a Subject across anyways (but they may want to as
well).
Please let me know if anyone sees this problem too, or if I am just completely
off track with this one. I think figuring out how to do JAAS as though
everything were local, and then putting RMI (or whatever) on top is the
first thing to tackle.Send this to:
newsgroups.bea.com / security-group. -
How to use ADF with weblogic Portal 10.3.2
Hello All,
I want to use ADF with Weblogic Portal 10.3.2. Can anyone guide me ?
Thanks,
*(' ')sman*Hello,
To use ADF with WLP 10.3.2 you will need a WebCenter WSRP producer running the portlet, which you can then consume as a remote portlet in WLP. The documentation on how to do that is here:
http://download.oracle.com/docs/cd/E15919_01/wlp.1032/e14235/chap_webcenter_interop.htm#BABDBJBD
Kevin -
Using Flexlm with Weblogic 8.1
Hi all,
I am using Flexlm utility to get my license up for my web application on Weblogic 8.1 but its throwing the exception.
Is there any configuration issues in using Flexlm with Weblogic?
I will appreciate any help. Thanks.
The exact stack trace is
at com.macrovision.flexlm.lictext.PriKey.pubkeyVerify(PriKey.java:115)
at com.macrovision.flexlm.lictext.LicenseElement.doAuthenticate(LicenseElement.java:459)
at com.macrovision.flexlm.lictext.FeatureLine.authenticate(FeatureLine.java:85)
at com.macrovision.flexlm.lictext.LicenseCertificate.authenticateList(LicenseCertificate.java:206)
at com.macrovision.flexlm.lictext.LicenseCertificate.authenticate(LicenseCertificate.java:188)
at com.macrovision.flexlm.lictext.LicenseGroup.getCertificateData(LicenseGroup.java:198)
at com.macrovision.flexlm.lictext.LicenseGroup.<init>(LicenseGroup.java:106)
at com.macrovision.flexlm.licsource.LicenseFile.<init>(LicenseFile.java:78)
at com.macrovision.flexlm.LicenseSource.createLicenseSource(LicenseSource.java:128)
at com.macrovision.flexlm.License.<init>(License.java:216)
atthere is a thin driver problem when inserting a blob greater than 4k in oracle. this worked fo me:
// thing i want to store
Object myObject = new Object();
String SQL = "UPDATE mytableSET blobcolumn= ? "
+ "WHERE id= ? ";
String SQL2 ="SELECT blobcolumn FROM mytable "
+ "WHERE id= ? ";
try
// create an empty_lob
BLOB myBlob = BLOB.empty_lob();
statement = conn.prepareStatement(SQL);
statement.setBlob(1, myBlob);
statement.setBigDecimal(2, id);
// update with the empty_lob
result = statement.executeUpdate();
if(result == 1)
// get the blob back
statement = conn.prepareStatement(SQL2);
statement.setBigDecimal(1, id);
results = statement.executeQuery();
if(results.next())
// write the new value
myBlob = (BLOB)results.getBlob(1);
OutputStream w = myBlob.getBinaryOutputStream();
w.write(myObject);
w.flush();
} -
Hi,
I would like to know if anybody has used iFS with weblogic before. If so could you please share the information like how to make it work. I would like to know the classpath settings etc...
Any help will be greatly appreciated.while i don't work for Oracle, i would suggest this is not a supported configuration. ;)
having said that, it should be easy enough to accomplish. just make sure your classpath (better yet, your WAR or EAR file) includes the required runtime iFS jars (repos.jar, adk.jar, utils.jar and email.jar), and then use JDBC to get iFS service configuration information. (See my response to Satya in the "custom JSP in OC4J" thread.)
that should work just fine.
.rich -
Error while using TXDataSource with Weblogic 6.1 & Oracle 8.1.6
Hi,
I am using Weblogic 6.1 and Oracle 8.1.6.
I have configured JDBC XA Connection Pool with Oracle thin driver. These are my settings...
Connection Pool:
Name - myXAPool
URL - jdbc:oracle:thin:@myServer:1521:myDb
DriverClassname - oracle.jdbc.xa.client.OracleXADataSource
TXDataSource:
Name - myXADS
JNDIName - myXADS
PoolName - myXAPool
I get the following error when I try to lookup the datasource. I am not sure where the problem is as I have configured Connection Pool and TXDataSource as mentioned in the documentation.
java.sql.SQLException: XA error: XAER_RMERR : A resource manager error has occured in the transaction branch start() failed on resource 'myXAPool' Unexpected error during start for XAResource 'myXAPool': null
It would be really great if you can help me out.
Thanks in Advance,
Sudhir.Hi Sudhir,
If you do not know if upgrade or not, have a look here :
http://e-docs.bea.com/wls/docs61/notes/bugfixes2.html
Note that at the end of June SP3 will be released...
Sergi
"Sudhir Babu" <[email protected]> wrote:
>
Hi Sergi,
Thanks a lot for the class file, I figured out what the problem was. Actually
the
database version I was working with was 8.0.6.0. The Oracle driver doesn't
work with
this but the JDriver worked. This is the output of running CheckDriver..
DatabaseProductName : Oracle
DatabaseProductVersion : Oracle8 Enterprise Edition Release 8.0.6.0.0 -
Production
With the Partitioning and Objects options
PL/SQL Release 8.0.6.0.0 - Production
DriverName : Oracle JDBC driver
DriverVersion : 8.1.7.1.0
Then I tried on using the Oracle Driver on another instance which has the
version
8.1.7.1.0 and it worked. The JDriver and Oracle driver both work with this
database.
The output of CheckDriver for this Oracle instance is..
DatabaseProductName : Oracle
DatabaseProductVersion : Oracle8i Enterprise Edition Release 8.1.7.1.0 -
Production
With the Partitioning option
JServer Release 8.1.7.1.0 - Production
DriverName : Oracle JDBC driver
DriverVersion : 8.1.7.0.0
By the way I am working on WLS 6.1 SP1. What is the advantage of SP2 ? Should
I upgrade
Thanks once again,
Sudhir.
"Sergi Vaz" <[email protected]> wrote:
Hi Sudhir ,
JDriver works well, you can work with it.
Just for curiosity, can you run the class I attached using the "exact"classpath
of your WL instance (with Oracle drivers in front of weblogic.jar) ? What
is the
output ?
On which platform are you running your WLSP2 ?
Thanks
Sergi
"Sudhir Babu" <[email protected]> wrote:
Hi Sergi,
I just checked the things you mentioned. The connection pool starts correctly
without
any errors. I also made sure SELECT previlege was granted to DBA_PENDING_TRANSACTIONS.
I do have the JAVA_XA package installed and it has EXECUTE permission
to
PUBLIC.
I actually tried using the Weblogic JDriver (weblogic.jdbc.oci.xa.XADataSource)
and
it works perfect without any issue. The only consideration is that itis
a Type 2
Driver and needs to have the Oracle Client installed. But right now Ido
have it
installed on the same machine.
Do you know any known issues with Weblogic JDriver. Do you think it'sa
good idea
to go with it ?
Thanks,
Sudhir.
"Sergi Vaz" <[email protected]> wrote:
Hi Sudhir,
does your connection pool start correctly ?
Check the setup of your Oracle server too:
1) grant select on DBA_PENDING_TRANSACTIONS table to PUBLIC
2) package JAVA_XA installed (with grant execute to PUBLIC)
Sergi
"Sudhir Babu" <[email protected]> wrote:
Hi Sergi,
Thanks for the response. I downloaded the driver for 8.1.7 from Oraclesite
and put
it in classpath in front of weblogic.jar. I still get the same problem.
Is there
another location where we can download the Oracle driver with the bug
fixed
Regards, Sudhir.
"Sergi Vaz" <[email protected]> wrote:
Hi Sudhir,
I think you are using Oracle JDBC drivers 8.1.6.
They have a bug, they do not accept a foreign XID.
Use 8.1.7 or higher to solve this problem.
Sergi
Sudhir Babu <[email protected]> wrote:
Hi,
I am using Weblogic 6.1 and Oracle 8.1.6.
I have configured JDBC XA Connection Pool with Oracle thin driver.
These
are my settings...
Connection Pool:
Name - myXAPool
URL - jdbc:oracle:thin:@myServer:1521:myDb
DriverClassname - oracle.jdbc.xa.client.OracleXADataSource
TXDataSource:
Name - myXADS
JNDIName - myXADS
PoolName - myXAPool
I get the following error when I try to lookup the datasource. I amnot
sure where the problem is as I have configured Connection Pool and
TXDataSource
as mentioned in the documentation.
java.sql.SQLException: XA error: XAER_RMERR : A resource manager errorhas
occured in the transaction branch start() failed on resource 'myXAPool'
Unexpected error during start for XAResource 'myXAPool': null
It would be really great if you can help me out.
Thanks in Advance,
Sudhir. -
Connecting to TimesTen using DataSource in WebLogic on Linux
We are trying to use weblogic 9.2 to connect to TimesTen7.0, both are on Linux.
We have installed Oracle 10g client and then installed TimesTen 7.0 Client on the Linux server hosting weblogic.
Created Client DSN in /var/TimesTen/sys.odbc.ini file as follows:
[ODBC Data Sources]
TTclientMaster=TimesTen 7.0 Client Driver
[TTclientMaster]
TTC_SERVER="TTServerHostName"
TTC_SERVER_DSN=TTmaster
When we are trying to create DataSource in weblogic Admin console it does not show up TTClient Driver in the list.
We tried setting up using "Others" for driver and databasetype but then it asks for databasename which we don't have since TT uses DSN.
We are looking for any pointers or references that can explain how to configure weblogic to use TimesTen using TT 7.0 client DSN.If you have access to a copy of TimesTen 6.0 you can look in the AppServer Configuration Guide (appsrv.pdf) that was shipped with that release. This guide is currently being rewritten and so is not yet available for 7.0.
If you can't get hold of a copy, e-mail me at [email protected] and I'll send it to you.
Chris -
Hi,
I am using toplink 10.1.3 .We are using the datasource to connect to weblogic connection pool.
My session.xml is like this:
- <login xsi:type="database-login">
<platform-class>oracle.toplink.platform.database.oracle.Oracle10Platform</platform-class>
<user-name />
<datasource>jdbc/ds</datasource>
</login>
In the java DAO part,I need a physical database connection to get the ArrayDescriptor.The part of java code is below
java.sql.Connection dbconnection=null;
DatabaseLogin login = serverSession.getLogin();
dbconnection=(java.sql.Connection)login.connectToDatasource(null);
Questions:
1.Is the above correct way to get the Physical JDBC connection from a weblogic connection pool(configured using datasource).
2.How will the Connection released to the pool?Should i use dbconnection.close() or clientSession.release().
ThanksThanks doug for your reply.
I am using datasource to connect to the weblogic 9.2 connection pool.
My specific use case is this.
I am executing a Stored procedure which will takes a Oracle user defined data type as an Input paramater.
some steps we use in the java code for the above use case.
--Getting the toplink session
ServerSession serverSession = TopLinkGenericDAO.getSession();
clientSession = serverSession.acquireClientSession();
--For getting the oracle user defined array
java.sql.Connection dbconnection=null;
DatabaseLogin login = serverSession.getLogin();
dbconnection=(java.sql.Connection)login.connectToDatasource(null);
oracle.sql.ArrayDescriptor descriptor = new oracle.sql.ArrayDescriptor(
"STRING_ARRAY", dbconnection);
oracle.sql.ARRAY arr_ORCL = new oracle.sql.ARRAY(descriptor,
dbconnection, aIncl_Vin);
--for executing stored procedure
StoredProcedureCall call = new StoredProcedureCall();
DataReadQuery dbquery = new DataReadQuery();
call.setProcedureName(CVeITDAOConstants.INSERT_PING);
call.addNamedArgumentValue("para1", arr_ORCL );
dbquery.setCall(call);
--release connection in the finally block
finally
clientSession.release();
dbconnection.close();
The above code fails when we execute it for 150 concurrent connection(using JMeter) with connection fail exception.
Please let me know how do i release the physical jdbc connection(dbconnection) in the finally block.
do we need to give dbconnection.close() or just by giving clientSession.release() will also release the jdbc connection.
Thanks. -
Problem in Using Log4J with Weblogic 9.2
I am using Weblogic 9.2 and Log4j.
By using Admin console I set the Severity Level to WARNING and inside my java code is given below:
Logger logger = Log4jLoggingHelper.getLog4jServerLogger();
if (logger.isEnabledFor(Priority.DEBUG)){
logger.debug("DEBUG - Test Debug message");
logger.info("DEBUG - Test Info Message");
logger.warn("DEBUG - Test Warning Message");
logger.error("DEBUG - Test Error Message");
logger.fatal("DEBUG - Test Fatal Message");
Somehow the logger.isEnabledFor(Priority.DEBUG) returning 'TRUE' and the follwoing message is displayed.
<Nov 29, 2006 2:44:04 PM EST> <Warning> org.apache.log4j.Category> <000000> <DEBUG - Test Warning Message>
<Nov 29, 2006 2:44:04 PM EST> <Error> <org.apache.log4j.Category> <000000> <DEBUG - Test Error Message>
<Nov 29, 2006 2:44:04 PM EST> <Info> <org.apache.log4j.Category> <000000> <DEBUG - Test Fatal Message>
<b><i>NOTE - The logger.debug() and logger.info() methods are not invoked because of the severity level to 'WARNING' in the console.</i></b>
<b>I would like to know why the Somehow the logger.isEnabledFor(Priority.DEBUG) is having a value of 'TRUE'.</b>
I expected only the Somehow the logger.isEnabledFor(Priority.ERROR) will have the value of 'TRUE'.Did you get an answer to your question? I have the same problem with WebLogic 10.0.
-
Using DataSource with MS Access
is it possible to use the JDBC DataSource with MS Access? Should I download some .class to register with JNDI?
I've done it with Tomcat, but I've never tried to do it outside of a container. You sound like you want to do it without a servlet or J2EE app server engine acting as the lookup and pool. - MOD
-
Using p3p with Weblogic/CSS
I am trying to use p3p policy and compact privacy policy.
We have Weblogic as App server and a hardware CSS to maintain session on weblogic
clusters.
The browser on client end is accpeting cookie, but I dont see the actual cookie
being placed.
The cookie contains session info and is used by CSS to maintain sticky to the
same managed server.
Am sending cpmpact policy using Meta tag in my JSPs
ANyone had similiar problem.Hi.
Hmm, since WLS execute threads never die, I don't know that your threadlocal variables
will get cleaned up or gc'd until the server is shutdown.
Regards,
Michael
Kumar Ampani wrote:
> With weblogic thread pooling, When I use threadlocal variables in my application,
> how does it work as far as cleaning those variables after the request is completed.
>
> Thanks in advance.
Michael Young
Developer Relations Engineer
BEA Support
-
Using ThreadLocal with WebLogic App Server
With weblogic thread pooling, When I use threadlocal variables in my application,
how does it work as far as cleaning those variables after the request is completed.
Thanks in advance.
Hi.
Hmm, since WLS execute threads never die, I don't know that your threadlocal variables
will get cleaned up or gc'd until the server is shutdown.
Regards,
Michael
Kumar Ampani wrote:
> With weblogic thread pooling, When I use threadlocal variables in my application,
> how does it work as far as cleaning those variables after the request is completed.
>
> Thanks in advance.
Michael Young
Developer Relations Engineer
BEA Support
-
Use DataSource of weblogic in a standalone Java file
Hi,
We have a requirement to run a java file at a scheduled time in a day using cron scheduler on our linux server.
We need to fetch data from the database & perform some business logic in this standalone JAVA file.
Our application has an EAR which is deployed on Weblogic 10.3 server & in our application, we are utilizing the datasource created in that domain using Hibernate.
Now, can we create a standealone Java file & use exisitng datasource (without Hibernate) instead of legacy JDBC code to connect to DB.
Also, do we need to keep this JAVA file a part of this EAR, WAR or can we put the class file in anylocation outside this EAR & then utilize datasource feature.
Please help on the same in implementation.
Thanks,
UttamHi Ravi,
I did create Datasource domain & put wlclient.jar in my application classpath (Add jar in Java Build path of application), but, when I ran application, its giving below error
Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/kernel/KernelStatus
at weblogic.jndi.Environment.<clinit>(Environment.java:78)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:198)
at TestDataSource.main(TestDataSource.java:37)
Also, I'm putting code here as I there is no provision to attach the file here. Please let me know whats wrong here.
Also, I've given the name of datasource as testDataSource through Admin console of the domain. Do we need to prefix the name with jdbc/ in the code or without that also it works?
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class TestDataSource {
public static void main(String[] args)
DataSource ds=null;
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
Context ctx=null;
try
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://172.19.244.180:7001");
System.out.println("HERE");
ctx=new InitialContext(ht);
ds=(DataSource)ctx.lookup("jdbc/testDataSource");
System.out.println("HERE AFER CONTEXT CREATION");
conn=ds.getConnection();
stmt=conn.createStatement();
rs=stmt.executeQuery("select distinct(circle) from AIRCEL_STORE_FINDER order by 1 ");
while (rs.next())
System.out.println("circle name "+rs.getString(1));
}catch (Exception e) {
System.out.println("Error in Main "+e.toString());
e.printStackTrace();
finally{
try{
if(rs!=null)
rs.close();
if(stmt!=null)
stmt.close();
if(conn!=null)
conn.close();
if(ds!=null)
ds=null;
if(ctx!=null)
ctx.close();
}catch (SQLException e) {
System.out.println("Error in SQLException Finally "+e.toString());
catch (NamingException e) {
System.out.println("Error in NamingException Finally "+e.toString());
} -
Using datasource with streaming api inside a web service
I am using the 9.1 server and accessing a datasource
created with aldsp3.0. When I run the code below as a
standalone java app, everything works fine. When I run it
on the server, I get a class cast exception when trying to cast an object returned from the stream to MyData type.
When running the java app in the debugger, the objects
dataServiceDoc, dog , and dObj all have
the correct type. When running the web service in the debugger, the objects are all of type
DataObjectGeneral, thus causing the cast error.
<p><p>
Any help will be greatly appreciated!
<p>
Thanks.
<p><p>
package services;
<p>
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import weblogic.jndi.Environment;
import com.bea.dsp.RequestConfig;
import com.bea.dsp.das.DASResult;
import com.bea.dsp.das.DataAccessServiceFactory;
import com.bea.dsp.das.PreparedExpression;
import com.bea.sdo.impl.data.DataObjectGeneral;
import commonj.sdo.DataObject;
<p>
@WebService
<p>
public class MyService
<p>
private final static String DS_URL = "t3://localhost:7001";
<p>
@WebMethod
<p>
public String testMethod2()
<p>
StringBuilder result = new StringBuilder();
<p>
try
<p>
// Get the initial context to the WebLogic Server passing in user credentials
<p>
Context ctx = getInitialContext(DS_URL,"weblogic", "weblogic");
<p>
RequestConfig reqConfig = new RequestConfig();
<p>
reqConfig.enableFeature(RequestConfig.RETURN_DATA_SERVICE_AUDIT);
<p>
reqConfig.enableFeature(RequestConfig.RETURN_AUDIT_PROPERTIES);
<p>
reqConfig.setStringArrayAttribute(RequestConfig.RETURN_AUDIT_PROPERTIES,
new String[] { "common", "query" });;
<p>
String dspDataSpace = "MY_DS";
<p>
String adhoc = createQuery();
<p>
PreparedExpression pe = DataAccessServiceFactory.prepareExpression(ctx, dspDataSpace, adhoc);
<p>
DASResult<Object> dasResult = pe.executeQuery(reqConfig);
<p>
int i = 0;
<p>
int N = 100;
<p>
Long[] ids = new Long[N];
<p>
while (dasResult.hasNext() && i<N)
<p>
Object dataServiceDoc = dasResult.next();
<p>
// Convert Object to a Data Object
<p>
DataObjectGeneral dog = (DataObjectGeneral) dataServiceDoc;
<p>
DataObject dObj = dog.getRootObject();
<p>
// Cast the Data Object to the SDO Type (MyDataType)
<p>
MyDataType p = (MyDataType) dObj;
<p>
i++;
<p>
<p>
catch (Exception e)
<p>
result.append(e);
<p>
<p>
return result.toString();
<p>
<p>
private static InitialContext getInitialContext(String url, String username, String password) throws NamingException
<p>
Environment env = new Environment();
<p>
env.setProviderUrl(url);
<p>
env.setInitialContextFactory("weblogic.jndi.WLInitialContextFactory");
<p>
env.setSecurityPrincipal(username);
<p>
env.setSecurityCredentials(password);
<p>
return new InitialContext(env.getInitialContext().getEnvironment());
<p>
<p>
public static void main(String [] args)
<p>
MyService ms = new MyService();
<p>
System.out.println(ms.testMethod2());
<p>
<p>
<p>test
-
Using JNI with weblogic JSP & Servlets
I want to use native libraries from JSP and Servlets.
Everything works fine befire redeploying.
After redeploying there is an error:
Servlet failed with Exception
java.lang.UnsatisfiedLinkError: Native Library D:\WINNT\system32\XXXX.dll
already loaded in another classloader
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1346)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
at java.lang.Runtime.loadLibrary0(Runtime.java:749)
at java.lang.System.loadLibrary(System.java:820)
at HelloWorld.<clinit>(HelloWorld.java:9)
at NativeTestServlet.doGet(NativeTestServlet.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:208)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1127)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1529)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
Can anybody solve it?
Best wishes, Oleg.
Java will not allow us to reload any class that is dependent on a native
library. I suggest that any classes that depend on native code should be
put in the system classpath. If you change these classes or the native
library you will need to restart your server.
Sam
"Jennifer Yin" <[email protected]> wrote in message
news:[email protected]...
> Oleg-
>
> I'm having the exact same problem and was wondering how you fixed it. I
ran
> javah -jni <classname> to verify the correct method call and have also
verified
> that the library file is included in the system path.
>
> Any other suggestions?
>
> Jennifer
>
> Oleg wrote:
>
> > I want to use native libraries from JSP and Servlets.
> > Everything works fine befire redeploying.
> > After redeploying there is an error:
> >
> > Servlet failed with Exception
> > java.lang.UnsatisfiedLinkError: Native Library
D:\WINNT\system32\XXXX.dll
> > already loaded in another classloader
> > at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1346)
> > at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
> > at java.lang.Runtime.loadLibrary0(Runtime.java:749)
> > at java.lang.System.loadLibrary(System.java:820)
> > at HelloWorld.<clinit>(HelloWorld.java:9)
> > at NativeTestServlet.doGet(NativeTestServlet.java:31)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > at
> >
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> > :208)
> > at
> >
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
> > ntext.java:1127)
> > at
> >
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
> > :1529)
> > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
> > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> > >
> >
> > Can anybody solve it?
> >
> > Best wishes, Oleg.
>
Maybe you are looking for
-
Procurement load fails with socket error in biapps 11.1.1.7.1
Hi friends, While performing a procurement load via CM, my load is getting failed with one of the mapping SDE_ORA_RequisitionlinescostFact and below is the error that is occurring. Failed child steps: SDE_ORA_REQUISITIONLINESCOSTFACT (InternalID:17
-
Role comparision in ECC 6.0
Hi, facing issues with role comparison in SUIM in ECC 6.0 did cross system ( DEV - PRD) comparison of role. if any authorization object is missing, it will show red signal, yellow if diffeent values of the field now problem is when i drill down furth
-
I cannot open my firefox 24 at all
Every time I click the Firefox icon or I try to start it, nothing happened. I already uninstall and re install back but still the same problem occurred. Crash ID : bp-34f211fc-3947-4e8b-96cf-b700c2131005. bp-37c0702f-61fe-4443-baf5-9711a2131004. bp-4
-
How to call Absence start date in absence Dff in SSHR.
How to call Absence start date in absence Dff in SSHR.
-
Encore 2.0 switches on windows transition effect XPSP2
Why does encore switch on the animation of windows and menus when it starts? I like to have all of the visual "enhancements" of XP turned off, and it's annoying that encore turns it back on.