NullPointerException when accessing EntityManagerFactory from within EJB

Hello everyone,
I am having trouble getting an EJB to work properly with persistence. Here is the code for my EJB:
package HelpDesk.ejb;
import javax.ejb.Stateless;
import HelpDesk.entity.Tecnico;
import javax.persistence.*;
import javax.persistence.EntityManagerFactory;
@Stateless
public class HelpDeskManager implements HelpDeskManagerInterface {
   @PersistenceUnit(unitName="HelpDeskPU")
   EntityManagerFactory emf;
  public void newTecnico(String nombre, String username, String privilegio, String password)
      javax.persistence.EntityManager em = emf.createEntityManager();
      Tecnico tec = new HelpDesk.entity.Tecnico(nombre, username, privilegio, password);
      em.persist(tec);     
}The error happens on the line: javax.persistence.EntityManager em = emf.createEntityManager();
This method is then called from a servlet which has the following code on its doGet() method:
      response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            HelpDesk.ejb.HelpDeskManager hdm = new HelpDesk.ejb.HelpDeskManager();
            hdm.newTecnico(request.getParameter("nombre"), request.getParameter("username"), request.getParameter("privilegio"), request.getParameter("password"));
            out.println("Técnico creado exitosamente.");
            response.sendRedirect("index.jsp");
        catch(Exception ex){out.println(ex.getMessage());}
        finally {
            out.close();
        }Using this try statement simply causes the word "null" to be output to the browser. Without the try statement, I get the NullPointerException on the app server logs. I am using Netbeans 6.5/ Glassfish v2. I can guarantee that the Persistence Unit is correctly configured and that a connection pool has been defined in Glasfish for this database, as well as a JNDI name for it, though I do not know if it's necessary to register the EJB as a JNDI name as well.
Any advice will be truly appreciated, as I am rather new to EJB technology. Thank you.

Hello again, thanks for your quick reply,
I tried it out the way you suggested, but I now get the following error displayed on my browser:
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: PWC1391: Servlet.init() for servlet newTecnico threw exception
root cause
java.lang.RuntimeException: WEB5002: Exception in handleBeforeEvent.
root cause
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref help_desk.servlet.newTecnico/hdm@jndi: HelpDesk.ejb.HelpDeskManager@[email protected]@Session@null into class help_desk.servlet.newTecnico
root cause
javax.naming.NameNotFoundException: HelpDesk.ejb.HelpDeskManager#HelpDesk.ejb.HelpDeskManager not foundI believe it is because I need to define the EJB as a JNDI resource. However, I am unsure how to go about this. When I try to do create a new JNDI resource via the Glassfish Admin Console, it asks for several fields, including Resource Type and Resource Factory. I think Resource Type can be the fully qualified class name, but my EJB doesn't have any factory classes associated with it.
Thanks again for the information. your help is greatly appreciated!

Similar Messages

  • To contact 3rd party application from within EJB container

    What are the possible options to communicate with an external application from within EJB container? Options that I can think of are
    - RMI
    - JMS
    - Socket communication
    - HTTP
    - any other option???
    And if anyone can give the pros & cons of the different approaches, based on their experiences it will be great.

    Hi,
    There is one more.
    Web Services which is much powerful than any other.
    Ofcourse for this also u have to use socket communication and http protocol.
    SOAP(Simple Object Access Protocol).. I think u got it..
    I prefer SOAP as it has many adavantages over RMI and other.
    Thanks,
    All the best.
    What are the possible options to communicate with an
    external application from within EJB container?
    Options that I can think of are
    - RMI
    - JMS
    - Socket communication
    - HTTP
    - any other option???
    And if anyone can give the pros & cons of the
    different approaches, based on their experiences it
    will be great.

  • RoboHelp 11 - When previewing topics from within the project, a script error displays: 'HHComponent Activator' is undefined. How do you get rid of this script error?

    RoboHelp 11
    When previewing topics from within the project, a script error diplays: 'HHComponent Activator' is undefined.
    How do you get rid of this script error?

    Hi there
    Have you tried clicking Help > Updates and applying the service release?
    If not, I'd start with that.
    Cheers... Rick

  • Accessing tunes from within STP or Toast

    When using Toast, or Motion, or Soundtrack Pro, etc media browser files provide access to iTunes for selecting whichever tune you want. Very nice. However I cannot see all my tunes. They're listed in Compilations, Albums, etc. But for the life of me I cannot figure out how to get the ones I want to appear in that browser window. For instance, in iTunes I imported 4 tracks. I selected them, created a playlist with those 4, and indicated they were a compilation. I also included them in an existing playlist that does somehow appear in the browser in outside apps (Motion, STP, Toast, etc). But no matter what I try, those 4 songs are not accessible from within Toast. I simply cannot see them to burn to a CD. They are songs that are legal, nothing shady from that department, but my eyes and brain are foggy about how/where those browsers are accessing the data. Any help appreciated.

    There used to be something called high-level API. Abandoned ages ago because most of us preferred the "real thing" or went to scripting.
    TextStyleRange like all the other Text scripting objects are second class citizens of the object model - they are created only on the fly as "proxy" objects. On the down side that means they consume memory until the document is released/saved/closed, and may fall apart (point to the wrong chunk of text) after any manipulation in preceding text. Besides the implementation is overkill by several degrees - each instance (I think it was kTextScriptingSuiteBoss) is the equivalent to a whole selection suite boss.
    That said, you can use IScriptUtils to access kScriptInfoManagerBoss.
    IScriptRequestHandler is aggregated there to execute script requests.
    Be warned that constructing such script requests also has some learning curve, and the interfaces in the scripting area are extremely unstable across InDesign versions. Every other version renames methods, classes, adds or removes arguments. You will need plenty preprocessor conditions for cross-version code.
    From the plugin side I only use that approach where the official interfaces do not work and the working interfaces (as used by scripting) are not exposed. One concrete case is TOP (type on path).
    Dirk

  • NullPointerException when executing OMBSTART from OMB Plus

    Hi
    I have deployed a process flow and assigned a schedule/calendar to that process flow all through OMB+.
    If I go to the Control Center, the scheduled job that's been created to execute the process flow is sitting in the 'Scheduled' tab of the Control Center Jobs window. I can then right click on the job and select 'Start' which starts the scheduled job (which will run whenever the schedule has been set to execute).
    My problem is that I'd prefer to kick-start the scheduled job from within OMB+ since we're trying not to use the Control Center for deployment.
    When I run the command:
    OMBSTART SCHEDULABLE '$newJobName' IN '$scheduleLocationName'
    I get the error:
    java.lang.NullPointerException
    I've tried restarting OMB+ (just in case it had become confused), and have changed my context within OMB, but I always get the same error. Has anyone come across this problem before?
    Thanks in advance
    Liffey

    Hello Cornell,
    This problem will be fixed in the next version of wlst.
    thanks,
    -satya

  • Data Model damaged, Cannot connect to Access 2013 from within Excel 2013

    Hello,
    Recently I am not able to use PowerPivot for Excel 2013 and I cannot connect to my Access 2013 database tables from within Excel 2013. Whenever I try to click on a slicer in my Excel worksheet, it gives me the following error: "Excel was unable to load
    a necessary component. This component might have been damaged or deleted. Reinstall the client software or data source driver software for your database."
    I am using Microsoft Office Pro Plus 2013 on Windows 7, 64-bit version. I have tried reinstalling Microsoft SQL Compact Edition 2005 and reinstalling Office 2013. I have run out of ideas and am a loss what to do next ? 
    Can anyone help point in the right direction for a possible solution to this problem ??? 
    Would appreciate all help.
    Thank you.
    ~Maneesh
    The problem with being punctual is, there's nobody there to appreciate it !!!

    Hi
    This is the forum to discuss questions about apps for office develop. For your question is more about Excel, I will move this thread to the TechNet forum for
    Excel
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly
    can either share their knowledge or learn from your interaction with us.
    Thank you for your understanding.
    Best Regards
    Lan
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • OWSM Policy - how to access subject from within protected service

    I am setting up a new instance of SOA Suite 11g for integration purposes at my organization. I am planning to use predefined WSM policies to protect the services (see http://download.oracle.com/docs/cd/E12839_01/web.1111/b32511/policies.htm).
    Most communication is server-to-server (e.g. HR sending data to CRM), so it would make sense to use something like X.509 (i.e. oracle/wss11_x509_token_with_message_protection_service_policy). However, I have a requirement that the underlying services (BPEL processes, for example), must know the subject (i.e. the server) that sent the message. For example, did this incoming message come from the HR system or the CRM system. This is used internally by the BPEL process for audit logs and other things.
    We also use OAM, so I will likely eventually use the oracle/wss_oam_token_service_policy to verify ObssoCookie values. In those cases, the underlying Java service or BPEL process will need to have access to the username of the authenticated user.
    I've searched and searched the documentation, and I cannot find any instructions about how to access details about the authenticated subject (such as username, roles, or X.509 properties) from within the protected service, whether it be a Java-based service, a BPEL process, or anything else.
    I did find some information about how to read SOAP header values from within Oracle BPEL processes (see http://chintanblog.blogspot.com/2007/12/insertextract-soap-headers-in-bpel-it.html). However, this looks like it will only work if I use the WSS UsernameToken policy (e.g. oracle/wss_username_token_service_policy), since that is the only policy where the actual subject identifier (username) is specified in a SOAP header.
    Do the other policies (X.509, SAML, and OAM) provide a mechanism to convey properties of the authenticated subject to the underlying service? If so, where is this documented? Thanks much!
    Sincerely,
    Nathan Kopp

    Is it wrong question or wrong thing to do?
    Let's make it a little bit easier/better/worse:
    How can I change policy permissions at runtime?

  • Accessing Tangosol from an EJB

    Hi,
         I have an EJB that when my EJB executes the following method for the first time, it starts up an instance of Tangosol:
         NamedCache cache = CacheFactory.getCache(cacheName);
         I don't want an instance of tangosol to just automatically start up one time on the first call to a Tangosol method given above. This is because I have custom parameters I'd want to use when I start up Tangosol, and I want to have control over when I start and stop Tangosol.
         How would I be able to get the EJB to automatically start an instance of Tangosol with command line params of cache config and tangosol override locations specified, along with a modified classpath?
         If this can't be done, how can I just get my EJB to not instantiate Tangosol, thus implying that I manually start up n instances before my EJB call.
         Thanks in advance,
         - N

    Thx Dimitry. Those provide me with 3 great options to start up Tangosol Coherence from Weblogic or my EJB.
         Two issues:
         1. This is how I would start my instance of Tangosol Coherence from my EJB or Weblogic. I'm testing this in my EJB now but it's not working. Please advice. Note that I'd pass the system properties for my two xml configs but I removed these here for sake of simplicity. I do this from ejbCreate() method. No new thread creation here.
         DefaultCacheServer dcs = new DefaultCacheServer();
         String[] args = new String[5];
         args[0] = "-server";
         args[1] = "-Xms512m";
         args[2] = "-Xmx512m";
         args[3] = "com.tangosol.net.DefaultCacheServer";
         args[4] = "5";
         dcs.main(args);
         dcs.start();
         2. Is there any way I can avoid having to start up Tangosol Coherence from Weblogic or EJB? For example, if I already have my two instances running on machine A, I don't want the EJB or weblogic to start up another Tangosol Coherence node. Is this possible? I've noticed that when I call CacheFactory.getCluster() or CacheFactory.getCache() that even if I have other instances of Tangosol running on machine A that were started from the command line aren't being recognized and an instance is automatically started from my EJB when I didn't ask it to. Why does this occur? Once the "automatically created" instance of Tangosol from my EJB is created, my other two instances I started separately from the cmd line recognize this EJB created tangosol instance. I need to get around this so that my EJB does not bring up a Tangosol node, but instead checks to see if a node exists and if so, just proceed as normal, otherwise it should either create a new node or throw an error.
         Thx,
         - N
         > Hi,
         >
         > You can configure Coherence from a
         > ServletContextListener, like Cameron suggested.
         > Alternatively, if you use WebLogic, you can use
         > Application LIfecycle Events - see <a
         > href="http://edocs.bea.com/wls/docs90/programming/life
         > cycle.html">Programming Application Lifecycle
         > Events</a> (WebSphere has a similar functionality -
         > 'WebSphere Startup Beans). Yet another alternative -
         > you can use a Stateless Session Bean with maximum and
         > initial pool size = 1 and configure Coherence during
         > it's initialization.
         >
         > Regards,
         > Dimitri
         Message was edited by:
         noah

  • GPEngineException: Error filling role when invoking GP from within webdynpr

    Hi
    I am trying to invoke a guided procedure process (the example Time-Off-process) from within a webdynpro-application. For this, I used the code given here: http://help.sap.com/saphelp_nw2004s/helpdata/en/43/fcdf77fc6510b3e10000000a11466f/frameset.htm. The process can be invoked and starts running if I configure the roles in the design time environment such that the role type is set to "Initiator". However, if I change the role type to "Instantiation defined", I get the following error:
    "Error filling role role.overseer of role type 3 during instantiation".
    The stack trace shows that a GPEngineException has been thron:
    com.sap.caf.eu.gp.exception.api.GPEngineException: Error filling role role.overseer of role type 3 during instantiation
         at com.sap.caf.eu.gp.process.rt.impl.GPRuntimeManager.checkRoleList(GPRuntimeManager.java:307)
         at com.sap.caf.eu.gp.process.rt.impl.GPRuntimeManager.startProcess(GPRuntimeManager.java:125)
    In my code, I assign roles to users exactly as described in the above mentioned document. Here's the code snippet:
         //Assign users to each role:                         
         IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();
         IGPProcessRoleInstanceList roles =
         rtm.createProcessRoleInstanceList();
         int rolenum = process.getRoleInfoCount();
         for (int i = 0; i < rolenum; i++) {
              String roleName = process.getRoleInfo(i).getRoleName();
              //create a new role instance by specifying the role's unique name
              IGPProcessRoleInstance roleInstance =
              roles.createProcessRoleInstance(roleName);
              //add the new role to the assignment list
              roles.addProcessRoleInstance(roleInstance);
    What could be the problem here? I have searched all over the forum, but didn't find any hint. It might as well be that the error doesn't mean anything. I got a similar problem earlier which was solved by activating the process in the GP-Designtime. It would be great if anybody had an idea as to what I could do here. Anything could be a helpful suggestion!
    Thanks very much!
    Best regards
    Bettina Hepp

    This error is thrown if the role configuration in the guided procedure design time doesn't correspond to the role assignment during process instantiation:
    1. If role should be assigned at process instantiation, tick "overwritable at runtime", set role to "Initiation defined" and do assign a user to the role when you invoke the process.
    2. If role should be the process initiator, set role to "Initiator". In this case it is not possible to assign a user to this role when invoking the process.
    3. There is a third role type: "Runtime defined", haven't tried that so far.

  • Do I need additional Driver/Clients when accessing Oracle from CSharp ?

    I am trying to connect from within a CSharp program to Oracle database 10g Express.
    I coded in CSharp:
    using System.Data.OracleClient;
    but this line gives an unresolve error: Type or namespace missing ...?
    As far as I thought VisualStudio 2005 provides a standard client for Oracle database.
    How do I enable it ?
    Or do I need some additional files from Oracle to get it working ?

    You may find useful these links from the Oracle technology corner >
    http://www.oracle.com/technology/sample_code/tech/windows/ole_db/oledb92/index.html
    http://www.oracle.com/technology/sample_code/tech/windows/ole_db/oledb8/index.html
    Regards.

  • Access ViewObject from within DataBean

    How do you call a View Object from within a java class?
    This statement returns null:
    SessionCookie cookie = container.getSessionCookie(am);
    Is there another way to do this?

    Add the following code to your managed bean.
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext extContext = facesContext.getExternalContext();
    Application app = facesContext.getApplication();
    DCBindingContainer binding = (DCBindingContainer) app.getVariableResolver().resolveVariable(facesContext, "bindings");
    DCDataControl dcCtl = binding.findDataControl("MyDataControl");
    ApplicationModule appModule = dcCtl.getApplicationModule();
    ViewObject vo = appModule.findViewObject("MyView");

  • How to access script from within Bridge

    I have considerable experience scripting InDesign, but this is my first
    Bridge script...
    The following script does what I want from within the ESTK, but I have
    no idea what to do to make it runnable from within Bridge... :(
    Any pointers?
    var brSel = app.document.selections[0].spec.toString();
    var bt = new BridgeTalk();
    //brSel = brSel.toSource();
    bt.target = "indesign";
    theScript = "var IDsel = app.selection[0]; \n";
    theScript += "if (IDsel instanceof Graphic){ \n";
    theScript += "var theGraphic = IDsel;\n";
    theScript += "}else{\n";
    theScript += "var theGraphic = IDsel.graphics[0];\n";
    theScript += "}\n";
    theScript += "var theFile = File(\""+brSel+"\");\n";
    theScript += "theGraphic.itemLink.relink(theFile);\n";
    theScript += "theGraphic.itemLink.update();\n";
    bt.body=theScript;
    bt.send()
    Thanks,
    Harbs

    Harbs,
    There isn't anything like a scripts palette in Bridge.
    Because your working on a selection, you'll need to add a menu item to bridge.
    You can also navigate to the folder containing the scripts and double click it. But then the script is the selection...
    Bob

  • Error when accessing Entity from JSP

    I'm trying to develop an application in Jboss AS.
    I have an Entity Class named Users and a stateful session named LoginActionBean which has the following method:
      public Users checkUser(String t1,String t2){
             Users test = (Users) em.createNamedQuery("Users.login").setParameter("userUsername",t1).setParameter("userPwd",t2).getSingleResult();
                return test;
        }In my jsp file, I try to do the following:
    Users a;
    public void jspInit() {
        try {
            InitialContext ic = new InitialContext();
            bci = (LoginActionLocal) ic.lookup("deytera_pasxa/LoginActionBean/local");
        } catch (Exception ex) {
            System.out.println("Error:"+
                    ex.getMessage());
    try {
        s2 = request.getParameter("username");
        s3 = request.getParameter("password");
        if (s2 != null && s3 != null) {
                a = bci.checkUser(s2,s3);
    .....I get no compilation error but when I try to run it I get:
    20:28:08,650 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
    java.lang.NoSuchMethodError: ejb.LoginActionLocal.checkUser(Ljava/lang/String;Ljava/lang/String;)Lejb/Users;
            at org.apache.jsp.isLogged_jsp._jspService(isLogged_jsp.java:90)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
            at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
            at java.lang.Thread.run(Thread.java:595)at the moment checkUser() is called. If I change the method's return type to let's say boolean and change the code, it works perfectly fine!
    I'm stuck here for 3 hours, any help much appreciated.
    Edited by: SyMpToM on May 5, 2008 11:03 AM
    Edited by: SyMpToM on May 5, 2008 11:04 AM

    The form action event is in a javascript function. I am sorry I mentioned that I am accessing this servlet from JSP. Actually,this servlet is accessed from an HTML document.
    The following is the javascript code:
    <script language="javascript">
    function lfnCallNext()
         alert("In the function");
         frmMain.method="POST";
         frmMain.action="/TestServlet";
         frmMain.hidChoice.value="GetList";
         frmMain.submit();
    </script>
    And this function is called from an hyperlink as follows:
    Work with Employee Database
    Thanks,

  • "Page not found or not available" error when accessing workitem from UWL

    Hi SAP Gurus,
    I encounter a perculiar problem in our portal system, was wondering if any of you guys encounter it before.
    When one of the users accesses the UWL screen and click on a particular workitem(approve trips), he gets a portal error message "Page not found or not available".
    Usually we get this message if the user does not have some form of authorization, but the things is I have setup the permissions of the UWL for "end-user" for "everyone" and all existing roles in the portal.
    heres our systems setup:
    -R/3 4.7
    -ITS 6.2
    -EP7
    -Authentication through LDAP server, the roles in the server are tied to the groups that the LDAP ID is tied to.
    The funny thing is, only this particular user has the problem, other users with the same roles didn't encounter such message. Also, the user do not have problem accessing to other UWL workitems, (eg, leave approval, claims, etc) only the Trips Approval have the problem.
    Anyone have any ideas? Could it be some roles in the R/3 side. Any suggestions?
    As usual, point will be awarded to useful answers.
    Regards,
    Jansen

    Answered for myself.  My situation related to the Credit/Dispute Management application. In my case, a standard task type was also defined for another application.  I had re-prioritize the xml configuration for Credit Manager, and modify the xml to include a system alias within the item configuration.  Now, my item is using the correct configuration and tasks are launching correctly from the UWL.
    Thanks!
    - David
    PS - Did not need to do back-end configuration.
    Message was edited by: David Karpman

  • NullPointerException while accessing .Properties from JAR

    Hi,
    I have created a JAR file which contains the .class as well as .properties in my application. Similarly when generating the JAR i have included the respective JAR's as well as the Main class of the app. in the Manifest.MF file.
    Below is the code i am using to load the properties from the LoggerConstants.
    if (properties == null) {
                   try {
                        properties = new Properties();
                        properties.load(Thread.currentThread().getContextClassLoader()
                                  .getResourceAsStream (LoggerConstants.LOGGER_PROPERTIES_PATH));
                        PropertyConfigurator.configure(properties);
                   } catch (IOException ioe) {
                        throw new LoggerException("unable to load file="
                                  + LOGGER_PROPERTIES_PATH, ioe);
    When i access the JAR in other app. by putting that in the build path, i am getting the following exception:-
    Exception in thread "main" java.lang.NullPointerException
         at java.util.Properties$LineReader.readLine(Properties.java:418)
    It seems that it is not able to pick the .properties which is there in the JAR file? But it is able identify the .class file?
    I tried by copying the same in the ANT Class path in eclipse, but still the problem persists. What i need to make sure that the .properties will be identified by the other app (App. 2)? Please shed some light into this.
    Thanks,
    Rithu

    Thanks Guys, the logger.properties will be under the classpath in the eclipse which will be under " src/com/example/logger.properties" directory. To brief , i am going to give this logger app. by compressing it in the JAR and will send to another machine , they need to use this JAR in their application and make use of the LogLevels i have created. The same will be done for other app. as well. So a Single Logger comp. which is build independently will be used by other standalone app. which needs to log the information.
    1) So, when i give the "LoggerComponent" JAR to other application. they should not modify any code (or create any classes) to use the .class or the .properties of the JAR?
    2) .class may not be a problem, but with .properties which may be a problem, hence are you saying that we need to load the logger.properties again in the referenced app. explictly, like wise do it for other app. which is going to use it? Because from my side i will give the Logger Comp. JAR to the other machines, just they need to use it as it is, without any modification in their code.
    3) Moreover when i create a JAR whether i need to package log4j.jar as well as other dependent JAR for the logger app.? So that the other reference app. dont have their own log4j.jar in their system to make use of it? Whether that makes sense or we should package a JAR with other JAR's(dependent JAR of the app.)?
    4) Ok. say if i am going to access the properties in my JAR in the reference app., like:-
    String sConfigFile = "src/com/example/logger.properties";
    InputStream in = LoggerTest.class.getClassLoader().getResourceAsStream(sConfigFile);
    if (in == null) {
         //File not found! (Manage the problem)
    Properties props = new java.util.Properties();
    props.load(in);
    LogManager logManager = new LogManager(); // Main class in the LoggerApplication JAR used in the reference app.
    logManager.logMessage("Test log msg");
    I will load properties and invoke the main class in JAR like above? Please clarify these queries. Thanks for the support
    Thanks,
    rithu

Maybe you are looking for