Getting Class instance of a class
Dear Friends,
I need to get Class instance of a class in my project. Inorder to use the reflection API 's the package name of the class is needed , but it may not be available Only available thing is the name of the class file and the location where that file is existing .
Please suggest some method to get Class instance in this situation.
Shaiju.P
You can create a ClassLoader of your own. There's a simplified example in this thread (reply number 6):
http://forum.java.sun.com/thread.jsp?thread=538836&forum=31
Similar Messages
-
Get class Instance, and then get hers attributes
Hi Gurus,
i'm new to ABAP Object,
creating an a BSP whit MVC controller i've try to implement the class controller,
but on a method of it i want to get instance of the class parents:
the class that i implement is an extension of CL_BSP_CONTROLLER2.
In this class in the method DO_REQUEST ( for example ) i try to get the instance of the class
parent ( and i got it! ) using this syntax:
data: Parent type ref to IF_BSP_DISPATCHER, " type take from attribute M_PARENT of the class
Parent = ME->M_PARENT.
In debug i see that 'Parent' get rightly the class parent instance but than i want do this:
(i want get the sub controller of the main contoller 'parent', in debug i can see everything fine)
SubController = Parent->GET_ATTRIBUTE(LEFT_CONTROLLER).
But the compiler say that the class instance 'Parent' has no methods and no attribute.
i've try other syntax like:
call METHOD Parent_>GET_ATTRIBUTE
IMPORTING
LEFT_CONTROLLER)
call METHOD ME->M_PARENT->GET_CONTROLLER
EXPORTING
CONTROLLER_ID = 'search'
IMPORTING
CONTROLLER_INSTANCE = Parent2
No one work!
How can i do?
Here screnshot of that i see in debug mode, and that i want get:
http://img190.imageshack.us/i/1debugscreen.jpg/
http://img10.imageshack.us/i/2debugscreen.jpg/
Thanks in advance,
DavideHi Pawan,
classes ref to CL_BSP_CONTROLLER2 like my controller class, have an attribute
M_PARENT type IF_BSP_DISPATCHER.
If the class is a subclass of an main class it has the M_PARENT attribute containing the instance of the parent class,
i can see in debug mode ( here example: http://img40.imageshack.us/img40/1648/3debugscreen.jpg )
i can get this attribute:
data: Parent type ref to IF_BSP_DISPATCHER, " type take from attribute M_PARENT of the class
Parent = ME->M_PARENT.
but the interface IF_BSP_DISPATCHER has no attribute and no method defined, and if i declare 'Parent' as type ref to
CL_BSP_CONTROLLER2 the compiler return error
<=> "The type of "PARENT" cannot be converted to the type of "ME->M_PARENT". "
Davide -
Reflection: get an instance of a internal class by default constructor
Hi there
first the structure (reduced):
public class ConvertionFactors { //singelton
private HashMap<String,Class> factors = new HashMap<String,Class>();
private class M_TO_FT implements DataFilter{
public double convert(double value) {
return value*M_IN_FT;
public DataFilter getFilter(String from, String to)
String name = from.toUpperCase()+convertionMethodNameSeparator+to.toUpperCase();
Class c = factors.get(name); //retrieve the class
Object o = c.newInstance(); //generate a instance.... not working
return (DataFilter)o;
The problem i want an instance of the internal class without defining a construktor like
public M_TO_FT(){} because there are many classes like this one :-(
(that was already working with a constructor that wants an instance of the container class.... thats what i am missing in the call c.newInstance() which uses the default constructor (i gues))
i want something like
new M_TO_FT() ; just the reflection version of it which calls the default constructor
thanks for helpwell i get a Exception like this:
java.lang.InstantiationException: com.eads.jpinfinity.data.unit.ConvertionFactors$M_TO_FT
at java.lang.Class.newInstance0(Class.java:335)
at java.lang.Class.newInstance(Class.java:303)
at com.eads.jpinfinity.data.unit.ConvertionFactors.getFilter(ConvertionFactors.java:315)
at com.eads.jpinfinity.data.unit.junit.ConvertionFactorsTest.testGetFilter(ConvertionFactorsTest.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
i think because i never told the method which is the containing class for this internal class. if i defina a constructor in the inner class it always needs a instance of the containter. by calling c.newInstance() there is no relation to the container class and because the inner class cant exist without the outer class it may not be constructed.
It is possible to get an instance with "new FT_TO_M();" (the traditional way) with the default constructor but jet i have not found a way to get a instance of a inner class with reflection without defining a constructor. -
Getting the Instance of a Class
I have this program where each user had there own prefences stored in there directory. A class called UserPrefences load the prefences into the data members of that class.
The problem is I want to get the instance of that prefences which was loaded to be accessed by other classes. I don't want to have to reload all the prefences again from a text file but rather get the instance of UserPrefences from different class. So how do I get the instance of that one class without creating a new object each time I access prefences from a different class?Singleton????It's a design pattern you use when you want exactly one instance of something to exist.
Can there be a static class? Top level classes cannot be static, but you can have a class full of static member variables.
Because there are many
fields in these prefences.Not sure how that's relevant.
You've given almost no information about your requirements, so I can't really give you any more specific help. -
How to get CLASS name for the generic item?
Hi,
I wrote following method to create a service instance.
public static <IType> IType GetServiceInstance()
IType type=null;
try
InitialContext ic=new InitialContext();
//ERROR: type= ic.lookup(IType.class.getName());
catch(Exception ex)
//do handle
return type;
}please see the //Error: here its giving error, also i m not getting "class" variable in IDE!!!
i want use like this;
IUserService userService=ServiceFactory.GetServiceInstance<IUserService>();so how can i do this?
Edited by: Manikandan.Java on Oct 31, 2007 3:02 AMI don't know if I understand your question, but you cannot find the class name because it is in run time just an object. You can, however, check if it is an instanceof.
if (genericType instanceof MyType) {
doMyThing();
} -
How to create object by getting class name as input
hi
i need to create object for the existing classes by getting class name as input from the user at run time.
how can i do it.
for exapmle ExpnEvaluation is a class, i will get this class name as input and store it in a string
String classname = "ExpnEvaluation";
now how can i create object for the class ExpnEvaluation by using the string classname in which the class name is storted
Thanks in advancei think we have to cast it, can u help me how to cast
the obj to the classname that i get as inputThat's exactly the point why you shouldn't be doing this. You can't have a dynamic cast at compile time already. It doesn't make sense. Which is also the reason why class.forName().newInstance() is a very nice but also often very useless tool, unless the classes loaded all share a mutual interface. -
I am using array list and retuning as list i am getting class cast exceptio
Hi
below is my code
public List fun(){
List list=new ArrayList()
return(list)
public main()
List samp=xxx.fun();
its throwing a class cast exception
please help me
thnaks
sreedeviQCDataInfo condInfo;
if(conditions!=null){
ListIterator li = conditions.listIterator();
while (li.hasNext()) {
condInfo = (QCDataInfo) li.next();
stmt = conn.getConnection().prepareStatement(sql);
stmt.setLong(1, JLong.forceLong(loanId));
stmt.setString(2,condInfo.getCategory());
stmt.setString(3,condInfo.getCleared());
stmt.setString(4, condInfo.getMessage());
stmt.setString(5, condInfo.getNotes());
System.out.println(condInfo.getCategory()+"=dtstus="+condInfo.getCleared()+"=execute:="+stmt.executeUpdate());
public static List getQCDataInfo(String loanId)
throws ACTPortalException {
info = new ArrayList();
int x=0,a=0,b=0,c=0,d=0,e=0,f=0;
while(rs.next()) {
QCDataInfo xform=new QCDataInfo();
xform.setCategory(rs.getString("category"));
xform.setCleared(rs.getString("cleared"));
xform.setMessage(rs.getString("message"));
xform.setUpdated(rs.getString("updated"));
xform.setNotes(rs.getString("notes"));
if(rs.getString("category").equals("Occupancy")){
xform.setIndex(x);x++;
}else if(rs.getString("category").equals("Liabilities")){
xform.setIndex(a);a++;
}else if(rs.getString("category").equals("Assets")){
xform.setIndex(b);b++;
}else if(rs.getString("category").equals("REO")){
xform.setIndex(c);c++;
}else if(rs.getString("category").equals("Collateral")){
xform.setIndex(d);d++;
}else if(rs.getString("category").equals("Employment and Income")){
xform.setIndex(e);e++;
} else if(rs.getString("category").equals("Other")){
xform.setIndex(f);f++;
// System.out.println("data:"+rs.getString("category")+":row number:"+rs.getRow());
info.add(xform);
return (info);
the above are 2 methods where i am getting class cast exception
=21 Apr 2006 10:16:44,828 JLogger->Caught exception in AuthorizationFilter.doFilter: null
java.lang.ClassCastException
at org.apache.struts.util.RequestUtils.lookupActionForm(RequestUtils.java:215)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:181)
at org.apache.struts.action.RequestProcessor.processActionForm(RequestProcessor.java:321)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:204)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.mindbox.app.CompressionFilter.doFilter(CompressionFilter.java:199)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.mindbox.app.DemoAccountFilter.doFilter(DemoAccountFilter.java:49)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.mindbox.app.AuthorizationFilter.doFilter(AuthorizationFilter.java:66)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
the above is the eeror which i am geeting when i call those methods
i thought there is a something wrong
thanks
sreedevi -
Getting Class not registered error when I run wmi queries
Getting Class not registered error when I run win32 wmi queries. Eg:
Specs:
Lenovo 3000 N100
Windows Vista Home Premium
Genuine Intel (R) CPU T2080 @ 1.73 GHz (2 CPUs)
1014 MB RAM
DirectX 10
Intel(R) GMA 950 -
To get Class object representing the primitive type by a String
for classes,I can use
classNameString = "java.lang.String"
Class c=Class.forName(classNameString);
to get Class object representing the classNameString.
but to get Class object representing the primitive type ,I have to use something like :
Class c=Integer.TYPE;
is there any way to get Class object representing the primitive type by a String?not using Class.forName(). you'll just need to key off the String passed to see whether it names a primitive:class ClassUtilities {
* Gives the <code>Class</code> corresponding to a named class or primitive.
* @param name FQN of a class, or the name of a primitive type
* @param loader a {@link java.lang.ClassLoader ClassLoader}
* @return the <code>Class</code> for the name given. This method
* converts primitive type names to their particular <code>Class</code>
* object. <code>null</code>, the empty string, <code>"null"</code>, and
* <code>"void"</code> yield {@link java.lang.Void#TYPE Void.TYPE}. If any
* classes require loading because of this operation, the given
* <code>ClassLoader</code> performs the loading. Such classes are not
* initialized, however.
* @throws ClassNotFoundException if the name names an unknown class
* or primitive
* @see java.lang.Class#getName
static Class classForNameOrPrimitive( String name, ClassLoader loader )
throws ClassNotFoundException {
if ( name == null || name.equals( "" ) || name.equals( "null" ) || name.equals( "void" ) ) {
return Void.TYPE;
if ( name.equals( "boolean" ) )
return Boolean.TYPE;
if ( name.equals( "byte" ) )
return Byte.TYPE;
if ( name.equals( "char" ) )
return Character.TYPE;
if ( name.equals( "double" ) )
return Double.TYPE;
if ( name.equals( "float" ) )
return Float.TYPE;
if ( name.equals( "int" ) )
return Integer.TYPE;
if ( name.equals( "long" ) )
return Long.TYPE;
if ( name.equals( "short" ) )
return Short.TYPE;
return Class.forName( name, false, loader );
} -
Cant get class texF (-1728)
Hi,
short description what i am trying to do:
I have writte a small applescript/shell script combi using exiftool to change efix-data of a specified folder.
After having realized how simple that is with pure applescript / shell script i planned to create a small application using XCode to optimize the workflow and user-experience.
I have to admit i am new to Xcode.
Ok, after firing up XCode & Interface Builder, i have selected:
- New Project -> application -> Applescript application
To get started with that i planned to play a bit with variables and ui-elements (ns text filed, buttons etc...)
So i do have a window, with 2 NSTextfields and 1 NSButton
I have selected the NSbutton and in Inspector i selected apple Script - action -clicked.
Now i continued with editing the .script file.
I was trying to do really small steps, to trying to copy content of a single text filed to a variable and then insert it into the other textfield.
sounds pretty easy i know.
on clicked theObject
set tempVar to content of text field "myfieldA"
set content of text field "myfieldB" to tempVar
end clicked
If i run the app and press my button i get the following error message:
Can't get <<class textF>> "myfieldA". (-1728)
Unfortunaly there seem to be no single documentation about those error codes, or google does not know the location. Having searched for a long time now.
As i am stuck right now i have checked several other examples, but my attempts looks to be correct... at least for my as starter.
Can someone help me out ?
thanks in advanceI think your problem is that you need to _fully specify_ the containment hierarchy of your text fields so AS Studio can locate them. Give your window an AppleScript name just like you've done for the two text fields, then do this:
on clicked theObject
set tempVar to content of text field "myfieldA" of window "myWindow"
set content of text field "myfieldB" of window "myWindow" to tempVar
end clicked
Or this:
on clicked theObject
tell window "myWindow"
set tempVar to content of text field "myfieldA"
set content of text field "myfieldB" to tempVar
end tell
end clicked
If your text fields are contained in a box, tab view, etc then you'll also need to take that into account when specifying the containment hierarchy.
Steve -
Getting class names in jconsole
Hello,
Is it possible to get class names which are loaded in the memory using jconsole?
I am using jdk 1.5. I have configured jmx in my Weblogic 9.2.
I am able to find the memory usage by the application, but i dont know how to get those class names in jconsole.
Regards,
SampathHi,
we ckeck all the class names in package.
first goto se80.select package and give package name and click on display button.it will display all the structures,classes which are assigned to that particular package .in that select class it will expand and displays all the names.
Cheers,
vasavi.
kindly reward if helpful. -
How do I get class in the javax.* package
How do I get class in the javax.* package
If possible don't mess with the javax Package
I mean I could not get the advantage of getting a class under javax Package
But for information
make a folder named javax
Make your class in that folder with starting code as
package javax;and then compile it and make a jar file and add it to classpath
It is very simple
But I think you should not mess with it
Is there any special requirement?
Bye for now
CSJakharia -
How can I get an instance of my customize cell in tableview?
Hi,I'd like to generate a customize tablecell in my tableview.but How can I get an instance of my customize cell in tableview when selected item changes?
public class Person {
private javafx.beans.property.BooleanProperty active;
private StringProperty firstName;
private StringProperty lastName;
private StringProperty email;
private Person(String fName, String lName, String email) {
this.active = new SimpleBooleanProperty(true);
this.firstName = new SimpleStringProperty(fName);
this.lastName = new SimpleStringProperty(lName);
this.email = new SimpleStringProperty(email);
public javafx.beans.property.BooleanProperty activeProperty() { return active; }
public StringProperty firstNameProperty() { return firstName; }
public StringProperty lastNameProperty() { return lastName; }
public StringProperty emailProperty() { return email; }
final ObservableList<Person> data = FXCollections.observableArrayList(
new Person("Jacob", "Smith", "[email protected]"),
new Person("Isabella", "Johnson", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"),
new Person("Michael", "Brown", "[email protected]")
public class RatingCell extends TableCell<Person,String> {
private NabiSyncRating rating;//NabiSyncRating is a customize control.it has some method ,like change backgroud-color,value,etc.
public RatingCell() {
rating = new NabiSyncRating(-1);
@Override
public void startEdit() {
super.startEdit();
if (isEmpty()) {
return;
rating.setDisable(false);
rating.requestFocus();
@Override
public void cancelEdit() {
super.cancelEdit();
rating.setDisable(true);
public void commitEdit(String value) {
super.commitEdit(value);
rating.setDisable(true);
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
Callback<TableColumn<Person, String>, TableCell<Person, String>> ratingCellFactory = new Callback<TableColumn<Person, String>, TableCell<Person, String>>() {
@Override
public TableCell<Person, String> call(
TableColumn<Person, String> p) {
return new RatingCell();
TableColumn firstNameCol = new TableColumn();
firstNameCol.setCellFactory(ratingCellFactory);
firstNameCol.setMinWidth(100);
firstNameCol.setMaxWidth(224);
firstNameCol.setResizable(true);
tableView.getColumns().addAll(firstNameCol);
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, Object oldvalue, Object newValue)
Person person=(Person)newValue;
//I'd like to get the instance of my customize control 'RatingCell' ,How can I get the RatingCell instance which in current row?
System.out.println("selected row is : " + newValue );
});HI,
I have found a solution to find it
First ,you need to set person property 'id' as the input parameter for your customized component method 'public void updateItem(String item, boolean empty)'
ratingCol.setCellValueFactory(new PropertyValueFactory<Person,String>("id"));
firstNameCol.setCellFactory(ratingCellFactory);and then you need to implement your customize component like this:
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.TableCell;
public class RatingCell extends TableCell<Person,String> {
private NabiSyncRating rating;
public RatingCell() {
rating = new NabiSyncRating(5);
this.setGraphic(rating);
this.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
this.setEditable(true);
public void updateRating()
if(rating!=null)
rating.selectRating();
@Override
public void startEdit() {
super.startEdit();
if (isEmpty()) {
return;
rating.setDisable(false);
rating.requestFocus();
@Override
public void cancelEdit() {
super.cancelEdit();
rating.setDisable(true);
public void commitEdit(String value) {
super.commitEdit(value);
rating.setDisable(true);
@Override
public void updateItem(String item, boolean empty) {
if(item!=null && item.length()>0)
if(rating!=null)
rating.setId("NR"+item);
this.setId("NC"+item);
super.updateItem(item, empty);
} and find the current like this :
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, Object oldvalue, Object newValue)
Person person=(Person)newValue;
Set<Node> colNodes=tableView.lookupAll("RatingCell");
for(Node nod:colNodes)
System.out.println("person.email:"+"NC"+person.email.getValue()+"|nodId: " + nod.getId()+"\r\n" );
if(("NC"+person.email.getValue()).equals(nod.getId()))
System.out.println("get current instance" );
((RatingCell)nod).updateRating();
});Edited by: noob on Apr 20, 2012 4:49 PM -
Can't get an instance of ConnectionPoolManager
I am trying to share the database connection pool across not only app modules but some of our pages that need to connect to the db but do not have app modules on them. But when I try to get the ConnectionPoolManager instance, it fails (UNLESS a page with an app module on it was loaded first). If I try to get the instance first I get a nullpointer exception. Important note: I am in my own connection wrapper class so I do not have a session or pageContext.
I do this in my static initializer block of my class:
poolManager = ConnectionPoolManagerFactory.getConnectionPoolManager();
(this throws a null pointer exception)
and I've traced the error to this line in the ConnectionPoolManagerFactory getting null back:
String s = PropertyMetadata.PN_POOL_MANAGER.getProperty();
I suspect it is because the oracle.jbo.PropertyManager.loadProperties has not been run yet. The javadocs says: "This class is used at framework initialization time to choose values for the various properties".
So, my questions are:
1) How can I initialize the framework from my bean that is not tied to a session?
2) If I have to invoke an app mod instance to make this work....is there a simple way to create a dummy app mod instance from a bean that is not tied to a session?Hi,
As you have figured out the ConnectionPoolManagerFactory was intended for use by the BC4J RT only -- it has never been
tested for use by an Object external to the oracle.jbo.server package. That said, I can see the value in maintaining a single
connection pool across BC4J and non-BC4J applications. I was able to workaround the exception reported above using the 9.0.3
preview release with the following test procedure:
System.setProperty(
PropertyMetadata.PN_POOL_MANAGER.pName
, PropertyMetadata.PN_POOL_MANAGER.pDefault);
try
Class.forName("oracle.jdbc.driver.OracleDriver");
catch (Exception e)
ConnectionPoolManager mgr = ConnectionPoolManagerFactory.getConnectionPoolManager();
String poolKey = mgr.generatePoolKey("jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL", null);
Connection conn = mgr.getConnection(
poolKey
, "jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL"
, null
, null
, null);
if (conn != null)
System.out.println("success");
mgr.returnConnection(poolKey, conn);
Please note the first line that adds the ConnectionPoolManagerImpl classname to the System properties. Please note that this
property could also be specified at the command line with a VM parameter:
-Djbo.ConnectionPoolManager=oracle.jbo.server.ConnectionPoolManagerImpl
I have filed an enhancement request for this use case and will provided better support in 9.0.4.
Hope this helps.
JR -
Can not get two instances to join same cluster even on same machine
On a RedHat Linux box, I have failed to get two instances of coherence to join the same cluster. I have managed to get the muticast test tool to show that packets are being sent and received. To do this, I had to:
java -cp bin/tangasol.jar -Djava.net.preferIPv4Stack=true com.tangosol.net.MulticastTest
Wed Apr 15 21:02:45 WET 2009: Sent packet 1.
Wed Apr 15 21:02:45 WET 2009: Received test packet 1 from self (sent 7ms ago).
Wed Apr 15 21:02:47 WET 2009: Sent packet 2.
Wed Apr 15 21:02:47 WET 2009: Received test packet 2 from self
Wed Apr 15 21:02:49 WET 2009: Sent packet 3.
Wed Apr 15 21:02:49 WET 2009: Received test packet 3 from self (sent 1ms ago).
Wed Apr 15 21:02:51 WET 2009: Sent packet 4.
Wed Apr 15 21:02:51 WET 2009: Received test packet 4 from self
However, I could not get the following to show that two instances are joining the same cluster... When I start to instances, both of them create a new cluster with only one member in each.
java -Djava.net.preferIPv4Stack=true -jar lib/coherence.jar
and obviously, when I try to start two instances of the sample application, I get the same problem.
java -cp ./lib/coherence.jar:./lib/tangosol.jar:./examples/java -Djava.net.preferIPv4Stack=true -Dtangosol.coherence.localhost=172.16.27.10 -Dtangosol.coherence.localport=8188 -Dtangosol.coherence.cacheconfig=/cache/explore-config.xml com.tangosol.examples.explore.SimpleCacheExplorerThanks for that... I ran:
jdk1.6.0_13/bin/java -Dtangosol.coherence.log.level=6 -Dtangosol.coherence.log=/my1.log -Dtangosol.ccacheconfig=/cache/explore-config.xml -Djava.net.preferIPv4Stack=true -jar lib/coherence.jar
and then
jdk1.6.0_13/bin/java -Dtangosol.coherence.log.level=6 -Dtangosol.coherence.log=/my2.log -Dtangosol.ccacheconfig=/cache/explore-config.xml -Djava.net.preferIPv4Stack=true -jar lib/coherence.jar
from the same machine and get the following from the log file of the second run (my2.log)
Oracle Coherence Version 3.4.2/411
Grid Edition: Development mode
Copyright (c) 2000-2009 Oracle. All rights reserved.
2009-04-16 06:53:11.574/0.625 Oracle Coherence GE 3.4.2/411 <Warning> (thread=main, member=n/a): UnicastUdpSocket failed to set receive buffer size to 1428 packets (2096304 bytes); actual size is 89 packets (131071 bytes). Consult your OS documentation regarding increasing the maximum socket buffer size. Proceeding with the actual value may cause sub-optimal performance.
2009-04-16 06:53:11.660/0.711 Oracle Coherence GE 3.4.2/411 <D5> (thread=Cluster, member=n/a): Service Cluster joined the cluster with senior service member n/a
2009-04-16 06:53:14.892/3.943 Oracle Coherence GE 3.4.2/411 <Info> (thread=Cluster, member=n/a): Created a new cluster "cluster:0x2FFB" with Member(Id=1, Timestamp=2009-04-16 06:53:11.58, Address=192.168.1.7:8089, MachineId=26887, Location=process:3514, Role=CoherenceConsole, Edition=Grid Edition, Mode=Development, CpuCount=8, SocketCount=2) UID=0xC0A8010700000120ADB3521C69071F99
SafeCluster: Name=cluster:0x2FFB
Group{Address=224.3.4.2, Port=34411, TTL=4}
MasterMemberSet
ThisMember=Member(Id=1, Timestamp=2009-04-16 06:53:11.58, Address=192.168.1.7:8089, MachineId=26887, Location=process:3514, Role=CoherenceConsole)
OldestMember=Member(Id=1, Timestamp=2009-04-16 06:53:11.58, Address=192.168.1.7:8089, MachineId=26887, Location=process:3514, Role=CoherenceConsole)
ActualMemberSet=MemberSet(Size=1, BitSetCount=2
Member(Id=1, Timestamp=2009-04-16 06:53:11.58, Address=192.168.1.7:8089, MachineId=26887, Location=process:3514, Role=CoherenceConsole)
RecycleMillis=120000
RecycleSet=MemberSet(Size=0, BitSetCount=0
Services
TcpRing{TcpSocketAccepter{State=STATE_OPEN, ServerSocket=192.168.1.7:8089}, Connections=[]}
ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=3.4, OldestMemberId=1}
the contents of the xml file are:
<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>
<!--
Caches with any name will be created as default replicated.
-->
<cache-mapping>
<cache-name>*</cache-name>
<scheme-name>default-replicated</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<!--
Default Replicated caching scheme.
-->
<replicated-scheme>
<scheme-name>default-replicated</scheme-name>
<service-name>ReplicatedCache</service-name>
<backing-map-scheme>
<class-scheme>
<scheme-ref>default-backing-map</scheme-ref>
</class-scheme>
</backing-map-scheme>
</replicated-scheme>
<!--
Default backing map scheme definition used by all
The caches that do not require any eviction policies
-->
<class-scheme>
<scheme-name>default-backing-map</scheme-name>
<class-name>com.tangosol.util.SafeHashMap</class-name>
</class-scheme>
</caching-schemes>
</cache-config>
Maybe you are looking for
-
How can I send a whole ITunes library from one computer to another? AIM
Okay, I am trying to send a whole library of roughly 800 songs using Aol Instant Messenger. I have tried many different ways, sending the ITL file, the itunes 4 music library. When I tried these and replaced the library with it, it worked, but didn't
-
HT1495 how to restore iphon-without backup, after it synchronization from ipod
how to restore iphon-without backup, after it synchronization from ipod
-
HP Officejet 8600 is not recognized by Acrobat 9.5.5 when trying to scan
When trying to create a PDF document via Acrobat (file/create PDF), Adobe does not recognize my new HP Officejet 8600 print/scan/fax/etc. Any solutions?
-
So confusing - can anyone explain how to set this up
I'm a long time Mac user, ical user, mac Mail user, Mobile Me user, iPhone and now iPad user. I have a Work and Personal Calendar in iCal. Whenever this new MobileMe and iCal came out, nothing works as I think it should. My calendars are on my mac an
-
Can anybody telle me the purpose of the number (56) in the following statement: 56 static cookie-value "R355972695" rserver HQCHECOM01