Denise Smith

Ranch Hand
+ Follow
since Jul 26, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Denise Smith

We're using container managed security with AD. everything works great but now we'd like to use that same registry to obtain other registry attributes. We'd like to find away to use something on the server like a url provider that can be set up. We know we can write java code to make a new initial context like so:

env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
// set security credentials, note using simple cleartext
// authentication
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, adminName);
env.put(Context.SECURITY_CREDENTIALS, adminPassword);
// connect to my domain controller
env.put(Context.PROVIDER_URL, url);
ctx = new InitialLdapContext(env, null);

But...we would either like to use a url provider that is set up on the server or access the directory that is already set up on the server for our authentication and authorization. Can someone help me to find out how to make a context from a url provider declared on the server ( i can do a jndi lookup to the provider but I don't know how to make the context from that) or tell me how to use what is already on the server to make a new context like the code above)
13 years ago
Here is my init method of the servlet: this executes the class ReadMail and the method scheduleJob();

*/
public void init(ServletConfig arg0) throws ServletException {
// TODO Auto-generated method stub

//Use the schedule() method of the java.util.Timer class:
ServletContext sc = arg0.getServletContext();


System.out.println("Initializing Scheduler for Notifications");
long now = System.currentTimeMillis();
long millisecondsInFuture = 30000 ;
Date whenToRun = new Date(now + millisecondsInFuture);
Timer timer = new Timer();
TimerTask task = new TimerTask() {
public void run() {
// job code here
String[] args = {};
try {
ReadMail.main(args);
scheduleJob();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}
};
timer.schedule(task, whenToRun);
}


ReadMail workds great(there are no data access beans in this class)
the scheduleJob(); starts to run but as soon as it hits tries to get the datasource it errors with the error provided previously.

here is the the Try block that cathes the Naming exception:

try {

select.setDataSourceName((String)new InitialContext().lookup("java:comp/env/espConn"));

select.setCommand("some select statement");
DBParameterMetaData parmMetaData = ParameterMetaData();
parmMetaData.setParameter(1, "somevariable",
java.sql.DatabaseMetaData.procedureColumnIn,
java.sql.Types.CHAR, String.class);
}


can anyone help me???

If I run my code without spawning a new thread it works
16 years ago

Originally posted by John Meyers:


I am not sure I follow. You have 2 JNDI contexts ? If the scheduler has access to the same JNDI that the name is bound to, there should be no problem accessing the bound object



actually...the thread code doesn't know the context information and I don't know how to tell it.
when I setDataSourcename this is the error I get

select.setDataSourceName((String)new InitialContext().lookup("java:comp/env/espConn"));

[6/23/08 12:10:40:562 EDT] 0000003c SystemErr R javax.naming.NameNotFoundException: Name "comp/env/espConn" not found in context "java:".
at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1094)
at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:990)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1263)
at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:201)
at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:142)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
at net.ongov.esp.resources.LocalExamSeriesForExamPostedToday.initializer(LocalExamSeriesForExamPostedToday.java:44)
at net.ongov.esp.resources.LocalExamSeriesForExamPostedToday.<init>(LocalExamSeriesForExamPostedToday.java:27)
at net.ongov.esp.resources.ScheduledExamNotification.scheduleJob(ScheduledExamNotification.java:100)
at net.ongov.esp.resources.ScheduledExamNotification$1.run(ScheduledExamNotification.java:316)
at java.util.TimerThread.mainLoop(Timer.java:447)
at java.util.TimerThread.run(Timer.java:397)


Any suggestions? how can I get the context that the servlet is using
16 years ago

Originally posted by Murthy Tanniru:
may be the scheduler in a different context



I think Murthy may be correct I spawned a new thread in the init() method of a load on start up servlet. That thread is outside the current context.
16 years ago
This servlet works if I start it manually after the server has stated but not with a scheduler in the servlet. The schduler starts the job. but the job fails with this error.

[6/20/08 15:17:06:016 EDT] 0000002a SystemErr R com.ibm.db.beans.DBException: Unexpected error; javax.naming.NameNotFoundException: Name "comp/env/espConn" not found in context "java:".
at com.ibm.db.beans.DBException.getSQLException(DBException.java)
at com.ibm.db.beans.DBSelect.execute(DBSelect.java)
at net.ongov.esp.resources.ExamPostedTodayByJobtitle.execute(ExamPostedTodayByJobtitle.java:45)
at net.ongov.esp.resources.ScheduledExamNotification.scheduleJob(ScheduledExamNotification.java:104)
at net.ongov.esp.resources.ScheduledExamNotification$1.run(ScheduledExamNotification.java:308)
at java.util.TimerThread.mainLoop(Timer.java:447)
at java.util.TimerThread.run(Timer.java:397)

Why can't the job find the db resource reference name when it starts on it's own?
16 years ago
The target attribute of <h:commanLink> has never worked for me-maybe it has to do with the version of jsf that I'm using. Either way...Try this it works for me...
On the command link itself... add an onmousedown like so-->
<h:commandLink styleClass="commandLink" id="CheckLnk"
action="#{pc_ADet.doCheckLnkAction}"
onmousedown="document.forms['YOUR_FORM_NAME_GOES_HERE'].target='_blank';">
<h:outputText id="CheckTxt"
styleClass="outputText" value="Report">
</h:outputText>
</h:commandLink>

Let me know if this meets your needs!
16 years ago
JSF
Hi,

I have a datatable that I want to set the rowclasses based on data that is in the rows
for example: if a hava a column named number and the first one is 5 I want that row to be style class1. If the next row matches that number I want it to have the same rowclass(class1) if the number is different say 8 I want it to have a different rowclass (class2) so that all consequtive numbers have the same rowclass. My problem is not with the logic but rather with setting the rowclass.

The following method is in a column in my datatable

/**
* @return Returns the rowClass.
*/
public String getRowClass() {

String s = String.valueOf(getValue("#{varPerson['NUM']}"));

if (s != null && (s.compareTo(getNewCcn())==0)) {


} else {

if(rowClass.compareTo("rowClass1")==0){
rowClass="rowClass2";
}else if(rowClass.compareTo("rowClass2")==0){
rowClass="rowClass1";
}
}

setNewCcn(s);

return rowClass;
}
16 years ago
JSF
You mean like--generate your own faces error and use a message bundle for the error message??
//method
protected void getBundleMsgSetError(String key) {
// Look up the requested message text

try {
ResourceBundle bundle = ResourceBundle.getBundle(
"some.prop.file.Msgs", getFacesContext()
.getViewRoot().getLocale());
text = bundle.getString(key);
} catch (Exception e) {
}
// Construct and add a FacesMessage containing it
getFacesContext().addMessage("",
new FacesMessage(FacesMessage.SEVERITY_ERROR, text, text));
}

//or just make a new Faces message when you need to:

getFacesContext().addMessage(
"",
new FacesMessage(FacesMessage.SEVERITY_ERROR,
getMsg(), getMsg()));
16 years ago
JSF
Does your web.xml file have a url mapping for the faces servlet?

Sample:

<servlet id="Servlet_100">
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>-1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
[ December 12, 2007: Message edited by: Denise Smith ]
16 years ago
JSF
so how are developers redirecting thier uses to login pages when the session timesout?
17 years ago
JSF
using jsf how can I test to see if a session has expired? I can test for a new session how do I test toi see if a session is no longer available??

Seems like this should be easy:

ExternalContext ec = facesContext.getExternalContext();

Object requestObject = ec.getRequest();
HttpServletRequest req = (HttpServletRequest) requestObject;
session = req.getsession();
if(session.------now what)
17 years ago
JSF
Are you using an IDE? If so which one??
17 years ago
JSF
simply:

<jsp:include page="fileName.jsp"flush="false">
<jsp:param name="ParmName" value="#{param.pName}" /></jsp:include>
[ August 27, 2007: Message edited by: Denise Smith ]
17 years ago
JSF
Add to web.xml


<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

then make the request like this
http://localhost/applicationName/faces/fileName.jsp

of course substitute the appropriate names for your server/application/fileName
17 years ago
JSF
To set up the page to login to you have to be sure to include the faces servlet in the form-login-page


<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/faces/loginDo.jsp</form-login-page>
<form-error-page>/errMsgs/loginEmsg.jsp</form-error-page>
</form-login-config>
</login-config>
17 years ago
JSF