Getting NULL for ctx.lookup
Hi,
I was creating a HTTP destination but getting below exception.
OUTPUT:
Start line
ctx : javax.naming.InitialContext@f32b694
Completed Step 1
tc~sec~destinations~service
Completed Step 2
Inside if of dstService
com.sap.engine.services.jndi.persistent.exceptions.NamingException: <--Localization failed: ResourceBundle='com.sap.engine.services.jndi.persistent.JNDIResourceBundle', ID='Destination Service not available', Arguments: []--> : Can't find resource for bundle java.util.PropertyResourceBundle, key Destination Service not available
at Client.main(Client.java:46)
below is the code. I think the code is not getting destination service object from server. What is the step to add "destinationservice" in SAP NW 731 portal?
import java.rmi.RemoteException;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import com.sap.engine.services.jndi.persistent.exceptions.NamingException;
import com.sap.security.core.server.destinations.api.DestinationException;
import com.sap.security.core.server.destinations.api.DestinationService;
import com.sap.security.core.server.destinations.api.HTTPDestination;
public class Client {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
env.put(Context.PROVIDER_URL, "<HostName>:<P4_port>");
env.put(Context.SECURITY_PRINCIPAL, "<user>");
env.put(Context.SECURITY_CREDENTIALS, "<password>");
try{
System.out.println("Start line");
Context ctx = new InitialContext(env);
System.out.println("ctx : " +ctx.toString());
System.out.println("Completed Step 1");
System.out.println(DestinationService.JNDI_KEY);
DestinationService dstService = (DestinationService)ctx.lookup(DestinationService.JNDI_KEY); //getting null at this line
System.out.println("Completed Step 2");
if (dstService == null){
System.out.println("Inside if of dstService");
ctx.close();
throw new NamingException("Destination Service not available");
//Note: this only created the destination
//it needs to be stored using dstService.storeDestination
System.out.println("Completed Step 4");
HTTPDestination destination = (HTTPDestination)
dstService.createDestination("HTTP");
destination.setUrl("http://<host>:<HTTP_port>");
destination.setName("UMEConnection");
destination.setUsernamePassword("<userName>", "<password>");
dstService.storeDestination("HTTP", destination);
}catch(DestinationException | RemoteException | javax.naming.NamingException e){
e.printStackTrace();
The ctx is coming as null.
Hi Hamendra,
Even after hard coding DestinationService.JNDI_KEY to tc~sec~destinations~service in the code, I am getting dstService = null.
Is there anything else I need to change in SAP portal NWA?
Is there any way to check the destination services that are available in SAP Portal?
Thanks
Alingan Patra
Similar Messages
-
Get null for OTNDeptEmp DEPT/EMP Live Web Service
Using Oracle 9i JDeveloper Vers. 9.0.2.829. Has anyone successfully run this live web service with a proxy?
I made the changes to OTN.DeptEmpStub for proxy but when I run Class1.java the returnVal for getDeptNoArray is null
so I assume I'm not getting out our firewall or back through? Is there any way to test to see how far I'm getting or any clues as to
what is wrong??? I eventually get this error --- java.lang.NullPointerException
void mypackage1.Class1.main(java.lang.String[])Thanks Mike - this got me further but now I get?? Any clues or should I email [email protected]?
D:\jdeveloper\jdk\bin\javaw.exe -ojvm -classpath D:\jdeveloper\jdev\mywork\Workspace1\Project1\classes;D:\jdeveloper\jdev\lib\jdev-rt.jar;D:\jdeveloper\soap\lib\soap.jar;D:\jdeveloper\lib\xmlparserv2.jar;D:\jdeveloper\jlib\javax-ssl-1_2.jar;D:\jdeveloper\jlib\jssl-1_2.jar;D:\jdeveloper\jdk\jre\lib\ext\activation.jar;D:\jdeveloper\jdk\jre\lib\ext\mail.jar;D:\jdeveloper\j2ee\home\lib\http_client.jar;D:\jdeveloper\lib\xmlparserv2.jar;D:\jdeveloper\lib\xmlcomp.jar -Dhttp.proxyHost=proxy.scott.af.mil -Dhttp.proxyPort=375 mypackage1.Class1
Example 1 - Department numbers
Got this far
Got into getDeptNoArray
after setSoapTransport
after setTargetObjectURI
[SOAPException: faultCode=SOAP-ENV:Protocol; msg=Unsupported response content type "text/html; charset=iso-8859-1", must be: "text/xml". Response was:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>500 Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error</H1>
The server encountered an internal error or
misconfiguration and was unable to complete
your request.<P>
Please contact the server administrator,
[email protected] and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.<P>
More information about this error may be available
in the server error log.<P>
<HR>
<ADDRESS>Oracle HTTP Server/1.3.22 Server at otn.oracle.com Port 7790</ADDRESS>
</BODY></HTML>
java.lang.String org.apache.soap.rpc.Call.getEnvelopeString(org.apache.soap.transport.SOAPTransport)
org.apache.soap.rpc.Response org.apache.soap.rpc.Call.invoke(java.net.URL, java.lang.String)
java.lang.String[] mypackage1.OTNDeptEmpStub.getDeptNoArray()
void mypackage1.Class1.main(java.lang.String[])
Process exited with exit code 0. -
Getting null for getRealPath.
Hi All,
Having 'resources' folder under WEB-INF folder, whiile trying to get RealPath it is returning 'null' value in basePath variable.
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().
getExternalContext().getSession(true);
String basePath = session.getServletContext().getRealPath("/WEB-INF/resources");
Please let me know how to get real path in JSF.
Thanks,
Sharath.It's an appserver thing. It will return null when the WAR is not extracted and also in some Weblogic configs/environments it will always return null regardless of WAR setup. This is not related to JSF.
Not related to your actual problem, but just a cosmetic hint, the getSession(true) is superfluous with a hardcoded boolean "true", just use getSession(). Further on, instead of HttpSession#getServletContext(), you can also get the ServletContext directly by ExternalContext#getContext(). -
How can I get null values for the later weeks
Hi All,
When I execute this code I get the records till current week.
How can I display the output so that I get null values for the later weeks. (with the help of v_numOfWeeks variable in the code)
Thanks,
Vikram
DECLARE
v_query VARCHAR2(4000);
TYPE ref_cursor IS REF CURSOR;
v_refcur ref_cursor;
v_sum NUMBER;
v_id NUMBER;
v_name VARCHAR2(1000);
v_weeknum NUMBER;
v_pernum NUMBER;
v_numOfWeeks NUMBER := 5;
BEGIN
v_query := ' SELECT SUM(product_bkg), postn_id, postn_tbl.postn_name, b.week_num, b.period_num
FROM ops_cv_extract b, (SELECT row_id, desc_text postn_name
FROM s_postn) postn_tbl
WHERE lvl_6_id = 5767
AND fiscal_year = 2008
AND b.week_num < 4
AND b.period_num = 3
AND b.postn_id = TO_NUMBER(postn_tbl.row_id)
GROUP BY postn_id, postn_tbl.postn_name, b.week_num, b.period_num
ORDER BY postn_tbl.postn_name, b.week_num';
OPEN v_refcur FOR v_query;
LOOP
FETCH v_refcur INTO v_sum, v_id, v_name, v_weeknum, v_pernum;
EXIT WHEN v_refcur%notfound;
dbms_output.put_line('P'|| v_pernum||'W'|| v_weeknum||' '||v_name||' '||v_sum);
END LOOP;
END;
This is the output when I execute this code.
P3W1 COMM CNTRL ISAM 213 26961.61
P3W2 COMM CNTRL ISAM 213 12870.4
P3W3 COMM CNTRL ISAM 213 245.88
P3W1 COMM CNTRL ISAM 273 72831.2
P3W2 COMM CNTRL ISAM 273 8739.38
P3W3 COMM CNTRL ISAM 273 3764.92
P3W1 COMM CNTRL TAM 213 49844
P3W2 COMM CNTRL TAM 213 20515.17
P3W3 COMM CNTRL TAM 213 16167.46
P3W2 COMM CNTRL TAM 216 12561.4
P3W3 COMM CNTRL TAM 216 2027.1
P3W1 COMM CNTRL TAM 273 -3336.71
P3W2 COMM CNTRL TAM 273 -1376.68
P3W3 COMM CNTRL TAM 273 19707.42
P3W1 Damon Walters -609.07
P3W2 Damon Walters 30030.24
P3W3 Damon Walters 37475.1
This is the output I'd like to get
P3W1 COMM CNTRL ISAM 213 26961.61
P3W2 COMM CNTRL ISAM 213 12870.4
P3W3 COMM CNTRL ISAM 213 245.88
P3W4 COMM CNTRL ISAM 213
P3W5 COMM CNTRL ISAM 213
P3W1 COMM CNTRL ISAM 273 72831.2
P3W2 COMM CNTRL ISAM 273 8739.38
P3W3 COMM CNTRL ISAM 273 3764.92
P3W4 COMM CNTRL ISAM 273
P3W5 COMM CNTRL ISAM 273
P3W1 COMM CNTRL TAM 213 49844
P3W2 COMM CNTRL TAM 213 20515.17
P3W3 COMM CNTRL TAM 213 16167.46
P3W4 COMM CNTRL TAM 213
P3W5 COMM CNTRL TAM 213
P3W1 COMM CNTRL TAM 273 -3336.71
P3W2 COMM CNTRL TAM 273 -1376.68
P3W3 COMM CNTRL TAM 273 19707.42
P3W4 COMM CNTRL TAM 273
P3W5 COMM CNTRL TAM 273
P3W1 Damon Walters -609.07
P3W2 Damon Walters 30030.24
P3W3 Damon Walters 37475.1
P3W4 Damon Walters
P3W5 Damon Walters Edited by: polasa on Oct 28, 2008 6:42 PMSure, in a Single SQL ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.01
satyaki>
satyaki>
satyaki>-- Start Of Test Data --
satyaki>with week_tab
2 as
3 (
4 select 1 period_num, 1 week_num, 10 bkg1 from dual
5 union all
6 select 1, 2, 40 from dual
7 union all
8 select 1, 3, 30 from dual
9 union all
10 select 1, 2, 20 from dual
11 union all
12 select 1, 1, 10 from dual
13 union all
14 select 1, 1, 20 from dual
15 union all
16 select 1, 3, 10 from dual
17 union all
18 select 2, 1, 15 from dual
19 union all
20 select 2, 2, 20 from dual
21 union all
22 select 2, 3, 10 from dual
23 union all
24 select 2, 1, 15 from dual
25 union all
26 select 2, 2, 30 from dual
27 union all
28 select 2, 3, 20 from dual
29 )
30 -- End Of Test Data --
31 select period_num,
32 week_num,
33 (
34 select sum(week_tab.bkg1)
35 from week_tab
36 where period_num = m.period_num
37 and week_num = m.week_num
38 group by week_num, period_num
39 ) sum_bkg1
40 from (
41 select dum.week_num,
42 wk.period_num
43 from (
44 select 1 week_num from dual
45 union all
46 select 2 from dual
47 union all
48 select 3 from dual
49 union all
50 select 4 from dual
51 union all
52 select 5 from dual
53 ) dum ,
54 (
55 select distinct period_num
56 from week_tab
57 ) wk
58 ) m;
PERIOD_NUM WEEK_NUM SUM_BKG1
1 1 40
1 2 60
1 3 40
1 4
1 5
2 1 30
2 2 50
2 3 30
2 4
2 5
10 rows selected.
Elapsed: 00:00:00.48
satyaki>Regards.
Satyaki De. -
Getting null value for inputfile component in the popup
Hi,
My requirement is when i select the selectBooleanCheckBox a popup has to be rendered and with in that popup i have to display the inputfile component when i browse it should read the appropriate file.
But i am getting null from the input file component.
I written the code like this:-
1.First i have written a value change listener for the selectBoolenCheckBox.
2.I am rendering the popup from the valueChageEvent.
3.And i written the dialogListener for the Dialog in the popup.
and the code for the Dilog listener is:--
public void readingInputFile(DialogEvent dialogEvent) {
inputFile1.getValue();
//it is giving null value.
thanks in advance.
From
Srikanth.Vthanks for giving suggestion.
but i am not able to understand what meant by multipart in dialog page.
Actually,The code i written was:--
1. for selectBooleanCheckBox i written value chage listener
onChangeValue(ValueChageEvent valueChageEvent){
// in this i call the method to raise popup;
risePopUp();
2.The popup structure has follows:-
af:form --> af:popup ---> af:dialog --->af:inputfile
for this dialog i have written dilogListener:
getInputFile(DialogEvent dialogEvent){
//giving null for the inputFile,getValue();
for this dialog i don't have any multipart property
From, -
Why am I getting the error "Coercion Failed: Input cannot be null for this coercion"?
I created a OOTB team site, with a OOTB document library and an OOTB "Approval - SharePoint 2010" workflow. Under the workflow's start options I have "Allow this workflow to be manually..." checked. On the next workflow setup page, I put
myself in the Assign To field and put "test" in the Request field. I left everything else blank.
Then, I setup a retention stage in the Information Management Policy settings for the library. The event is Modified + 1 days, action is Start a workflow and I selected the workflow described above. I set the Recurrence for 1 days.
If I execute the workflow manually, it executes without error.
When the IMP executes the workflow, the status indicated in the column added to the library is "Canceled". Clicking on the Canceled link opens the Workflow Information. In the Workflow History section the Event Type is Error, User ID is System
Account and Description is "Coercion Failed: Input cannot be null for this coercion".
Research shows that this error can be invoked when creating custom workflows that contain empty input fields when executed. I would think that if there were required input fields in the workflow
configuration, that the workflow would error when manually executed.
Any help is appreciated. Thank you.
Matt H.I had found that article previously but it doesn't seem to apply since this is OOTB and not a workflow created in SD. I would expect that MS would have created the workflow in such a manner that it would work with IMP. Besides, I don't think
it's possible to edit the default Approvers workflow. Also, I'm sure I'm not the first one out there to use the Approvers workflow with IMP. If it was broken OOTB, someone else would have discovered it. My guess is that there is something
not configured correctly on the server, but I don't know how to start to diagnose it based on this error message.Matt H. -
Getting tasks for all users in a role
Hi,
We need to get all users in a Role, and out of those, find out which one has the least tasks in their UWL using a WebService. Saw some example codes and here's my attempt at it. Doesn't quite work, I'm getting the Logged in users context or session doesn't exist Exception. Any help on this will be GREATLY appreciated.
public class LeastTasksBean implements LeastTasksLocal {
public String getUserLeastTasks( String sRole )
try{
Map<String, String> users = new HashMap<String, String>();
Map<String, String> tasks = new HashMap<String, String>();
final int sessionIdleTimeout = 60;
String Users[] = UMFactory.getRoleFactory().getUsersOfRole( sRole, true );
if( Users != null ){
for( int i = 0; i < Users.length; i ++ ){
UWLContext uwlContext = new UWLContext();
IUWLService uwlService = findService();
uwlContext.setAllowBackEndConnections( true );
IUser uwlContextUser = UMFactory.getUserFactory().getUser( Users[0] );
uwlContext.setUser ( uwlContextUser );
Locale loc = new Locale( "ES" );
uwlContext.setLocale ( loc );
HttpServletRequest request = getHttpRequest();
uwlContext.setOriginRequest ( request );
IUWLSession session = uwlService.beginSession( uwlContext, sessionIdleTimeout );
uwlContext.setSession ( session );
IUWLItemManager itemManager = uwlService.getItemManager( uwlContext );
QueryResult result = itemManager.getItems( uwlContext, null, null );
users.put( String.valueOf( i ), uwlContext.getUserName() );
tasks.put( String.valueOf( i ), String.valueOf( result.getItems().size() ) );
uwlService.endSession( uwlContext );
int userTasks = 0;
int leastTasks = Integer.valueOf( tasks.get( 0 ) );
int userKey = 0;
for( int i = 0; i < Users.length; i ++ ){
userTasks = Integer.valueOf( tasks.get( Integer.toString( i ) ) );
if( userTasks < leastTasks ){
leastTasks = userTasks;
userKey = i;
return users.get( Integer.toString( userKey ) );
else{
return "No users exist for this role";
//Exception Handling
private IUWLService findService() throws NamingException
Properties properties = new Properties();
properties.put( InitialContext.INITIAL_CONTEXT_FACTORY, "com.sapportals.portal.prt.registry.PortalRegistryFactory" );
InitialContext ctx = new InitialContext( propiedades );
IUWLService uwlService = ( IUWLService ) ctx.lookup( IUWLService.ALIAS_KEY );
return uwlService;
private HttpServletRequest getHttpRequest() throws Exception
Properties properties = new Properties();
properties.put( "domain", "true" );
ApplicationWebServiceContext wsContext =
(ApplicationWebServiceContext) new InitialContext( propiedades ).lookup( "/wsContext/" + ApplicationWebServiceContext.APPLICATION_WSCONTEXT );
HttpServletRequest request = wsContext.getHttpServletRequest();
return request;Hi David,
I have a similar requirement on our project. I need to get a count of pending workitems for all user but I'm getting similar message when I try to access UWL context of any other user.
Did you find any solution for this? Is it possible to get the workitems for all users using webservice or wendynpro?
I would appreciate if you can provide some inputs on this.
Thank you in advance.
Regards,
Seema Rane -
JNDI NameNotFoundException on ctx.lookup in WLS 6.1
Hi dear all
When deploying several entity beans in WLS 6.1 we always get a
NameNotFoundException on the ctx.lookup for each bean. The JNDI name is
defined (for every bean) in the IDE and also available in the WLS console
(i.e. also in the deployment descriptor).
Calling the ctx.lookup on the JNDI name for a DataSource defined in WLS does
not raise an NameNotFoundException but a ClassCastException on the following
"narrow" method (a DataSource object is not a bean --> so the WLS/VM runtime
environment works right).
Obviously, the JNDI names for the beans can not be determined/found
correctly because of a deployment/version problem?!
We're using JBuilder 5.0 and WLS 6.1SP1 on NT 4.0 (might be a/the problem?).
Thx in advance
MarkusThe java:comp/env namespace is specific to each individual component (i.e.,
every component can potentially see a different set of objects with different
names and/or the same objects with different names). For an EJB reference
lookup, I believe that we automatically bind it under java:comp/env/ejb so if
you specify the name of the ejb-ref as MyBeanHome in the ejb-jar.xml file, then
the EJB whose deployment descriptor contains this ejb-ref entry can look up that
referenced bean's home at java:comp/env/ejb/MyBeanHome. When you specify the
JNDI name under which a bean will be deployed, we do not automatically make that
bean home available to other beans in their respective java:comp/env/ejb
namespaces (though they are accessible via the global JNDI name used to register
the bean). To get this, you must create the ejb-ref entries and their
corresponding ejb-reference-description entries in the deployment descriptors.
Hope this helps,
Robert
Programit wrote:
Ditto. I'm experiencing the same problem.
I've spent a great deal of time working with this stuff. I believe Weblogic
is lacking in their support here. It's obvious that something isn't working
correctly, because everything was working fine before I installed WLS6.1
with SP1. In fact, I have two systems running right now: The code and
deployment descriptors are exactly the same. The System works fine in
WLS6.1. The System does NOT work in WLS6.1 SP1 becuase of these damn Naming
issues.
We've deployed with the BEA RDBMS Security Realm -- without modification.
Other than that, everything else is pretty standard. The JNDI tree on the
Weblogic console doesn't work either. It says it can resolve "comp"!!!!
"kefah Seyed" <[email protected]> wrote in message
news:[email protected]...> Hi Markus
I send this message because I have the same
problem with JNDI. My envirronment is the
same : I'm under nt 4.0 with weblogic 6.1
but I use Together 5.5 and I tried to deploy manually the EJB.
But it's always the same error.
I tried under WebSphere and with a name
like "java:comp/env/ejb-name" it work.
So I tried all I could if you have a solution now please send me amessage. -
Why ican't I find jndi.properties for TopicConnectionFactory lookup?
I have a problem with IPlanetMessageQueue3.0 . Why i can't find jndi.properties for TopicConnectionFactory lookup ? Like this Context ctx = new
InitialContext();TopicConnectionFactory tcf = (TopicConnectionFactory)ctx.lookup("TopicConnectionFactory"); What is value of
Context.INITIAL_CONTEXT_FACTORY and Context.PROVIDER_URL ( I home jmqbroker://localhost:7676 ) for default configuration ?Have you used the object manager to create the ConnectionFactory object(s) in the JNDI store? If not, you need to use the tool to create the
object(s) and store them in the JNDI server before you may use them.
There is a simple help for this in the IPlanetMessageQueue3.0 installation bin directory. In the MQ installation bin directory, type the following
command:
imqobjmgr -H
you will get examples on how to create JNDI objects and the values that you need to set up JNDI Context. -
NullPointerException using @Resource for JDBC lookup
I had the following working and am trying to convert to using @Resource and have been unsuccessful:
First I had the following working, inside a jar within an ear deployed to glassfish v3 and no sun-ejb-jar.xml file:
public CM
public CM() {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jdbc/xDataSource");
Connection conn = ds.getConnection();
When I switched to the following I get a NullPointerException when I deploy, indicating that the resource could not be found
@Stateful
public CM
@Resource(name="jdbc/xDataSource", mappedName="jdbc/xDataSource")
private DataSource ds;
public CM() {
Connection conn = ds.getConnection();
and added sun-ejb-jar.xml file to META-INF directory
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 EJB 3.1//EN"
"http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_1-0.dtd">
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>CM</ejb-name>
<resource-ref>
<res-ref-name>jdbc/xDataSource</res-ref-name>
<jndi-name>jdbc/xDataSource</jndi-name>
</resource-ref>
</ejb>
</enterprise-beans>
</sun-ejb-jar>
P.S. Sorry about not using code tags I'm not sure which tag to use to properly format it.Do you know what those authorizations should be when using a standard JDBC Lookup mapping function? Currently we have a custom UDF that calls the table via a <schema>.<table name> and the current user in the Receiver Comm Channel works just fine. It appears that when using the standard SAP JDBC Lookup function it calls the table directly and the user in the Comm Channel no longer has the correct permissions.
I would expact that the JDBC Lookup function would allow for a standard "Read" on any table as long as the user has that level of access...but not in this case. I am going to bring it up to our SAP XI software development team and see what they say, but wanted to get some views from our other experts as well.
Thanks,
Matt -
While running a report through workspace getting "Null" error
While running a report through workspace i am getting "Null" error.i have checekd the db connection and also access to hfm.
ThanksHi Raj,
There are a few OSS Notes for your issue.
If your Query has hierarchy in it then check 734184
If your query is based on Infoset then check Note 784502 and 701941.
Also check 668921.
Bye
Dinesh -
Reading and writing to file , getting null when i try to read file content
i start by apologizing incase i have posted this question in the wrong forum
i am trying to iterate through a directory tree and pick all the subdirectories and put them in an arraylist . on the other hand , i am picking all the files and putting them in a different arraylist . After that i iterate through the arraylist , pick a folder , create a file in it search for all the files of the same type in its subfolders and write them to the newly created file
The problem i am running into is i i can't read the files and hence i can't write to the file .
My directory tree is in the format
c:\KPCData\\01\01\01\01\01\ file1_type1
c:\KPCData\\01\01\01\01\02\ file2_type1
where one one of the types is "covers" . i know this could be asking too much but i am at my tethers end , could someone please have a look at the code and tell me where i might be going wrong . you could zero in on the part where i have ************ before the a line of code thank you package directories;
import java.io.*;
import java.util.*;
public class Directories {
private static ArrayList direcs= new ArrayList();
private static ArrayList census= new ArrayList();
private static ArrayList vagrant= new ArrayList();
private static ArrayList hotel= new ArrayList();
private static ArrayList emigrant= new ArrayList();
private static ArrayList traveller= new ArrayList();
private static ArrayList longform= new ArrayList();
private static ArrayList cover= new ArrayList();
private static String parentPath = null;
private static File mycover = null;
private static File mytravel = null;
private static File myemigrant = null;
private static File mylong= null;
private static File myinstitution = null;
private static File myvagrant = null;
private static BufferedReader in;
private static BufferedWriter out;
private static String read,toread;
//function for listing the folder contents
class compareDirs implements Comparator
public int compare(Object one, Object two)
int val=0;
File file1 = (File)one;
File file2= (File)two;
String name1 = file1.toString();
String name2= file2.toString();
if (name1.length()==name2.length())
val= name1.compareTo(name2);
else
if( name1.length()>name2.length())
val=-1;
if (name1.length()<name2.length())
val=1;
return val;
private ArrayList recurs(File dir,File file) throws IOException
File []files=dir.listFiles();
for(int index=0;index<files.length ;index++)
if(files[index].isDirectory())
recurs(files[index],file);
}//if
else
census.add(files[index]);
}//for index
return census;
} //recurs
//function for determining the number and paths of the folders
private ArrayList numDirs(File dirs)
File []files=dirs.listFiles();
for(int index=0;index<files.length ;index++)
if(files[index].isDirectory())
if (direcs.contains(files[index])==false)
direcs.add(files[index]);
numDirs(files[index]);
}//if
}//for index
return direcs;
public static void main(String[]args) throws IOException
File myfile = new File("C:\\KPCData");
File myfile2= new File("C:\\KPCData\test.txt");
Directories dir = new Directories();
if (myfile.isDirectory())
ArrayList myList=dir.recurs(myfile,myfile2);
ArrayList mydir1 = dir.numDirs(myfile);
ArrayList mydirs = new ArrayList();
mydirs.add(mydir1.get(0));
for (int x=0;x<mydir1.size();x++)
{ int count=0;
for (int y=0;y<mydirs.size();y++)
if (x==y)
count++;
if (count<1)
mydirs.add(mydir1.get(x));
Collections.sort( mydirs,dir.new compareDirs() );
for(int index1 =0 ;index1<mydirs.size();index1++)//print out directories
File mydir=(File)mydirs.get(index1);
File directory= (File)mydirs.get(index1);
if(!mydir.getPath().contains("00"))//// if not leave node create files for each file type
String name1 =mydir.getPath();
ArrayList ray=new ArrayList();
String name="K";
for (int index=0;index<name1.length();index++ )
if (name1.charAt(index)!='\\'&&name1.charAt(index)!='C'&&name1.charAt(index)!=':'&&name1.charAt(index)!='K'&&name1.charAt(index)!='P'&&name1.charAt(index)!='D'&&name1.charAt(index)!='a'&&name1.charAt(index)!='t')
name =name+(String.valueOf(name1.charAt(index)));
// create a string
name= name.substring(1);
String trial = name+"_cover.dat";
mycover = new File ( mydir,trial);
if (mycover.exists()) {
mycover.delete();
mycover.createNewFile();
} else {
mycover.createNewFile();
String addit = mydir.getParent().toString();
mylong = new File (addit+"\\_long.dat");
if (mylong .exists()) {
mylong.delete();
//mylong.createNewFile();
} else {
//mylong.createNewFile();
myemigrant = new File (mydir.getParent()+"\\_emigrant.dat");
if (myemigrant.exists()) {
myemigrant.delete();
// myemigrant.canWrite();
} else {
// myemigrant.canWrite();
mytravel= new File (mydir.getParent().toString()+"\\_traveller.dat");
if (mytravel.exists()) {
mytravel.delete();
// mytravel.createNewFile();
} else {
//mytravel.createNewFile();
myinstitution = new File (mydir.getParent().toString()+"\\_institution.dat");
if (myinstitution.exists()) {
myinstitution.delete() ;
// myinstitution.createNewFile();
} else {
//myinstitution.createNewFile();
myvagrant = new File (mydir.getParent().toString()+"\\_vagrant.dat");
if (myvagrant .exists()) {
myvagrant.delete();
// myvagrant.createNewFile();
} else {
//myvagrant.createNewFile();
//}//initial
for( int index2 =0;index2<myList.size();index2++)//loop the second one for individual files
File file= (File)myList.get(index2);
if (file.getParent().contains("00"))//leave node
parentPath =file.getParent().substring(0, file.getParent().length()-4);
else
parentPath =file.getParent().substring(0, file.getParent().length()-3);
if (parentPath.toString().compareTo(directory.getParent())==0&file.getName().contains("cover"))
try {
in = new BufferedReader(new FileReader(file));
out = new BufferedWriter( new FileWriter(mycover));
************ while ((read =in.readLine())!=null)
System.out.println("testing");//test whether i ever get in this section !!!
out.write(read);
out.close();
in.close();
catch(NullPointerException e)
System.out.println(e);
catch(IOException e)
System.out.println("There was a problem:" + e);
}//class Directorieskingspalace wrote:
Dr Clap
The problem i am having is that whereas i am very sure that there are contents in the files i am trying to read , this part of the code Print the Values of parentPath,directory.getParent() and file.getName() here .In the start of this if condition to get a idea what stuff is coming here.
if (parentPath.toString().compareTo(directory.getParent())==0&file.getName().contains("cover"))
{Are you trying to compare parentPath and directory.getParent() as Strings ? How about using equals() ?
Also are you aware that a single & and && are not one and the same ?
& will check nevertheless even if the string comparison on the parentPath returns true or false.
&& will not check file.getName() part if the String comparison part fails.
try {
in = new BufferedReader(new FileReader(file));
out = new BufferedWriter( new FileWriter(mycover));
************ while ((read =in.readLine())!=null)
System.out.println("testing");//test whether i ever get in this section !!!
out.write(read);
out.close();
in.close();
catch(NullPointerException e)
System.out.println(e);
catch(IOException e)
System.out.println("There was a problem:" + e);
}How about adding a simple Exception catch block here ,in case you miss anything ?
never gets executed executed (meaning ,according to the code, the files am reading have no content ). i am a bit new to files and directories in java . i am hence seeking advice on what i could be doing wrong .IN short,debugging your code will help you a lot. -
Getting null values from nodes using DOMParser
Hi
I'm having problems retrieving the values from an XML doc.
I'm using the DOMParser, but instead of retrieving the values
from the nodes, I just get null.
Code fragment :
DOMParser parser = new DOMParser();
parser.parse(url);
XMLDocument doc = parser.getDocument();
NodeList nl = doc.getElementsByTagName("*");
Node n;
iNode = nl.getLength();
for (int i=0; i<iNode; i++)
n = nl.item(i);
String szNodeName = n.getNodeName();
System.out.print(szNodeName+ " (" );
System.out.print(n.getNodeValue()+")");
System.out.println();
The result is
course (null)
Name (null)
All the node names are correct, but the node values are NOT
displayed.
Any idea ?
Rodrigo
nullAccording to the DOM Level 1 spec, the "value" of an ELEMENT node
is null and the getNodeValue() method will always return null for
an ELEMENT type node. You have to get the TEXT children of an
element and then use the getNodeValue() method in the text nodes.
Oracle XML Team
Rodrigo Loureiro (guest) wrote:
: Hi
: I'm having problems retrieving the values from an XML doc.
: I'm using the DOMParser, but instead of retrieving the values
: from the nodes, I just get null.
: Code fragment :
: DOMParser parser = new DOMParser();
: parser.parse(url);
: XMLDocument doc = parser.getDocument();
: NodeList nl = doc.getElementsByTagName("*");
: Node n;
: iNode = nl.getLength();
: for (int i=0; i<iNode; i++)
: n = nl.item(i);
: String szNodeName = n.getNodeName();
: System.out.print(szNodeName+ " (" );
: System.out.print(n.getNodeValue()+")");
: System.out.println();
: The result is
: course (null)
: Name (null)
: All the node names are correct, but the node values are NOT
: displayed.
: Any idea ?
: Rodrigo
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
OIM to OID Provisioning - Userid getting 'null' in OID
OIM provisioned to OID. When Im creating a user in OIM and provisioning the OID resource, the userid is getting 'null' value in OID.
Any reasons? How to fix this ?
I have checked the design console and the ldapuserDNPrefix is mapped to uid.Hi,
You have to had an another atrribute in order to make it work:
Solution
While creating a user account on Oracle Internet Directory through Oracle Identity Manager, the
user ID that you specify is assigned to the cn field of Oracle Internet Directory.
If required, you can customize the mapping so that the user ID is assigned to the uid field of
Oracle Internet Directory.
1.In the Design Console, open the AttrName.Prov.Map.OID lookup definition.
2.Change the decode value of the ldapUserDNPrefix code key to uid.
*3.Add the following item to AttrName.Prov.Map.OID lookup defintion*
Code key "User ID", decode value "uid".
Please note that Key is case sensitive. -
No getter method for property user of bean Problem
Hi everyone,
I am new to this struts. I have a samll application to check login. When I run my application I get this message in my server console
No getter method for property user of bean org.apache.struts.taglib.html.BEAN
I saw the previous forum for the same topic. I have checked my property names start with appropriate cases. Here is my code
%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head><title>Login</title></head>
<body>
<html:form action="submit.do">
<table width="100%" border="0" height=75%>
<tr>
<td align="right" >UserName: </td>
<td><html:text property="user"/></td>
<tr>
<tr>
<td align="right" >Password: </td>
<td><html:text property="password"/></td>
</tr>
<tr>
<td colspan=2 align="center"><html:submit/></td>
</tr>
<tr>
<td colspan=2 align="center"><html:errors/></td>
</tr>
</table>
</html:form>
</body>
</html>
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
import java.util.*;
* @author skannan
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
public class LoginForm extends ActionForm
private String user = null;
private String password = null;
/* user */
public String getUser()
return (this.user);
public void setUser(String user)
this.user = user;
/* password */
public String getPassword()
return (this.password);
public void setPassword(String password)
this.password = password;
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// Log the forms data
servlet.log("Lastname:" + user);
servlet.log("Address:" + password);
// Check for mandatory data
ActionErrors errors = new ActionErrors();
if (user == null || user.equals("")) {
errors.add("User", new ActionError("error.user"));
if (password == null || password.equals("")) {
errors.add("Password", new ActionError("error.password"));
return errors;
I am missing anything in my config files. Please I need help.
Thanks!I did check my struts-config file
Here is the part of my file
<!-- ========== Form Bean Definitions ================= -->
<form-beans>
<form-bean name="loginForm"
type="kannan.struts.trailer.checkin.LoginForm"/>
<form-bean name="checkInForm"
type="kannan.struts.trailer.checkin.CheckInForm"/>
</form-beans>
<!-- ========== Action Mapping Definitions ============ -->
<action-mappings>
<action path="/submit"
type="kannan.struts.trailer.checkin.LoginAction"
name="loginForm"
input="/login.jsp"
scope="request">
<forward name="success" path="/checkIn.jsp"/>
<forward name="failure" path="/login.jsp"/>
</action>
Still I am getting the error
Maybe you are looking for
-
Plain HTTP Adapter (XML return without namespace)
Hello Experts, I'm very new at XI. I'm using XI 7.0 SP9. I wanna make interface with public website using plain HTTP adapter. The receiver url is http://openapi.naver.com/search?key=cdb64b1f218b55acbb73105b3b6f68a9&query=news&target=rank It returns X
-
Hi, I want to install a BOE and be able to save Crystal Reports which report data off SAP system. The following is what I did: 1. Install JDK and Tomcat 5.5 2. Install BOE XI 3.1 SP2 and deploy it to the existing Tocat The reason that I manually inst
-
Decline calls from lock screen
Big problem for me when i decline call with power button no missed call in lock screen to swipe to call .... i have to go to phone swipe up and see the call,,,!!!!!Kindly advice for the same .. Because while driving it very pain to call back... The s
-
Exporting application finished with error (when deploying)
When deploying HFM application from EPMA, I get this error from job "Exporting Application ...": Process Name : dimension_server Thread : 10 Server : HYPSRV Detail : An error was encountered while executing the Application Export: Object reference no
-
How to use frameset in flash 8
Hi can somebody help me with my web page i create some buttons using flash. i used frameset tag in my web page. So i have 2 rows in my web page and the second row has 2 colums. so i put the buttons i created in flash in first column of the secon row,