cancel
Showing results for 
Search instead for 
Did you mean: 

KM Task Sheduker : create a Class

Former Member
0 Kudos

Hello,

I try to read a xml file in a specific KM Task scheduler :

1) XML file is on dist/PORTAL-INF/users.xml

2) By run() method, i would like to try to read this file but it doesn't work, what

can be the problem ?

public void run( String id, Properties properties ) {

URL myurl = getClass().getClassLoader().getResource("users.xml");

try {

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

Document doc = docBuilder.parse (new File(myurl.getFile()));

doc.getDocumentElement ().normalize ();

}

catch...

}

What can be the problem ?

Thanks a lot and Best regards

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Aurelien,

you were discussing this topic in other thread. The problem is that by your code (my sample) you can access an file located between your class sources. And <b>dist/PORTAL-INF</b> is not a right choise. Your XML file is not included into built-in JAR file, this is the problem.

I was suggesting you to put your file into classpath package, for example in the same package you have the Task implemented in. Imagine you have Task class:


com.company.schedulers.MyTask

put your file into the same package and address it like this:


URL myurl = this.getClass().getClassLoader().getResource("com/company/schedulers/users.xml"); 

Files located into dist directory are copyed elsewhere when deployed.

regards.

mz

Former Member
0 Kudos

Hello,

Ok I try this but now I have this error :

#1.5#00123F744AA90064000000000000170000043D9FF36F72F6#1193657100274#System.err#sap.com/irj#System.err#J2EE_GUEST#0####95f59d20861111dccf7100123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain###java.io.FileNotFoundException: 😧
usr
sap
XXX
DVEBMGS03
j2ee
cluster
server0
file:
😧
usr
sap
XXX
DVEBMGS03
j2ee
cluster
server0
apps
sap.com
irj
servlet_jsp
irj
root
WEB-INF
portal
portalapps
CREATE
lib
CREATEapi.jar!
com
company
create
users.xml (The filename, directory name, or volume label syntax is incorrect)#

Best regards,

Former Member
0 Kudos

Hello Aurelien,

the most probable couse is that the file is actually missing in your application archive. Please check next:

1) Unzip your PAR archive

2) FInd and unzip JAR archive

3) Search for you file "users.xml"

And if it's not there, then as i have described :

<b>To build in non-JAVA files (and XML is considered non-java) you have to check in option:

"Yes, I want the non java sources includet into the portal components jars"

You will find this option in NWDS:

Window -> Preferences -> SAP Enterprise Portal -> Application Development Studio.</b>

And see the 'filename' part of your FileNotFound exception:

<u>D:
usr
sap
XXX
DVEBMGS03
j2ee
cluster
server0
</u><i>file:
😧
usr
sap
XXX
DVEBMGS03
j2ee
cluster
server0
apps
sap.com
irj
servlet_jsp
irj
root
WEB-INF
portal
portalapps
CREATE
lib
CREATEapi.jar!
com
company
create
users.xml</i>

Seems like a mistake in string append. Check it too.

please share the result.

mz

Former Member
0 Kudos

Hello Maxim,

Yes of course this option has been already checked.

So 1) I decrompress the CREATEapi.jar

2) in folder : /com/company/create/users.xml the file is here and ok !

So I tried to deploy it again, regard J2EE server :

I have again the message :

#

#1.5#00123F744AA9005F000000000001929400043DA92BCA3DF1#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain###java.io.FileNotFoundException: 😧
usr
sap
XXX
DVEBMGS03
j2ee
cluster
server0
file:
😧
usr
sap
XXX
DVEBMGS03
j2ee
cluster
server0
apps
sap.com
irj
servlet_jsp
irj
root
WEB-INF
portal
portalapps
CREATE
lib
CREATEapi.jar!
com
company
create
users.xml (The filename, directory name, or volume label syntax is incorrect)#

#1.5#00123F744AA9005F000000010001929400043DA92BCA41FE#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at java.io.FileInputStream.open(Native Method)#

#1.5#00123F744AA9005F000000020001929400043DA92BCA42AD#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at java.io.FileInputStream.<init>(FileInputStream.java:106)#

#1.5#00123F744AA9005F000000030001929400043DA92BCA4335#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at java.io.FileInputStream.<init>(FileInputStream.java:66)#

#1.5#00123F744AA9005F000000040001929400043DA92BCA43BA#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:69)#

#1.5#00123F744AA9005F000000050001929400043DA92BCA443F#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:156)#

#1.5#00123F744AA9005F000000060001929400043DA92BCA44C0#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at java.net.URL.openStream(URL.java:913)#

#1.5#00123F744AA9005F000000070001929400043DA92BCA4541#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:201)#

#1.5#00123F744AA9005F000000080001929400043DA92BCA45D0#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:263)#

#1.5#00123F744AA9005F000000090001929400043DA92BCA4687#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at com.sap.engine.lib.xml.parser.Parser.parseWithoutSchemaValidationProcessing(Parser.java:280)#

#1.5#00123F744AA9005F0000000A0001929400043DA92BCA4739#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at com.sap.engine.lib.xml.parser.Parser.parse(Parser.java:342)#

#1.5#00123F744AA9005F0000000B0001929400043DA92BCA47C9#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at com.sap.engine.lib.xml.parser.DOMParser.parse(DOMParser.java:101)#

#1.5#00123F744AA9005F0000000C0001929400043DA92BCA4851#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at com.sap.engine.lib.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:127)#

#1.5#00123F744AA9005F0000000D0001929400043DA92BCA48D7#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:151)#

#1.5#00123F744AA9005F0000000E0001929400043DA92BCA4965#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at com.company.create.create.run(create.java:57)#

#1.5#00123F744AA9005F0000000F0001929400043DA92BCA4A17#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at com.sapportals.wcm.service.scheduler.SchedulerEntry.run(SchedulerEntry.java:174)#

#1.5#00123F744AA9005F000000100001929400043DA92BCA4AA2#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at com.sapportals.wcm.service.scheduler.crt.PoolWorker.run(PoolWorker.java:108)#

#1.5#00123F744AA9005F000000110001929400043DA92BCA4B30#1193696700415#System.err#sap.com/irj#System.err#J2EE_GUEST#0####c97b98f0866d11dc9d0f00123f744aa9#Thread[ThreadPool.Worker2,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error##Plain### at java.lang.Thread.run(Thread.java:534)#

I'm lost...

Thanks a lot

Best regards

Former Member
0 Kudos

Is it not a problem of this piece of code :

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

Document doc = docBuilder.parse (new File(myurl.getFile()));

where myurl is transformed in string ....

Thanks a lot

Best regards

Former Member
0 Kudos

Aurelien,

yes, the problem is somwhere there, <b>try to use myurl.getPath() function instead of getFile()</b>.

Do you have debugging possibility?

I'd rather like to see <b>myurl</b> object values. That file-path you are trying to access is wrong. First part of it is duplicated. So long have no idea why.

regards.

mz