Helper Class Code

Hi All,
One very simple question. Where do we write the code for all the helper classes in JDeveloper? And how do we call database procedure with parameters using them?
Thanks,
CAH

Thanks for your reply Frank.
Yes my question was not complete.
I did some research and found out the place where I need to write the code. The problem is solved.
Thanks,
CAH

Similar Messages

  • Code Sample: Easy RFC Lookup From XSLT Mappings Using a Java Helper Class

    Hi everyone,
    This is just a shameless plug for my article: <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc8efd4ee14">Easy RFC Lookup From XSLT Mappings Using a Java Helper Class</a>. I hope you're interested in reading it, and I welcome your comments in this thread.
    Kind regards,
    Thorsten

    Hi Stefan. Thanks for your post. I have already done that. It still does not work. As a base for my java helper class I have usesd Thorstens code.
    The problem is quite confusing. I will try to ouline both issues here.
    First of all, when try to test from within the Operation Mapping, I always get a java error saying it cannot find the communication channel (it is there and working because I have tested it with the RFCLookup in graphical mapping). I have found a way to work around this, and that is to uncheck the "Use SAP XMLToolkit" checkbox --> switch to test tab, enter my ReceiverService in the parameter tab (header parameter) --> switch back to Definition tab, check the "Use SAP XMLToolkit" checkbox --> switch to Test tab and run the test. Then the XSLT and call to java helper class will work. Of course this is not really something you want to do all the time. Maybe there is a bug.
    Secondly, it never works when I try to do it "live". I am using a file adapter to pick up one file, convert it and a file adapter to drop the converted file. I get the following error code in SXMB_MONI.
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <!--  Request Message Mapping   -->
    <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">TRANSFORMER_CONF_EX</SAP:Code>
      <SAP:P1>ATJ_Accounting2XML_Accounting.xsl</SAP:P1>
      <SAP:P2>http://rd.accounting.logica.com</SAP:P2>
      <SAP:P3>fd552c30-bad9-11dd-9761-c21dac1b818c</SAP:P3>
      <SAP:P4>-1</SAP:P4>
      <SAP:AdditionalText />
      <SAP:Stack>TransformerConfigurationException triggered while loading XSLT mapping ATJ_Accounting2XML_Accounting.xsl; http://rd.accounting.logica.comfd552c30-bad9-11dd-9761-c21dac1b818c-1</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Using an XSLT without a call to a java helper class, works just fine.
    I am totally at a loss here. Any more input would be much appreciated.
    /Patrik

  • XSLT mapping with Java helper classes

    Hi,
    I'm trying to implement a XSLT mapping to convert my request to a specific soap request message format for this I'm calling some methods from a java helper class. I have imported the jar file into the archives. When I tried to test the interface it keeps complaing there is some exception but doesn't give me the exact error. Has any one called any java helper classes with in XSLT mapping, if so I would appreciate if you could help me with this. Here is the code from xsl.
    <wsse:Security soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext"   xmlns:UserToken="java:com.company.test.mapping.UserTokenMap">
    <wsse:UsernameToken>
        <wsse:Username xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
          <xsl:value-of select="UserToken:getUsername()"/>
        </wsse:Username>
        <wsse:Password wsse:Type="wsse:PasswordDigest" xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
        <xsl:value-of select="UserToken:getPasswordDigest()"/>
        </wsse:Password>
        <wsse:Nonce xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
        <xsl:value-of select="UserToken:getNonce()"/>
        </wsse:Nonce>
        <wsu:Created xsi:type="soapenc:string" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
        <xsl:value-of select="UserToken:getCreateDate()"/>
    </wsu:Created>
    </wsse:UsernameToken>
    </wsse:Security>
    Thanks,
    Joe

    Hi,
    I'm getting following exception when I refer to the java class with in my XSLT mapping. Any one encountered the same problem.
    com.sap.engine.services.ejb.exceptions.BaseRemoteException:
    Exception in method transform.
         at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:218)
         at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native
    Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: java.lang.UnsupportedClassVersionError:
    com/earthlink/xi/mapping/UserTokenMap (Unsupported
    major.minor version 49.0)
         at java.lang.ClassLoader.defineClass0(Native
    Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:448)
         at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingLoader.findClass(RepMappingLoader.java:175)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
         at com.sap.engine.lib.xsl.xpath.JLBLibrary.<init>(JLBLibrary.java:33)
         at com.sap.engine.lib.xsl.xpath.LibraryManager.getFunction(LibraryManager.java:69)
         at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:98)
         at com.sap.engine.lib.xsl.xpath.XPathProcessor.innerProcess(XPathProcessor.java:56)
         at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:43)
         at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:51)
         at com.sap.engine.lib.xsl.xslt.XSLValueOf.process(XSLValueOf.java:76)
         at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296)
         at com.sap.engine.lib.xsl.xslt.XSLElement.process(XSLElement.java:248)
         at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296)
         at com.sap.engine.lib.xsl.xslt.XSLElement.process(XSLElement.java:248)
         at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296)
         at com.sap.engine.lib.xsl.xslt.XSLElement.process(XSLElement.java:248)
         at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296)
         at com.sap.engine.lib.xsl.xslt.XSLElement.process(XSLElement.java:248)
         at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296)
         at com.sap.engine.lib.xsl.xslt.XSLElement.process(XSLElement.java:248)
         at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296)
         at com.sap.engine.lib.xsl.xslt.XSLTemplate.process(XSLTemplate.java:272)
         at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:463)
         at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:431)
         at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:394)
         at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:398)
         at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:240)
         at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingTransformer.transform(RepMappingTransformer.java:150)
         at com.sap.aii.ibrep.server.mapping.ibrun.RepXSLTMapping.execute(RepXSLTMapping.java:81)
         at com.sap.aii.ibrep.server.mapping.ibrun.RepSequenceMapping.execute(RepSequenceMapping.java:54)
         at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80)
         at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107)
         at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127)
         at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104)
         at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40)
         at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167)
         ... 10 more
    ; nested exception is:
         java.lang.UnsupportedClassVersionError:
    com/earthlink/xi/mapping/UserTokenMap (Unsupported
    major.minor version 49.0)

  • Java Error in RFC Lookup in XSLT Mapping usinf Java helper class

    Hi All,
    I am doing RFC Lookup in XSLT Mapping using Java Helper class.
    The Lookup works fine when called one RFC at a time However my requirement is I want to do 2 Lookups.
    Both Lookups works when done individually however when I call both lookups in one mapping I get following error "javax.xml.transform.TransformerException: DOMSource whose Node is null."
    Following is the code I have written in XSLT for the lookup:
         <xsl:template name="Lookup_1">
              <xsl:param name="STDPN"/>
                   <rfc:RFC_READ_TABLE>
                        <QUERY_TABLE>KNA1</QUERY_TABLE>
                        <OPTIONS><item><TEXT>
                                  <xsl:value-of select="$STDPN"/>
                             </TEXT></item>
                        </OPTIONS>
                        <FIELDS>
                             <item>
                                  <FIELDNAME>KUNNR</FIELDNAME>
                             </item>
                        </FIELDS>
                   </rfc:RFC_READ_TABLE>
              </xsl:variable>
              <xsl:variable name="response" xmlns:lookup="java:urn.mt.pi" select="lookup:execute($request, 'BS_D, 'cc_RfcLookup', $inputparam)"/>
              <xsl:element name="STDPN">
                   <xsl:value-of select="$response//DATA/item/WA"/>
              </xsl:element>
         </xsl:template>
         <xsl:template name="Lookup_2">
              <xsl:param name="BELNR"/>
                   <xsl:variable name="Query">AGMNT = '<xsl:value-of select="$BELNR"/>'</xsl:variable>
                   <xsl:variable name="request1">
                        <rfc:RFC_READ_TABLE>
                             <QUERY_TABLE>ZTABLE</QUERY_TABLE>
                             <OPTIONS><item><TEXT>
                                  <xsl:value-of select="$Query"/>
                                  </TEXT></item>
                             </OPTIONS>
                             <FIELDS>
                                  <item>
                                       <FIELDNAME>KUNAG</FIELDNAME>
                                  </item>
                             </FIELDS>
                        </rfc:RFC_READ_TABLE>
                   </xsl:variable>
                   <xsl:variable name="response1" xmlns:lookup="java:urn.mt.pi" select="lookup:execute($request1, 'BS_D','cc_RfcLookup', $inputparam)"/>
                   <xsl:element name="BELNR">
                        <xsl:value-of select="$response1//DATA/item/WA"/>
                   </xsl:element>
         </xsl:template>
    My Question: Am I doing anything wrong? Or Is it possible to call multiple lookups in one XSLT?
    Thanks and Regards,
    Atul

    Hi Atul,
    I had the same problem like you had.
    The main Problem is that with the example code the request variable is created as NodeList object. In XSLT a variable is somekind of a constant and can't be changed. As the request object is empty after the first request the programm fails at the following line:
    Source source = new DOMSource(request.item(0));
    So I've created a workaround for this problem.
    In the call of the template I've put the request as a parameter object at the template call:
    <xsl:with-param name="req">
    <rfc:PLM_EXPLORE_BILL_OF_MATERIAL xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
      <APPLICATION>Z001</APPLICATION>
      <FLAG_NEW_EXPLOSION>X</FLAG_NEW_EXPLOSION>
      <MATERIALNUMBER><xsl:value-of select="value"/></MATERIALNUMBER>
      <PLANT>FSD0</PLANT>
      <VALIDFROM><xsl:value-of select="//Recordset/Row[name='DTM-031']/value"/></VALIDFROM>
      <BOMITEM_DATA/>
    </rfc:PLM_EXPLORE_BILL_OF_MATERIAL>
    </xsl:with-param>
    With this change the request will be provided as a String object and not as a NodeList object.
    Afterwards the RfcLookup.java has to be changed to the following:
    package com.franke.mappings;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.lookup.Channel;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.lookup.RfcAccessor;
    import com.sap.aii.mapping.lookup.LookupService;
    import com.sap.aii.mapping.lookup.XmlPayload;
    * @author Thorsten Nordholm Søbirk, AppliCon A/S
    * Helper class for using the XI Lookup API with XSLT mappings for calling RFCs.
    * The class is generic in that it can be used to call any remote-enabled
    * function module in R/3. Generation of the XML request document and parsing of
    * the XML response is left to the stylesheet, where this can be done in a very
    * natural manner.
    * TD:
    * Changed the class that request is sent as String, because of IndexOutOfBound-exception
    * When sending multiple requests in one XSLT mapping.
    public class RfcLookup {
         * Execute RFC lookup.
         * @param request RFC request - TD: changed to String
         * @param service name of service
         * @param channelName name of communication channel
         * @param inputParam mapping parameters
         * @return Node containing RFC response
         public static Node execute( String request,
                 String service,
                 String channelName,
                 Map inputParam)
              AbstractTrace trace = (AbstractTrace) inputParam.get(StreamTransformationConstants.MAPPING_TRACE);
              Node responseNode = null;
              try {
                  // Get channel and accessor
                  Channel channel = LookupService.getChannel(service, channelName);
                  RfcAccessor accessor = LookupService.getRfcAccessor(channel);
                   // Serialise request NodeList - TD: Not needed anymore as request is String
                   /*TransformerFactory factory = TransformerFactory.newInstance();
                   Transformer transformer = factory.newTransformer();
                   Source source = new DOMSource(request.item(0));
                   ByteArrayOutputStream baos = new ByteArrayOutputStream();
                   StreamResult streamResult = new StreamResult(baos);
                   transformer.transform(source, streamResult);*/
                    // TD: Add xml header and remove linefeeds for the request string
                    request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+request.replaceAll("[\r\n]+", ""); 
                    // TD: Get byte Array from request String to send afterwards
                    byte[] requestBytes = request.getBytes();
                   // TD: Not used anymore as request is String
                    //byte[] requestBytes = baos.toByteArray();
                    trace.addDebugMessage("RFC Request: " + new String(requestBytes));
                    // Create input stream representing the function module request message
                    InputStream inputStream = new ByteArrayInputStream(requestBytes);
                    // Create XmlPayload
                    XmlPayload requestPayload =LookupService.getXmlPayload(inputStream);
                    // Execute lookup
                    XmlPayload responsePayload = accessor.call(requestPayload);
                    InputStream responseStream = responsePayload.getContent();
                    TeeInputStream tee = new TeeInputStream(responseStream);
                    // Create DOM tree for response
                    DocumentBuilder docBuilder =DocumentBuilderFactory.newInstance().newDocumentBuilder();
                    Document document = docBuilder.parse(tee);
                    trace.addDebugMessage("RFC Response: " + tee.getStringContent());
                    responseNode = document.getFirstChild();
              } catch (Throwable t) {
                   StringWriter sw = new StringWriter();
                   t.printStackTrace(new PrintWriter(sw));
                   trace.addWarning(sw.toString());
              return responseNode;
         * Helper class which collects stream input while reading.
         static class TeeInputStream extends InputStream {
               private ByteArrayOutputStream baos;
               private InputStream wrappedInputStream;
               TeeInputStream(InputStream inputStream) {
                    baos = new ByteArrayOutputStream();
                    wrappedInputStream = inputStream;
               * @return stream content as String
               String getStringContent() {
                    return baos.toString();
              /* (non-Javadoc)
              * @see java.io.InputStream#read()
              public int read() throws IOException {
                   int r = wrappedInputStream.read();
                   baos.write(r);
                   return r;
    Then you need to compile and upload this class and it should work.
    I hope that this helps you.
    Best regards
    Till

  • Including helper classes in java proxy jar file

    I must not be using the right header search criteria because I'm sure this question
    has been asked before. In a Web Service File (.jws) I've imported a couple of
    helper classes that function as data transfer objects. I did this to maintain
    consistency with other portions of the application. The Java Proxy jar file generated
    by Workshop does not include these files. Is there a way of including these dependencies
    or do I need to distribute another jar file with my helper classes?

    Hi Naichen,
    I was able to successfully run both the autotype and clientgen Ant task, on the
    WSDL you provided. The code behind those Ant tasks are pretty much what the WebLogic
    Web Services test page run. Are you using WLS 8.1 SP2? If not, you might want
    to try with that version.
    Regards,
    Mike Wooten
    "Naichen Liu" <[email protected]> wrote:
    >
    >
    >
    Hi,
    I am having a warning message when trying to generate java proxy jar
    file on weblogic8.1
    webservice test web app, the message is as follows:
    "Warning Failed to generate client proxy from WSDL definition for this
    service.
    Prescription Please verify the <types> section of the WSDL."
    in the mean time, on weblogic starting terminal, I saw the following
    exceptions,
    C:\DOCUME~1\u252738\LOCALS~1\Temp\wlwproxy37508.jar1533409921\com\ual\www\rcc\cb
    t\schema\modifypnr\AlphaLength4Deserializer.java:36: cannot resolve symbol
    symbol : class FacetUtils
    location: package binding
    weblogic.xml.schema.binding.FacetUtils.checkLengthFacet(__typed_obj,4L);
    ^
    C:\DOCUME~1\u252738\LOCALS~1\Temp\wlwproxy37508.jar1533409921\com\ual\www\rcc\cb
    t\schema\modifypnr\OSIFieldAnonTypeDeserializer.java:36: cannot resolve
    symbol
    symbol : class FacetUtils
    location: package binding
    weblogic.xml.schema.binding.FacetUtils.checkMaxLengthFacet(__typed_obj,69L);
    ^
    C:\DOCUME~1\u252738\LOCALS~1\Temp\wlwproxy37508.jar1533409921\com\ual\www\rcc\cb
    t\schema\modifypnr\AlphaLength2Deserializer.java:36: cannot resolve symbol
    symbol : class FacetUtils
    location: package binding
    weblogic.xml.schema.binding.FacetUtils.checkLengthFacet(__typed_obj,2L);
    ^
    C:\DOCUME~1\u252738\LOCALS~1\Temp\wlwproxy37508.jar1533409921\com\ual\www\rcc\cb
    t\schema\modifypnr\FreeFormAnonTypeDeserializer.java:36: cannot resolve
    symbol
    symbol : class FacetUtils"
    Can anybody help me about this issue? I attached WSDL file, also United
    Airlines
    got an enterprise weblogic license deal with BEA, any help will be highly
    appreciated.
    Thanks!!!
    Naichen

  • Obtaining principal in EJB helper classes

    I have a pretty typical EJB setup where the actual EJBs delegate a lot of work
    off to helper classes which are simple java classes. Some of these helpers need
    access to the principal currently executing on this container thread. Currently,
    I am passing the principal as a parameter in every method signature on the helpers
    which need it. But as you can probably guess that approach is quickly becoming
    unweildy.
    Ideally, what I would like to do is to have access to the principal associated
    with the currently executing thread. I can mimic this by setting thread-local
    variables in the EJB prior to calling helpers. But I was wondering (ok, hoping)
    that there was already a way to access this information (either through weblogic
    classes or MBeans). At this point, I dont even care if it is not portable.
    P.S., I use WL6.1
    Thank you in advance,
    Steve

    >
    The helper methods do database querries etc and return results that the EJB sends onwards to clients. If these methods
    are NOT synchronized (and the ejbs share the static class) won't it cause concurrency errors? I think most of our methods are not
    synchronized (and it doesn't seem to cause any concurrency errors so far... though the system have not beeen stressed test that much,
    and concurrency bugs tends to pop up later and randomly :P).
    >
    No, if you dont have any static data variables in the Java classes, static method as such will not cause concurrency errors, and the methods should not be synchronized.
    If you have any synchronized methods and they take a while to execute, that could become a bottleneck in itself, because different threads waiting for each other,
    so make sure you dont have any synchronized methods where it is not explicitly needed.
    Think of a static method (without static data in the class being manipulated) as a plain function in another programming-language.
    >
    We have some scaleability problems with the EJBs... It seems as if they do not run concurrently. If we do a stress test with several threads calling the EJBs their response time increases by a too large factor to feel comfortable...
    >
    Apparently, you do have a some scaling/concurrency problem, which could have many causes -- transaction locking and clashes in the database, poorly configured database, network congestion, problems in the EJB architecture, etc -- can be many reasons...
    The general idea to debug, is first to find out exactly what calls in your code that take longest time to execute (profiling, logging, System.out.println's are useful) when you put parallel load on your system -- rather than just seeing "the whole application seems slow" -- from there you can move on, "divide&conquer" the problem, etc...

  • Reading files from within helper classes

    From within a servlet, I can get the servlet context to get a path to the "web" directory of my project and easily access properties files for my project. If I create another package in my project to hold helper classes that perform some specific function and want to create and/or read from a properties file, I get a path to the bin directory of my servlet container:
    Servlet Path: D:\Documents and Settings\Josh\My Documents\Josh\Projects\ServletSandBox\build\web\
    Helper Class File Path: D:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\bin\test
    I'd like to develop my helper packages as reusable APIs, so they're not tied directly to my project or to a servlet in general, but I'd like the properties files to stay somewhere in my project folder, preferably in the WEB-INF directory with the servlet's own specific properties file.
    I can't figure out the best way to handle this. I wanted to just be able to pass the helper class a String if somebody wanted to specify a filename other than the default filename. Does it make sense to specify a file URL instead? Is there any other way to get the calling servlet's context path without having to pass in a variable?
    Thanks

    It seems that the helper API shouldn't need to be given a path to its own config file. I would like to have code that will load the file regardless of whether or not its in a stand alone java app or a servlet. Whenever the helper API is jarred up and imported into my servlet, it can't find the config file unless it's in the "D:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\bin\test" directory. OR, if I use the current thread to get the loader, it will locate it in the "classes" folder, which is the only solution I can come up with that will let me write code to load the file that will work, regardless of its implementation.
    The "project" folder I'm talking about is just the NetBeans "project" folder for the servlet, or the "ServetSandBox" folder in my example. I guess that doesn't really matter in the context of the servlet though.
    So is using the current thread the appropriate way to do this? When you say that code will work if I put the resource in the WEB-INF directory, that seems to only be true if I try to load it from the servlet itself, not the helper class. The helper class doesn't find the resource in the WEB-INF directory.
    Also, I would like to be able to write the default values to a new config file if one doesn't exist. How in the heck do I get a pointer to the "classes" folder, or any other folder that I can also read from using the classloader, so I can write to a new file?

  • To view database Java Source and Class code in SQL Developer - Do this...

    I've wanted something like this for a while.. Hope this helps someone else...
    Make a master detail report...
    1. Click the reports tab.
    2. Right click on "user defined reports" and select "add report"
    3. Type "Java Source Object and Class Code" into the name field.
    4. Make sure "Style" is set to "Table".
    5. Paste this code into the "SQL" window.
    select OBJECT_NAME, OBJECT_TYPE, to_char(created,'DD-MON-YYYY HH24:MI:SS') Created, to_char(LAST_DDL_TIME,'DD-MON-YYYY HH24:MI:SS') "Last DDL", STATUS
         from user_objects
        where object_type in ('JAVA SOURCE')
        order by object_name6. Click "Add child"
    7. Make sure "Style" is set to "Code" in the child.
    8. Paste the following code into the SQL window of the child.
    select text from user_source where name = :OBJECT_NAME order by line9. Click Apply..
    10. Enjoy...
    no semicolons after the sql....
    Message was edited by:
    slugo

    Mark,
    Thanks Check this out people can now subscribe to the public reports out no the exchange.
    http://krisrice.blogspot.com/2007/10/marks-post-on-forums-got-me-to-do.html
    -kris

  • Install Base Accounting Class code

    Hi,
    Iam using api csi_item_instance_pub.update_item_instance for updating Install base instance.
    Iam able to update the partyid, account id but not accounting class code.
    Can anyone please help me how to update accounting class code along with party information.
    Any help is highly appreciated.
    Here is my code which Iam using to update Item instance..
    CREATE OR REPLACE PROCEDURE updateib_load_test
    IS
    g_instance_id_lst csi_datastructures_pub.id_tbl;
    l_instance_rec apps.csi_datastructures_pub.instance_rec;
    p_ext_attrib_values apps.csi_datastructures_pub.extend_attrib_values_tbl;
    p_party_tbl apps.csi_datastructures_pub.party_tbl;
    p_account_tbl apps.csi_datastructures_pub.party_account_tbl;
    l_pricing_attrib_tbl apps.csi_datastructures_pub.pricing_attribs_tbl;
    l_org_assignments_tbl apps.csi_datastructures_pub.organization_units_tbl;
    l_asset_assignment_tbl apps.csi_datastructures_pub.instance_asset_tbl;
    l_txn_rec apps.csi_datastructures_pub.transaction_rec;
    x2_txn_rec apps.csi_datastructures_pub.transaction_rec;
    l_return_status VARCHAR2 (100);
    l_msg_count NUMBER;
    l_msg_data VARCHAR2 (2000);
    l_created_manually_flag VARCHAR2 (100);
    ----l_org_id NUMBER := 204;
    n NUMBER := 1;
    v_instance_id NUMBER;
    p_commit VARCHAR2 (5);
    p2_commit VARCHAR2 (5);
    p_validation_level NUMBER;
    p_init_msg_lst VARCHAR2 (500);
    v_instance_party_id NUMBER;
    v_ip_account_id NUMBER;
    l_relationship_tbl apps.csi_datastructures_pub.ii_relationship_tbl;
    v_relationship_id NUMBER;
    v_success VARCHAR2 (1) := 'T';
    x2_return_status VARCHAR2 (100);
    x2_msg_count NUMBER;
    x2_msg_data VARCHAR2 (2000);
    p2_validation_level NUMBER;
    p2_init_msg_lst VARCHAR2 (500);
    a NUMBER;
    t1_msg_dummy VARCHAR2 (1000);
    t1_output VARCHAR2 (1000);
    l_not_created NUMBER;
    l_buffer VARCHAR2 (32767);
    l_problem EXCEPTION;
    l_message VARCHAR2 (2000);
    CURSOR updateib_cur
    IS
    SELECT *
    FROM ib_conv_stg
    WHERE updateib = 'Y'
    AND status_stg = 'V'
    AND new_instance_number IS NOT NULL
    AND transaction_id_stg = 8077;
    BEGIN
    -- DBMS_OUTPUT.put_line ('AFTER BEGIN');
    apps.fnd_file.put_line (apps.fnd_file.LOG, 'AFTER BEGIN');
    FOR updateib_rec IN updateib_cur
    LOOP
    BEGIN
    l_instance_rec.accounting_class_code := fnd_api.g_miss_char;
    IF p_party_tbl.EXISTS (1) IS NOT NULL
    THEN
    p_party_tbl.DELETE;
    END IF;
    IF p_account_tbl.EXISTS (1) IS NOT NULL
    THEN
    p_account_tbl.DELETE;
    END IF;
    IF p_ext_attrib_values.EXISTS (1) IS NOT NULL
    THEN
    p_ext_attrib_values.DELETE;
    END IF;
    /* SELECT apps.csi_item_instances_s.NEXTVAL
    INTO v_instance_id
    FROM SYS.DUAL;*/
    l_instance_rec.instance_id :=
    TO_NUMBER (updateib_rec.new_instance_number);
    l_instance_rec.instance_number := updateib_rec.new_instance_number;
    apps.fnd_file.put_line (apps.fnd_file.LOG,
    l_instance_rec.instance_id);
    l_instance_rec.object_version_number := updateib_rec.object_version;
    apps.fnd_file.put_line (apps.fnd_file.LOG,
    l_instance_rec.object_version_number
    --l_instance_rec.inventory_item_id := updateib_rec.inventory_item_id;
    l_instance_rec.inv_master_organization_id :=
    updateib_rec.inv_master_organization_id;
    --189;
    l_instance_rec.mfg_serial_number_flag :=
    updateib_rec.mfg_serial_number_flag;
    --'Y';
    --l_instance_rec.serial_number := updateib_rec.ls_serial_number;
    ---'LOG0005';
    l_instance_rec.quantity := updateib_rec.quantity; --1;
    l_instance_rec.unit_of_measure := updateib_rec.unit_of_measure;
    --'EA';
    l_instance_rec.accounting_class_code :=
    updateib_rec.accounting_class_code;
    apps.fnd_file.put_line (apps.fnd_file.LOG,
    updateib_rec.new_instance_number
    || 'instance_rec'
    || l_instance_rec.accounting_class_code
    || 'updateib'
    || updateib_rec.accounting_class_code
    --'CUST_PROD'; --'INV';
    l_instance_rec.instance_status_id := updateib_rec.instance_status_id;
    --510;
    l_instance_rec.customer_view_flag := updateib_rec.customer_view_flag;
    --'N'; --N
    l_instance_rec.merchant_view_flag := updateib_rec.merchant_view_flag;
    --'Y'; --Y
    l_instance_rec.sellable_flag := updateib_rec.sellable_flag;
    --'Y'; --N
    --l_instance_rec.active_start_date := updateib_rec.active_start_date;
    --SYSDATE;
    l_instance_rec.location_type_code := updateib_rec.location_type_code;
    --'HZ_PARTY_SITES';
    l_instance_rec.location_id := updateib_rec.location_id; --375885;
    l_instance_rec.install_date := updateib_rec.install_date;
    --SYSDATE;
    l_instance_rec.install_location_type_code :=
    updateib_rec.install_location_type_code;
    --'HZ_PARTY_SITES';
    l_instance_rec.install_location_id :=
    updateib_rec.install_location_id;
    --375885;
    --l_instance_rec.vld_organization_id :=
    --updateib_rec.last_vld_organization_id;
    --2104;
    l_instance_rec.creation_complete_flag :=
    updateib_rec.creation_complete_flag;
    --'Y';
    --l_instance_rec.object_version_number :=
    --updateib_rec.object_version_number;
    -- 1;
    l_instance_rec.external_reference :=
    updateib_rec.ls_external_reference;
    l_instance_rec.instance_usage_code :=
    updateib_rec.instance_usage_code;
    l_instance_rec.inv_organization_id :=
    updateib_rec.inv_organization_id;
    l_instance_rec.inv_subinventory_name :=
    updateib_rec.inv_subinventory_name;
    l_instance_rec.inv_locator_id := updateib_rec.inv_locator_id;
    l_instance_rec.manually_created_flag :=
    updateib_rec.manually_created_flag;
    l_instance_rec.last_oe_po_number := updateib_rec.last_oe_po_number;
    l_instance_rec.instance_type_code :=
    updateib_rec.ls_instance_type_code;
    l_instance_rec.attribute3 := updateib_rec.ls_warranty_expiration_date;
    --l_instance_rec.UPDATE_ORACLE:= updateib_rec.UPDATE_ORACLE;
    -- ************* FOR PARTIES **********************************************************
    /* SELECT apps.csi_i_parties_s.NEXTVAL
    INTO v_instance_party_id
    FROM SYS.DUAL;*/
    p_party_tbl (1).instance_party_id := updateib_rec.instance_party_id;
    p_party_tbl (1).instance_id :=
    TO_NUMBER (updateib_rec.new_instance_number);
    p_party_tbl (1).party_source_table :=
    updateib_rec.owner_party_source_table;
    --'HZ_PARTIES'; --
    p_party_tbl (1).party_id := updateib_rec.owner_party_id;
    --442143; --13478;
    p_party_tbl (1).relationship_type_code := 'OWNER';
    p_party_tbl (1).contact_flag := 'N';
    -- l_party_tbl (1).active_start_date := updateib_rec.active_start_date;
    --SYSDATE;
    p_party_tbl (1).object_version_number :=
    updateib_rec.object_version_p;
    apps.fnd_file.put_line (apps.fnd_file.LOG,
    p_party_tbl (1).object_version_number
    -- *********** FOR PARTY ACCOUNT *****************************************************
    /* SELECT apps.csi_ip_accounts_s.NEXTVAL
    INTO v_ip_account_id
    FROM SYS.DUAL;*/
    p_account_tbl (1).ip_account_id := updateib_rec.ip_account_id;
    p_account_tbl (1).instance_party_id := updateib_rec.instance_party_id;
    p_account_tbl (1).party_account_id :=
    updateib_rec.owner_party_account_id;
    --755865;
    p_account_tbl (1).relationship_type_code := 'OWNER';
    --l_account_tbl (1).active_start_date := updateib_rec.active_start_date;
    --SYSDATE;
    p_account_tbl (1).object_version_number :=
    updateib_rec.object_version_a;
    apps.fnd_file.put_line (apps.fnd_file.LOG,
    p_account_tbl (1).object_version_number
    -- 1;
    p_account_tbl (1).parent_tbl_index := 1;
    p_account_tbl (1).call_contracts := 'Y';
    -- ************************** TRANSACTION REC *****************************************
    l_txn_rec.transaction_date := SYSDATE;
    l_txn_rec.source_transaction_date := SYSDATE;
    l_txn_rec.transaction_type_id := 1;
    l_txn_rec.object_version_number := 1;
    -- *************** API CALL *******************************************************
    -- DBMS_OUTPUT.put_line ('BEFORE CREATE ITEM INSTANCE');
    apps.fnd_file.put_line (apps.fnd_file.LOG,
    'BEFORE UPDATE ITEM INSTANCE'
    END;
    BEGIN
    fnd_msg_pub.initialize;
    csi_item_instance_pub.update_item_instance
    (p_api_version => 1.0,
    p_commit => apps.fnd_api.g_true
    --Defaults assigned in the package
    p_init_msg_list => apps.fnd_api.g_true
    --Defaults assigned in the package
    p_validation_level => apps.fnd_api.g_valid_level_full
    --Defaults assigned in the package
    p_instance_rec => l_instance_rec,
    p_ext_attrib_values_tbl => p_ext_attrib_values,
    p_party_tbl => p_party_tbl,
    p_account_tbl => p_account_tbl,
    p_pricing_attrib_tbl => l_pricing_attrib_tbl,
    p_org_assignments_tbl => l_org_assignments_tbl,
    p_asset_assignment_tbl => l_asset_assignment_tbl,
    p_txn_rec => l_txn_rec,
    x_instance_id_lst => g_instance_id_lst,
    x_return_status => l_return_status,
    x_msg_count => l_msg_count,
    x_msg_data => l_msg_data
    COMMIT;
    apps.fnd_file.put_line (apps.fnd_file.LOG,
    'AFTER UPDATE ITEM INSTANCE'
    apps.fnd_file.put_line (apps.fnd_file.LOG, 'test' || l_msg_data);
    /* apps.fnd_file.put_line (apps.fnd_file.LOG,
    'test1'
    || apps.fnd_msg_pub.get
    (l_lcv,
    apps.fnd_api.g_false
    IF l_return_status != apps.fnd_api.g_ret_sts_success
    THEN
    l_not_created := l_not_created + 1;
    ROLLBACK;
    RAISE l_problem;
    END IF;
    updating STATUS in stg table
    BEGIN
    IF l_return_status = 'S'
    THEN
    dbms_output.put_line('satus :'||l_return_status);
    COMMIT;
    END IF;
    COMMIT;
    END;
    -------------exception l_problem
    EXCEPTION
    WHEN l_problem
    THEN
    IF (l_msg_count > 0)
    THEN
    l_buffer := '';
    FOR l_lcv IN 1 .. l_msg_count
    LOOP
    l_message :=
    apps.fnd_msg_pub.get (l_lcv, apps.fnd_api.g_false);
    END LOOP;
    END IF;
    COMMIT;
    END;
    END LOOP;
    END updateib_load_test;

    Hi Nagamohan,
    Thanks for your reply.
    Iam using the Location type code 'HZ_PARTY_SITES'.
    Actually Iam updating existing instance to update party information.
    The existing instance has the accounting_class_code as 'CUST_PROD'.
    I want to update accounting class code to 'INV' while updating party information.
    Iam able to update party information but not able to update accounting class code.
    When I digged into the api, csi_item_instance_pub.update_item_instance I found some code which was updating the accounting_class_code to null if there is party information to be updated. I think this is the reason Iam not able to update accounting class.
    Please help me if there is any chance of updating accounting class code along with party information.
    Thanks in advance

  • Why use helper classes?

    I am confused about the purpose of helper classes when using EJB's. Is the idea simply to make the code more maintainable? To separate data access code from the business logic? To aid the reuse of code? Why should I choose to use a helper class rather than creating a new EJB to do the job?
    I have been unable to find any comprehensive articles, and am a bit confused!
    Thanks in advance.

    - split out code into distinct functional models
    - split out code that can be reused effectively elsewhere
    - wrap objects that need to be passed to other modules as a whole
    - performance (EJBs are slow compared to standard beans)
    - keep code shorter (per file/method) so it's easier to read and maintain
    etc. etc.

  • EJB and helper classes ...

    I have created an EJB component which uses
    some helper classes in JDeveloper 3.0 .
    The component deploys sucessfully to OAS 4.0.8.1 . When I try to run the component through an applet ( including the _client.jar
    in the archive tag) , the applet does not find the helper classes . How I do i include the helper classes in the _client.jar file ?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    Try to put all the EJB's in a single package and import the package. I
    can think of this solution right now, will keep posting for updates.
    Regards
    Raj
    Daniel Westerdale wrote:
    Hi,
    I have a number of EJBs that each use a common set interfaces,
    exceptions and Value beans. If I deploy using the iasdeploy command
    line, then I must package up all these common classes within each of
    the EJB modules - leading to a lot of duplicate code.
    Is there a smarter a way of packaged the common classes so that I can
    include them in the .EAR file but only in one module.
    Note: I would prefer to only argument the IAS classpath with 3rd party
    classes that rarely change and not these common classes e.g. Jlog
    cheers
    Daniel
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • EJB environment question (static helper classes)

    We're using JBoss as AS containing several stateless session beans.
    Now, we have certain helper classes that are abstract and contain static methods. Is this a problem for the EJBs? All of them use these helper classes all over their methods. Are they sharing the static class and will slow down somehow? Or is each EJB using its version of the class and can run concurrently?
    Should we rethink this and put an INSTANCE of each helper class in each ejb instead of using static methods in the helper class?
    Now in EJB method:
    Helper.calculateStuff();
    Should it be?
    Helper h = new Helper(); // defined when ejb is created
    helper.calculateStuff();
    Edited by: JAeon on Sep 8, 2008 12:21 AM
    Edited by: JAeon on Sep 8, 2008 12:22 AM

    >
    The helper methods do database querries etc and return results that the EJB sends onwards to clients. If these methods
    are NOT synchronized (and the ejbs share the static class) won't it cause concurrency errors? I think most of our methods are not
    synchronized (and it doesn't seem to cause any concurrency errors so far... though the system have not beeen stressed test that much,
    and concurrency bugs tends to pop up later and randomly :P).
    >
    No, if you dont have any static data variables in the Java classes, static method as such will not cause concurrency errors, and the methods should not be synchronized.
    If you have any synchronized methods and they take a while to execute, that could become a bottleneck in itself, because different threads waiting for each other,
    so make sure you dont have any synchronized methods where it is not explicitly needed.
    Think of a static method (without static data in the class being manipulated) as a plain function in another programming-language.
    >
    We have some scaleability problems with the EJBs... It seems as if they do not run concurrently. If we do a stress test with several threads calling the EJBs their response time increases by a too large factor to feel comfortable...
    >
    Apparently, you do have a some scaling/concurrency problem, which could have many causes -- transaction locking and clashes in the database, poorly configured database, network congestion, problems in the EJB architecture, etc -- can be many reasons...
    The general idea to debug, is first to find out exactly what calls in your code that take longest time to execute (profiling, logging, System.out.println's are useful) when you put parallel load on your system -- rather than just seeing "the whole application seems slow" -- from there you can move on, "divide&conquer" the problem, etc...

  • Helping class

    i'm learning how to develop one-to-many relationship software.
    The entities involved are STUDENT and RESULT. i.e I want  every
    student to main the history of his results.
    My helping class is result.java and its included in my question.
    Pls, I want to know if my helping class is correct and also if my servlet file is
    also correct. All my codes are for my helping class. I excluded that of the
    main class since I don't have problem with it.
    My main goal is to store many Results(subjects and scores) for every student
    This extract of the servlet  file shows only for result
    String[] sub = request.getParameterValues("subject");
       String[] score = request.getParameterValues("score");
           resultid.setSubject(sub);
           resultid.setScore(score);
         // This stores severa
         Vector v = resultid.getResult();
         Iterator iter =     v.iterator();
         while(iter.hasNext())
              resultid =(result)iter.next();
         String x = resultid.getSubject();
         String y = resultid.getScore();
    // The bean is for helping class
    package student;
    import java.util.*;
    public class result implements java.io.Serializable
         private String subject;
         private String score;
         private Vector v;
         public name()
         public String getSubject()
              return subject;
         public void setSubject(String subject)
              this.subject = subject;
         public String getScore()
              return score;
         public void setScore(String score)
              this.score = score;
         public void addResult()
              v.addElement(this);
         public Vector getResult()
              return v;
    }

    Pls, remember the following codes retrieve subject and score from jsp file .
    // This is the servlet that handles the result
    String[] sub = request.getParameterValues("subject");
       String[] score = request.getParameterValues("score");
           resultid.setSubject(sub);
           resultid.setScore(score);
         // This stores severa
         Vector v = resultid.getResult();
         Iterator iter =     v.iterator();
         while(iter.hasNext())
              resultid =(result)iter.next();
         String x = resultid.getSubject();
         String y = resultid.getScore();

  • Class/member variables usage in servlets and/or helper classes

    I just started on a new dev team and I saw in some of their code where the HttpSession is stored as a class/member variable of a servlet helper class, and I was not sure if this was ok to do or not? Will there be problems when multiple users are accessing the same code?
    To give some more detail, we are using WebLogic and using their Controller (.jpf) files as our servlet/action. Several helper files were created for the Controller file. In the Controller, the helper file (MyHelper.java) is instantiated, and then has a method invoked on it. One of the parameters to the method of the helper class is the HttpServletRequest object. In the method of the helper file, the very first line gets the session from the request object and assigns it to a class variable. Is this ok? If so, would it be better to pass in the instance of the HttpServletRequest object as a parameter to the constructor, which would set the class variable, or does it even matter? The class variable holding the session is used in several other methods, which are all invoked from the method that was invoked from the Controller.
    In the Controller file:
    MyHelper help = new MyHelper();
    help.doIt(request);MyHelper.java
    public class MyHelper {
        private HttpSession session;
        public void doIt(HttpServletRequest request) {
            session = request.getSession();
            String temp = test();
        private String test() {
            String s = session.getAttribute("test");
            return s; 
    }In the past when I have coded servlets, I just passed the request and/or session around to the other methods or classes that may have needed it. However, maybe I did not need to do that. I want to know if what is being done above will have any issues with the data getting "crossed" between users or anything of that sort.
    If anyone has any thoughts/comments/ideas about this I would greatly appreciate it.

    No thoughts from anyone?

  • Servlet cannot find helper class

    Hello
    Under WEB-INF/classes I put ServletExample and SingletonExample. Compiling ServletExample, that makes use of SingletonExample, works.
    In the directory WEB-INF/classes I also have another direcotry, test. And in WEB-INF/classes/test I put again ServletExample and SingletonExample.
    Here I have tried in several ways to compile the servlet, but I always get an:
    Cannot find symbol class SingletonExample.
    I tried writing package test at the top of both files, and even at the top of only one of these two.
    I even tried to make WEB-INF/classes/test/ServletExample make use of SingletonExample residing in WEB-INF/classes, but I didnt succeded.
    What happens when you have subdirectory in WEB-INF/classes/? I think this is a MUST, to have subdirectory in large webapplication, so I really dont want to put everything in the classes directory.
    Do you how to resolve this prolem? And: if Im in WEB-INF/classes/test and want to referr from a servlet residing in this direcory to a Singleton/helper class residing in WEB-INF/classes/, which approach do I have to use?
    Thanks
    Paolo

    Jeez, you aren't gonna get very far in Java like this.
    CLASSPATH is wrong - again. You're supposed to give JARs and paths where the class loader is supposed to look, not the actual .class file.
    Also, you're not telling the compiler to put the .class file in the package directory structure.
    Your example is pretty awful. Try this:
    Put this code into c:\common
    package common;
    import common.test.TestDown;  // What the hell is this?  There is no package test, but there is a package named common.test
    public class TestUp
       public void sayHello()
          System.out.println("Hello.....");
    }Put this code into c:\common\test
    package common.test;
    import common.TestUp;
    public class  TestDown
       public TestDown()
            TestUp testUp = new TestUp();
            testUp.sayHello();
       public static void main(String[] args)
            new TestDown();
    }Open a command shell and navigate to c:\, then do the following:
    Directory of c:
    07/01/2005  03:43 PM    <DIR>          .
    07/01/2005  03:43 PM    <DIR>          ..
    07/01/2005  03:45 PM    <DIR>          common
                   0 File(s)              0 bytes
                   3 Dir(s)  74,909,675,520 bytes free
    C:\>javac -d . common\*.java
    C:\>javac -d . common\test\*.java
    C:\>java -classpath . common.test.TestDown
    Hello.....Once you've got your head around this, go learn Ant and have it compile your projects properly.
    %

Maybe you are looking for