Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!

Sakti Singh

Greenhorn
+ Follow
since Dec 13, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sakti Singh

Deepa,
Double click on server and go to Environment tab. Add the classes12.zip in classpath section. Save it and restart the server.

Hope this will work ..If not let me know..

thanks,

Sakti
14 years ago
Ankur,

right click on WSAD icon and add "-setworkspace" to target URL.

it should look like :

"C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\wsappdev.exe" -setworkspace

hope this helps..

thanks,

Sakti
14 years ago
Folks,

I tried to search for info on this in google and javaranch but could not get anything useful. I am using WSAD and Websphere test environment. Can I configure listener port to listen to Oracle AQ messages.

thanks,

Sakti Singh
14 years ago
To ALL J2EE Guru's,

I am getting some problems in looking up my beans local home interface(Details under), however when I look up the remote home interface its fine. Please look into my problem when you have a minute. Appreciate your help.
---------------------------------- Details --------------------
1. I have 2 beans, one stateful, other stateless and both have remote and local interfaces
2. I can access both using remote interfaces but not using local interfaces
3. However TestClient works fine for both Remote and Local interfaces:

Followings are the urls TestClient looks up:

Stateless Bean remote Interface:

http://localhost:9080/UTC/jndiLookup?name=com/selectica/configejb/CxConfigStatelessHome&random=0.032660621190745975

Stateless Bean LocalInterface:

http://localhost:9080/UTC/jndiLookup?name=local:/ejb/com/selectica/configejb/CxConfigStatelessHome&random=0.32728747419322335

In my client program I used following JNDI:

I. For looking up remote home : com/selectica/configejb/CxConfigStatelessHome (Works OK)
II. For Looking up local home: local:ejb/com/selectica/configejb/CxConfigStatelessHome (throws following exception)


javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: local
at com.ibm.ws.naming.jndicos.CNContextImpl.checkForUrlContext(CNContextImpl.java:2770)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1220)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at GetServiceProgramsLocal.getEJBObjectHandle(GetServiceProgramsLocal.java:130)
at GetServiceProgramsLocal.main(GetServiceProgramsLocal.java:54)


4. My Client module and ejb module are in same .ear.
5. I have created local references (Deployment descriptor is pasted below)

Some more Details:

Look up Code:


private static CxConfigLocalStateless getEJBObjectHandle() throws NamingException, CreateException, RemoteException {
CxConfigLocalStateless config = null;
final InitialContext ic = new InitialContext(); // get initial context
final CxConfigLocalStatelessHome home = (CxConfigLocalStatelessHome) ic.lookup("local:ejb/com/selectica/configejb/CxConfigStatelessHome");
config = (CxConfigLocalStateless)home.create();

return config;
}


Deployment Descriptor:

<?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

<ejb-jar id="ejb-jar_ID">

<enterprise-beans>
<session id="Session_1076368683641">
<ejb-name>SelecticaConfigEJB_Stateful</ejb-name>
<home>com.selectica.configejb.CxConfigHome</home>
<remote>com.selectica.configejb.CxConfig</remote>
<local-home>com.selectica.configejb.CxConfigLocalHome</local-home>
<local>com.selectica.configejb.CxConfigLocal</local>
<ejb-class>com.selectica.configejb.CxConfigBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
<env-entry id="EnvEntry_1076368726516">
<env-entry-name>CODEBASE</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>c:/selectica/kbs/;</env-entry-value>
</env-entry>

<env-entry id="EnvEntry_1076368726517">
<env-entry-name>DATASOURCE_CONFIG_FILE</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>ds.xml</env-entry-value>
</env-entry>

<env-entry id="EnvEntry_1076368726518">
<env-entry-name>DEBUG</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>False</env-entry-value>
</env-entry>

<ejb-local-ref id="EJBLocalRef_1129752409153">
<ejb-ref-name>ejb/SelecticaConfigEJB_Stateful</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.selectica.configejb.CxConfigLocalHome</local-home>
<local>com.selectica.configejb.CxConfigLocal</local>
<ejb-link>SelecticaConfigEJB_Stateful</ejb-link>
</ejb-local-ref>
</session>

<session id="Session_1076368683642">
<ejb-name>SelecticaConfigEJB_Stateless</ejb-name>
<home>com.selectica.configejb.CxConfigStatelessHome</home>
<remote>com.selectica.configejb.CxConfigStateless</remote>
<local-home>com.selectica.configejb.CxConfigLocalStatelessHome</local-home>
<local>com.selectica.configejb.CxConfigLocalStateless</local>
<ejb-class>com.selectica.configejb.CxConfigStatelessBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<env-entry id="EnvEntry_1076368726531">
<env-entry-name>CODEBASE</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>http://localhost:8080/;c:/selectica/kbs/;</env-entry-value>;
</env-entry>
<env-entry id="EnvEntry_1076368726532">
<env-entry-name>DATASOURCE_CONFIG_FILE</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>ds.xml</env-entry-value>
</env-entry>

<env-entry id="EnvEntry_1076368726533">
<env-entry-name>DEBUG</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>False</env-entry-value>
</env-entry>

<ejb-local-ref id="EJBLocalRef_1129752409223">
<ejb-ref-name>ejb/SelecticaConfigEJB_Stateless</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.selectica.configejb.CxConfigLocalStatelessHome</local-home>
<local>com.selectica.configejb.CxConfigLocalStateless</local>
<ejb-link>SelecticaConfigEJB_Stateless</ejb-link>
</ejb-local-ref>
</session>
</enterprise-beans>

<assembly-descriptor id="AssemblyDescriptor_ID">
<container-transaction id="MethodTransaction_1076368726531">
<method id="MethodElement_1076368726547">
<ejb-name>SelecticaConfigEJB_Stateful</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>

<trans-attribute>Required</trans-attribute>
</container-transaction>

</assembly-descriptor>
</ejb-jar>

Regards,
Sakti
[ October 21, 2005: Message edited by: Sakti Singh ]
14 years ago
my apologies , please read it as b = (byte)(b+1)

thanks to all those who pointed this out

Regards,
Sakti
I agree with Steve, given the files are in proper package the answer should be E. If you make x public, output will be x = 42.
1. Java does implicit narrowing conversion when the right hand side of an expression is a constant or can be evaluated to be a constant during compile time.

so
byte b =1 //valid
byte b= 1+2 // valid

but byte b = b+1 // Invalid -- as it can not be evaluated during compile time

2. Above is valid only if the compile time constant is within the range of the type used.

byte b = 128; //Invalid -- compile time error

3. b+=1 is evaluated as b = (Type of b) b+1 by compiler.

So in the above case its b = (byte) b+1 which is correct since the integer value as a result of (b+1) is typecasted to byte.

Also note that :

byte b = 127;
b+=1; or b++ or ++b // Valid -- for the above reason


Hope this helps.

Regards,
Sakti
[ August 17, 2005: Message edited by: Sakti Singh ]
Smitha,

Binary negative numbers are expressed in 2's complement. To get 2's complement of binary number b you need to do following:

~b + 1 (I guess you know ~, i,e changing 1 to 0 and viceversa)

for ex:

+9 in base 10(Decimal) = 0000 1001 in base 2(Binary)
1. ~(+9) = 1111 0110
2. add 1 = 1111 0111 = -9 in binary.

Also remember when you have a binary negative number (Sign bit is 1) then you can 2's complement that and calculate the decimal to findout what number is that.

for ex if somebody asks you what is 1111 0111 in decimal:

now:

1. you know its a negative number (sign bit is 1)

2. 2's complement will be - 0000 1001 -- thats 9 so the original decimal number is -9.

Note: All my examples are in 8 bit format, but Java used 32 bits for integer. Anyway I can assure you that the concept is the same.

Now I guess you can understand how 1111 1011 is -5.

Hope this helps..

Sakti Singh
[ August 16, 2005: Message edited by: Sakti Singh ]
&& - Short Circuit AND
|| - Short Circuit OR

for AND :

false && any boolean (true/false) is always false, so && does not evaluate the 2nd part when first part if false ..

Similarly incase of || , if first part is true, the second part is not evaluated..

Hope this helps
Hi Lasse, thanks for looking at this:

Lasse>Is this a web application (a .war file) or a standalone application?

Sakti> This is a web app, .war file

Lasse> Is the user supposed to edit this configuration file at some point or is it a "static" configuration that the user doesn't even know about?

Sakti> The xml file should be modified only at the time of deployment.

This xml file has ini variables like:
dbuser, dbpassword, schema, mailserver, adminid, approverid et al

Which may be modified after deployment as well. So I would say its not a "static" configuration.
[ June 27, 2004: Message edited by: Sakti Singh ]
Hello Folks,

I am using an xml file as my initial config file. I don't want to hard code the aboslute path of the xml file in xml file reader class. Is there any way I can tell the xml path to my config xml file reader?

Eg: String xmlFilePath = "C:\test\test.xml"
SAXParser saxParser = factory.newSAXParser();
saxParser.parse( new File(xmlFilePath), this);

I don't want to hardcode xmlFilePath


My problem will be solved if I can

1. use relative path
2. some kind of class path

else I will have to write another ini file (which will have the xml file path) and place that at root directory

Note that my application supports : AIX, Linux and windows


Appreciate you help..

Namaste,

Sakti
[ June 26, 2004: Message edited by: Sakti Singh ]
Hi, Check your logic...Let me know if this sloves ur problem..
is this correct ; after if means if is doing nothing)
-----------------------------------------------
if (node.getParentNode().getParentNode().getNodeName().equals(ORDER_HEADER));

-----------------------------------------------
if (node.getParentNode().getNodeName().equals(COMMENTS))
{
if (node.getParentNode().getParentNode().getNodeName().equals(ORDER_HEADER));
activation.setSpecial_instructions(node.getNodeValue());
System.out.println("Special Instructions " + activation.getSpecial_instructions());
}
---------------------------------------------------
yes,
try this:
-----------
response.setContentType("text/html")
thanks
Sakti
18 years ago
JSP
if more than one exception raised by a piece of code you can specify more than one catch clauses , where each catch clause will catch a diff type of exception.
for eg.
try {
// your code
}
catch(SQLException se) { //-------1
se.printStackTrace();
}
catch(Exception e) { //----------2
e.printStackTrace();
}
Note: Exception class is super class of all other exceptios..hence should be caught last(last catch block)....
if u change the order of catch blocks to 2--1 , then 1 block will never be executed as 2 is capable of catching all the exceptions
Hope this will solve ur problem
thanks
Sakti