UserTransaction - Scope using JNDI lookup from jspInit() method
Howdy,
I'm using JSP's with JavaBeans accessing a DataSource and some other enviroment variables using JNDI lookups. I've read that JNDI lookups can take a fair amount of time and should be limited whenever possible. My previous configuration had the JNDI lookups inside the constructors of the JavaBeans but I've recently decided to move them to the jspInit() method of the calling JSP. This way the lookup only needs to be performed once and then I pass the values to the JavaBean in a method called setContextVariables. Two of the references to objects that i'm sending are the UserTransaction and DataSource objects. Within the Javabeans I have userTran.begin() and commit() statements. So far it's running great but i'm starting to wonder about the thread safety of this method. My question lies in the actual delagation of the UserTransaction object to the calling client method. It seems that i'm passing the same transaction to every Javabean (or am I?) Is the transaction actually issued when the begin() method is called, or at the time of the JNDI lookup? To test everything out, I opened two sessions and put a breakpoint inside one of the transactions. When I stopped at the breakpoint I ran another thread (also using a transaction retrieved from the same JSP). Then I went back and resumed the first thread and everything seemed to work ok. So... this seems completely fantabulastic so far (definitely noticable response time increases) but I'm still a little skeptical. If anyone is using a process similar to this I would appreciate some feedback. Thanks.
Hi,
The EJB bean will use the client transaction when the following attributes are specified in descriptor.
1) Required
2) Mandatory
3) Supports
In Required case, if the client is associated with Transaction, then the EJB bean will use the same transaction. This is achieved by Transaction context. The EJB bean will use the same transaction context set by client. if the client doesn't have any transaction, then the container will create new transaction context for EJB bean and completes the transaction.
In Mandatory case, the client must be associated with Transaction so that EJB bean will use the same transaction. If the client doesn't associate with transaction, then container will throw TransactionRequiredException for EJB bean.
In Supports case, it works similar to Required case except that if the client doesn't associate with transaction, then there won't be any transaction in EJB bean.
hope this helps.
Similar Messages
-
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 -
Calling non ejb from ejb using jndi lookup
Is it possible to call a non ejb java object from an ejb using a jndi lookup?
For example, we have a java class where main registers itself with our application server (JBoss 3.0.1). We have a test client that can use jndi to look up the object, but we can't get an ejb inside the application server to use the object.
Are we trying to do the impossible? If my question is not clear, please let me know so I can try to clarify.
ThanksJNDI uses factories to create objects.
It's possible that JBoss has a Bean Factory which you can use to create your instance.
Tomcat has a Bean factory in its JNDI implementation. I use it just as you have indicated.
The JBoss documenation may help?
Dave -
Calling BRM from UDF using JNDI lookup with @EJB annotation
Hi Experts
I am trying to implement a UDF to invoke my BRM Rules set via JNDI Lookup instead of a SOAP Channel lookup.
I have had a look at the following links/docs:
Calling BRM from UDF using Public API
http://www.gleanster.com/system/resources/W1siZiIsIjIwMTIvMDgvMDcvMjAvNDcvNTAvNDMvVGhpbmdzX1lvdV9TaG91bGRfS25vd19hYm91dF9TQVBfTmV0V2VhdmVyX0JSTS5wZGYiXV0/Things%20You%20Should%20Know%20about%20SAP%20NetWeaver%20BRM.pdf
For item 1 above, the example looks really good, but it doesnt explain how I get access to the following required imports from my UDF:
import com.sap.brms.qrules.ejb.*;
import com.sap.brms.qrules.engine.AbstractProject;
import com.sap.brms.qrules.engine.RuleEngine;
import com.sap.brms.qrules.engine.RulesetContext;
import javax.ejb.EJB;
The second document is really good as well, but I could not figure out how to get it to work from my UDF.
So, can anyone help me to understand specifically what is required to get this to work?
Is is possible to invoke the rule set from my UDF?
How do I give my UDF access to all the required jars/imports?
I have manage to create a new DC (Development Component) with a public part and this enables me to get my code to compile on my local PC but I am not able to activate it due to the server not having access to the same java packages as my local copy.
Any help would be greatly appreciated.You resolve the dependency by importing the required jars with using the dependency tab for the mapping program.
As stipulated before, I have managed to resolve the dependency issue but I have now getting the same error as in the forum: Calling BRM from UDF using Public API
The specific error is:
com.sap.engine.services.cross.PortableRemoteObjectContainer.narrow(PortableRemoteObjectContainer.java:238)
Has anyome manage to get invoke a BRM Ruleset using JNDI? -
Problem deploying cmp bean invoking another cmp bean using jndi lookup
I have a cmp BeanA that invokes another cmp BeanB, so I am using a jndi lookup in BeanA to download the localhome object to BeanB using the following:
Context ctx = new InitialContext();
home = (LocalAddressHome) ctx.lookup("java:comp/env/ejb/BeanBHomeRef");
then I specify the ejb/BeanBHomeRef, entity bean, local, BeanB's local home and component interface in EJB ref. when I am packaging BeanA
I also package BeanB in a separate jar file.
When I attempt to deploy the application it throws strange exception that says the folowing:
java.lang.IllegalArgumentException: BeanBEJB says it links to an ejb called BeanBEJB of local home class LocalBeanBHome but no bean with this local home c
lassname and type can be found in this ejb-jar.
yet when I un-jar the package, these class files exitsts.
When I go ahead and delete the reference to BeanB from the BeanA package file, I am able to deploy the application but then correctly fails on jndi lookup.
I have been able to open the cmpcustomer.ear sample application that comes with RI and execute it without any problem. But when I to package the same beans for example CustomerBean and it won't even allow me to create the customer.jar file. I get a screen full of errors.......
I am using Sun RI 1.3.01, is there a known bug that I am not aware of? Is there a fix around it?
Is there any another way to get the home ref. to BeanB so I can invoke create() method?
Any advice or suggestions?
thanksl
-kaisaabWhat app server are you using? may be I can help you
--Ashish Saraf -
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 -
JNDI lookup from Tomcat to EJB Container
Hello!
i am currently trying to use a combination of Catalina and an external EJB Server (running on another machine).
i am really struggeling with doing the jndi lookup. i have no idea where and how to set the properties in the web server and do the mapping from the ejb-refs to the jndi name? (since tomcat doesnt seem to have a deploymentplan?!)
maybe someone here knows the problem and can help, please?
(i am not sure but this might also be the wrong discussion group for that??)
thanks
wolfgangHello Wolfgang,
I solved this problem by setting the proper jndi properties in the startup phase (MyInitServlet) by System.setProperty(...).
This seems ugly, but it works.
Tilo -
Could not access Local Session Bean using JNDI lookup
Hi EJB Guru,
I am quite new to EJB 3.0 but have had a good deal of success including using JNDI to lookup Remote Stateless Session Bean in EJB 3.0. However, looking up local Stateless Session Bean prove more challenging with I had anticipated.
Here is my code
as follows:
public interface Calculator {
public int add(int x, int y);
public int subtract(int x, int y);
import javax.ejb.Remote;
@Remote
public interface CalculatorRemote extends Calculator {
import javax.ejb.Local;
@Local
public interface CalculatorLocal extends Calculator {
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import bean.CalculatorLocal;
import bean.CalculatorRemote;
@Stateless
public class CalculatorBean implements CalculatorRemote, CalculatorLocal {
public int add(int x, int y) {
return x + y;
public int subtract(int x, int y) {
return x - y;
import bean.*;
import bean.Calculator;
import bean.CalculatorLocal;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ClientAccessLocalCalculator {
public static void main(String[] args) throws NamingException {
InitialContext ctx = new InitialContext();
CalculatorLocal calculator = (CalculatorLocal) ctx.lookup("CalculatorBean/local");
System.out.println("1 + 1 = " + calculator.add(1, 1));
System.out.println("1 - 1 = " + calculator.subtract(1, 1)); }
import bean.Calculator;
import bean.CalculatorRemote;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ClientAccessRemoteCalculator {
public static void main(String[] args) throws NamingException {
InitialContext ctx = new InitialContext();
CalculatorRemote calculator = (CalculatorRemote) ctx.lookup("CalculatorBean/remote");
System.out.println("1 + 1 = " + calculator.add(1, 1));
System.out.println("1 - 1 = " + calculator.subtract(1, 1)); }
}Output when running ClientAccessRemoteCalculator gives
1 + 1 = 2
1 - 1 = 0
Output when running ClientAccessLocalCalculator on JBoss AS 4.0.5 gives:
Exception in thread "main" javax.ejb.EJBException: Invalid invocation of local interface (null container)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:75)
at $Proxy0.add(Unknown Source) at ClientAccessLocalCalculator.main(ClientAccessLocalCalculator.java:14)
JNDIView in JMX-Console in JBoss:
+- CalculatorBean (class: org.jnp.interfaces.NamingContext)
| +- local (proxy: $Proxy84 implements interface bean.CalculatorLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
| +- remote (proxy: $Proxy83 implements interface bean.CalculatorRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
Output when running ClientAccessLocalCalculator on SJSAS 9.0 gives:
Exception in thread "main" javax.naming.NameNotFoundException: bean.CalculatorLocal not found
C:\>asadmin
Use "exit" to exit and "help" for online help.
asadmin> list-jndi-entries
Jndi Entries for server within root context:
bean.CalculatorRemote: javax.naming.Reference
jbi: com.sun.enterprise.naming.TransientContext
jdbc: com.sun.enterprise.naming.TransientContext
UserTransaction: com.sun.enterprise.distributedtx.UserTransactionImpl
bean.CalculatorRemote__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
bean.CalculatorRemote#bean.CalculatorRemote: javax.naming.Reference
ejb: com.sun.enterprise.naming.TransientContext
Command list-jndi-entries executed successfully.
asadmin>I am using Application Client to lookup these Session Beans on Netbeans 5.5, JBoss AS 4.0.5 (EJB3 installer)/SJSAS
9.0, SDK 1.5.0_11 on Windows XP platform.
Any assistance would be much appreciated.
Many thanks,
HenryHi Henry,
Any direct global JNDI lookup is not portable. It works in some cases but not in others, which
is why we recommend using the portable Java EE approach of declaring an ejb dependency
and looking up that dependency via the bean's component environment (java:comp/env).
This is true whether you're dealing with Remote or Local ejb dependencies.
Local ejbs are not supported in the Application Client tier at all. In the server tier, there is no
guarantee that a Local EJB even is assigned a global JNDI name since there's no requirement
that it be available outside of the application in which the ejb is defined.
You can find more information on these ejb access topics in our EJB FAQ :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html -
JNDI lookup from Portal Application Module
Dear Experts,
I have a problem with looking up a Deployable Web Service Proxy from within a Portal Application Module.
I use NWDI and created both the Deployable WS Proxy DC and the Portal App DC.
I added the generated Proxy to the Proxy DC's public part and added it as used DC to the Portal Module DC.
When I perform the JNDI lookup, no exception is thrown but the Code is not executed any further...
Here is the source:
Category.APPLICATIONS.infoT( loc, "lookup JNDI...", new Object[] { this });
Object o = ctx.lookup(JNDI_NAME);
Category.APPLICATIONS.infoT( loc, o.getClass().getName(), new Object[] { this });
service = (OrchestrationService)o;
Category.APPLICATIONS.infoT(loc, "success!", new Object[] { this });
The log shows the name of the class (OrchestrationServiceImpl) but not the success! part.
As I said: No exceptions are thrown...
Any help is appreciated!
MatthiasSolved the problem!
It's allways the same:
As soon as you ask the question the answer comes to you by itself...
I needed to add a reference to the using DC. I already did that before but not correctly:
If you want to add a reference to a j2ee application you need to read this document:
[Calling J2EE Applications from Portal Applications|http://help.sap.com/erp2005_ehp_03/helpdata/EN/42/9ddf20bb211d72e10000000a1553f6/frameset.htm]
It says the reference has to look like this:
<property name="SharingReference" value="SAPJ2EE::sap.com/Hello"/>
I hope it helps someone. -
JNDI lookup from a Java stored proc?
Anybody know if a JNDI lookup, or accessing an EJB from a Java stored procedure is possible? I looked through all the docs and it says it is possible but doesn't specify how. In the java class thats resolved through the stored proc, how are the server generated classes and interfaces made available? Normally setting the classpath for the client app that does the lookup accomplishes this, but what if its called through the stored proc?
check the rdbms platform's "javavm" folder for a "readme.txt" file ...
In section 3.16.9, it discusses how to do this ... -
How to use Action listener from Static method
Hello,
I am begginer in Java. I am trying to add JButton and add ActionListener to it in the Java tutorial example (TopLevelDemo).
The problem i am facing are:
1. Since "private static void createAndShowGUI" method is static I cannot reference (this) in the method addActionLisetener when trying to add the JButton
JButton pr = new JButton("Print Report");
pr.addActionListener(this);
2. If I make "private static void createAndShowGUI" a non static method then it does not run from main method giving me the error(cannot reference non-static).
3. Where do I put actionPerformed method?
I did not post the errors for all situations. Just asking how I can Add JButton and add ActionListener to it in the following code
Thanks
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/* TopLevelDemo.java requires no other files. */
public class TopLevelDemo {
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("TopLevelDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create the menu bar. Make it have a cyan background.
JMenuBar cyanMenuBar = new JMenuBar();
cyanMenuBar.setOpaque(true);
cyanMenuBar.setBackground(Color.cyan);
cyanMenuBar.setPreferredSize(new Dimension(200, 20));
//Create a yellow label to put in the content pane.
JLabel yellowLabel = new JLabel();
yellowLabel.setOpaque(true);
yellowLabel.setBackground(Color.yellow);
yellowLabel.setPreferredSize(new Dimension(200, 180));
//Set the menu bar and add the label to the content pane.
frame.setJMenuBar(cyanMenuBar);
frame.getContentPane().add(yellowLabel, BorderLayout.CENTER);
//Display the window.
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}Here is one way of doing it...
JButton btn = new JButton("Click on Me");
btn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
// do something
}});here we create an anonymous inner class ActionListener and add it to our button...
- MaxxDmg...
- ' I am not me... ' -
Using a lookup from one CSV file to another CSV file errors with a name clash
Hi
I have a master CSV file created by querying the AD. I need to populate the "Team" attribute by doing a lookup using Name against the Name Column any of 6 CSVs, someone has prepared for me . The problem is the data is inconsistent
in the 6 CSV files so Name can hold either the Name or Username i.e. SAmAccountName or LoginName
Now my ps script works when the data is good. but I have around 30 exception cases whereby there is a mismatch . To explain:
is in this line ( see the big code block below)
$userObject = $nameAndTeamCsvData | Where-Object {$_.Name -eq $masterUserName}
The $_.Name is using the top level masterCSVData Name but I was hoping that it was using the
$nameAndTeamCSVData.Name as in only within the scope of the Where-Object {} ..I guess I have misunderstood the syntax of what I had written.
. A quick a dirty fix would be rename this column in all of the 4 spreadsheets or trying to fix the code.....
# now update the empty team value for user object
$csvMasterData | ForEach-Object `
$masterName = $_.Name
$masterUserName = $_.Username # to deal with exception cases
#force scope to as the properties in the outer with the same name should be out of scope
# lookup the Name to see if we can extract the user's Team
$userObject = $nameAndTeamCsvData | Where-Object {$_.Name -eq $masterName }
# deal with the situation where the name in the businesses spreadsheets is actually the Username (login name) in the master csv
if ( $userObject -eq $null )
# lookup the username (loginname) to see if we can extract the user's Team # !!!!error occurs here with the $_.Name !!!!!
$userObject = $nameAndTeamCsvData | Where-Object {$_.Name -eq $masterUserName}
if ( $userObject -eq $null )
$_.Team = "UNKNOWN"
else
# replace the mastercsv.Team with the one we have looked up
$_.Team = $userObject.Team
else
# Name matches so replace the mastercsv.Team with the one we have looked up
$_.Team = $userObject.Team
DanielI see your challenge. How about collecting the column names in an array and looking for the potential names? Following my example before, try this:
$dataColumns = $I | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name
Now, you can loop through the names and collect the appropriate data.
if ($dataColumns.Contains('Column1'))
#add ForEach-Object { $_.Column1... }
HTH
~fr3dd
Hi I had to wait until Friday as I have someone ( my boss) checking the business & team csv files against valid usernames and names.
# now update the empty team value for user object
$nameAndTeamCsvData | ForEach-Object `
$nt_name = $_.Name
# $masterUserName = $_.Username # to deal with exception cases
# lookup the Name to see if we can extract the username and mobile from the masterCSV
$userObject = $null # Replace my original code: $csvMasterData | Where-Object {$_.SName -eq $nt_name } # with foreach code below
$uo = $null
foreach ($uo in $csvMasterData)
if ($uo.SName -eq $nt_name)
$userObject = $uo
# ouch can't break out of this even though I found it so have to move on to the next
}if ( $userObject -ne $null ){ # Name matches so replace the few propeerties in mastercsv.Team with the ones we have looked up
$_.Username =$userObject.SamAccountName
$_.Mobile =$userObject.Mobile
This does work but is clearly not very efficient since I don't think I can
break or exit out of the foreach loop. I am thinking I could quickly modify and add your code - my import is delayed as I am having a new property added to user class... Let me know what you think. -
JNDI lookup from proxied applet is slow
Hi,
I am doing a t3s lookup for an EJB from an applet. The lookup is fairly fast (<
1 sec) if the browser is
setup to not use an HTTP proxy server. However, if the browser is setup to go
via a proxy server, the
t3s lookup takes upwards of 30 seconds.
Running the Weblogic server with -Dweblogic.system.enableReverseDNSLookups=false
makes
no difference.
I am using WLS5.1SP9, and Netscape 4.7 and IE5 browsers.
Any suggestions, please?
Thanks
RaviYour File-system Object Store should be in a place
accessible by your client application. Then you can
specify JNDI properties
java.naming.factory.initial
java.naming.provider.url
for the initial context. There are examples in
<install-directory>/examples/jms directory.
The ConnectionFactory object you created should
have broker hostname and port (if not default)
specified.
amy -
Using a variable from another method within another method
I have a couple methods. In the beginning of the class I declared the double variables. Then I have a method1 that in that class that changes those double variables. Then the last method2 runs, and is suppose to print information to the screen with the changed variable information all being called from another class. How do I get those changed double variables to be read in method2?
Sorry about all that, when I paste it in from the compiler it's skews it some, but hopefully this should be more readable
* Project Filename: Lab1s2
* Program Filename: Lab1s2.java
* I/O Files used:
* Fuction: This program will use interactive input to ask cost of a
* product in dollars and cents (eg. 17.50). If the product
* is not less than $100.00, an error message will be displayed
* and input will be requested again. Once a valid value is
* given, the program will calculate the fewest bills and change
* to be returned if the customer gives a $100.00 bill.
* Formulas: (100 - amount = change)
* Algorithm:
* Purpose: The main method calls other methods found in the MoneyXX class
* that will accomplish the function of the project.
public class Lab2sl
public static void main( String[] args ) // main method begins program execution
Money2sl myMoney2sl = new Money2sl(); // create myMoney2sl object and assign it to Money2sl
myMoney2sl.inputSL();// calls input method and pass argument
myMoney2sl.changeSL(); // calls change method
System.out.println(); // output a blank line
myMoney2sl.outputSL(); //calls outputSL to show results
* Project Filename: Money2SL.java
import java.util.Scanner;
import java.util.Calendar;
public class Money2sl
Scanner input = new Scanner( System.in ); // create Scanner to obtain input from command window
private double change,
amount; // instant variable, stores amount
private double twentyD = 20.00;
private double tenD = 10.0;
private double fiveD = 5.0;
private double dollar = 1.0;
private double quarter = 0.25;
private double dime = 0.10;
private double nickel = 0.05;
private double penny = 0.01;
private double numTwentyD;
private double numTenD;
private double numFiveD;
private double numDollar;
private double numQuarter;
private double numDime;
private double numNickel;
private double numPenny;
// inputSL() method gets amount, checks to see if it is under $100, stores amount into variable
public void inputSL() //input method
Calendar dateTime = Calendar.getInstance(); // get current date and time
//print date and time
System.out.printf( "%s\n", "nothing" );
System.out.printf( "%1$ta, %1$tB. %1$te, %1$tY %1$tr\n\n", dateTime );
//print output
System.out.println( "Please enter the amount of money (less than $100) that you will spend: "); // prompt
amount = input.nextDouble();
while ( amount > 100 )
System.out.println( "error - enter amount less than $100");
System.out.println( "Please enter the amount of money (less than $100) that you will spend: "); // prompt
amount = input.nextDouble();
} // end inputSL method
// changeSL() calculates change from amount entered out of $100
public void changeSL()
change = 100 - amount; // calculate change
while(change > 0)
if ( change - fiveD >= 0 )
numFiveD ++;
change -= fiveD;
if ( change - fiveD >= 0 )
numFiveD ++;
change -= fiveD;
if ( change - dollar >= 0 )
numDollar++;
change -= dollar;
if ( change - quarter >= 0 )
numQuarter ++;
change -= quarter;
if ( change - dime >= 0 )
numDime ++;
change -= dime;
if ( change - nickel >= 0 )
numNickel ++;
change -= nickel;
if ( change - penny >= 0 )
numPenny ++;
change -= penny;
} // end changeSL method
//outputSL() displays original amount, change dollar amount, and change in individual bills and coins
public void outputSL()
System.out.printf( "$%.2f dollars will return $%.2f, which is: ",
amount, change );
System.out.println(); // blank line
System.out.println(); // blank line
if ( numTwentyD > 0 )
if ( numTwentyD > 1)
System.out.println( numTwentyD + " twenty dollar bills" );
System.out.println( numTwentyD + " twenty dollar bill" );
if ( numTenD > 0)
if ( numTenD > 1 )
System.out.println( numTwentyD + " ten dollar bills" );
System.out.println( numTwentyD + " ten dollar bill" );
if ( numFiveD > 0)
if ( numFiveD > 1 )
System.out.println( numFiveD + " five dollar bills" );
System.out.println( numFiveD + " five dollar bill" );
if ( numDollar > 0)
if ( numDollar > 1 )
System.out.println( numDollar + " one dollar bills" );
System.out.println( numDollar + " one dollar bill" );
if ( numQuarter > 0)
if ( numQuarter > 1 )
System.out.println( numQuarter + " quarters" );
System.out.println( numDollar + " quarter" );
if ( numDime > 0)
if ( numDime > 1 )
System.out.println( numDime + " dimes" );
System.out.println( numDime + " dime" );
if ( numNickel > 0)
if ( numNickel > 1 )
System.out.println( numNickel + " nickels" );
System.out.println( numNickel + " nickel" );
if (numPenny > 0)
if ( numPenny > 1 )
System.out.println( numPenny + " pennies" );
System.out.println( numPenny + " penny" );
} -
JNDI lookup from OC4J to weblogic throws javax.naming.NameNotFoundException
Hi All,
We have the below setup in our production environment.
EJB application is deployed in the Weblogic 10.3.4.0 Server on Sun Solaris. The EJB version is 3.0
OC4J 10.2.0 is running on another Sun Solaris machine.
There are 2 webservice applications WEBSERV1 & TestSoapEJB running on this OC4J container.
We need to do lookup the EJBs deployed on the Weblogic server. For this we used the below logic in the web service's Stateless session bean:
String weblogicURL = "";
Properties props = new Properties();
try
props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("wl.properties"));
weblogicURL = props.getProperty("weblogicURL");
catch (FileNotFoundException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.SECURITY_PRINCIPAL,"weblogic");
ht.put(Context.SECURITY_CREDENTIALS,"weblogic654");
ht.put(Context.PROVIDER_URL, weblogicURL);
ctx = NamingManager.getInitialContext(ht) ;
// tried using //ctx = new InitialContext(ht); same behavior.
TestEJB.AdministratorEJB ejb = (TestEJB.AdministratorEJB) ctx.lookup("TestEJB#TestEJB.AdministratorEJB");
ctx.close();
When we first test first WEBSER1, the lookup is fine.
But when we test the second webservice WEBSER2, the webservice name itself not able to lookup: It gives the below error:
javax.naming.NameNotFoundException: remaining name: env/TestSoapEJB
Below is the stack throws thrown on browser:
500 Internal Server Error
javax.naming.NameNotFoundException: remaining name: env/TestSoapEJB
at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:39)
at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:59)
at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:59)
at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:64)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)
at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at oracle.j2ee.ws.SessionBeanRpcWebService.init(SessionBeanRpcWebService.java:65)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpApplication.loadServlet(HttpApplication.java:2354)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpApplication.findServlet(HttpApplication.java:4795)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2821)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:680)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
at java.lang.Thread.run(Thread.java:662)
It seems that, the OC4J is looking in Weblogic context. But it should be looking in its own context. How to resolve this issue.
The same case happens if i restart the OC4J and first test the TestSoapEJB the lookup is fine . But if i test the WEBSERV1 , it throws the same error as above. In short, if one of the webservices lookup is working fine, the other webservice is not working. At the same time only one webservice's lookup is working.
Kindly help me to resolve this issue.
regards,
Zia
Edited by: PT Expert on Sep 9, 2012 3:16 AMI work now more that two days on this error!!!
-> I remade my complete jdev project, it did not work!
-> I deleted the jdev/system/j2ee/oc4j/workspace dir
-> I search for some .lock files
-> and many more tries!!! But without success...
Is there a way to reset the Embedded OC4J?
Maybe you are looking for
-
Computer turns itself on every day at 8PM PLEASE HELP
Hi I have an imac running 10.5.4. It turns itself on every day at 8PM. My auto on setting are unselected in the power options, and the auto off is set to 1:30 AM. I am also running windos xp with VM Fusionware. Can anyone please help? Thanks
-
Is there a standard report or transction code to get Moving Average Price for Spare Parts?
-
Hi! please see the attached screenshot. The outside of the stroke curve is smooth, but the inside is really bumpy and rough, even though there are only three anchor points. It prints that way too; it's not just the monitor. Could someone tell me how
-
Audio sync lost from AE to Encore.
I'm using AE6 with a 23.976 timeline with audio that is correctly synced in the timeline. I render using the Blueray presets and import the resulting audio and video files into encore dropping them into a new timeline. This is a full feature length
-
I have an issue since the upgrade to iOS 7 where I can send iTexts to all other contacts with iPhones except my wife if she is not on our home wireless network. She cannot send to me either when off the wireless network but can also send to everybody