Configuring Log4j for a EJB Project.

Hi,
I have a weblogic EJB project as a Ear file. The project has no web components (so war file). I want to know which is the ideal way to initialize log4j in this situation.
I can use listener class thro' weblogic-application.xml. But there is no neat way to passing the log4j.xml thro' parameter from weblogic-applicaiton.xml file.
If we are using servlet we could use init-parm to passing xml file. I don't want to hard code the xml file location in the listener class.
What is the best practice to initialize log4j for a EJB project?
Thanks in advance.
Anand

Dan,
I had a similar problem because I wanted to define my own log4j config regardless of what other portal apps were deployed in the BEA domain or what log4j was the default for the domain. This is what I do:
1) Put your log4j config file in the WEB-INF classes dir (or I guess it could be in some other place that the CLASSPATH knows of)
2) Create a servlet that looks like:
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.xml.*;
public class Log4jInitServlet extends HttpServlet {
private static final long serialVersionUID = 23456;
public void init(ServletConfig config) throws ServletException {
super.init(config);
DOMConfigurator.configure(Thread.currentThread().getContextClassLoader().getResource("myLog4jConfigFile.xml"));
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
3) Add the servlet definition in the web.xml and add a <load-on-startup>1</load-on-startup>
That should do it.
- Peter

Similar Messages

  • Configuring Maven for a new Project

    Could anyone provide inputs on how to configure Maven for a new project?
    I am referring to links
    http://maven.apache.org/guides/getting-started/index.html#How%20do%20I%20setup%20Maven?
    http://maven.apache.org/guides/mini/guide-creating-archetypes.html
    Rgds,
    seetesh

    We are introducing a new feature in Flex 2.0.1 that's due out
    early next year. The feature is called "Modules" and it was
    discussed at this year's MAX 2006. You can read more about it on
    Roger Gonzalez's blog:
    http://blogs.adobe.com/rgonzalez/
    - check the "Modular Applications" articles. I think this will go a
    long way to making the reusable parts you are talking about.
    Flex does not build things from instructions unless they are
    written in ActionScript. We have customers that do create dynamic
    interfaces based on data loaded from a database, so it is possible.
    But if you have pre-built templates and all you need to do is
    change certain aspects at runtime, it should be pretty easy with
    Flex. Take a look at the Flex documentation, especially the part
    about the Flex framework and how Flex sources are compiled into
    SWFs.
    You style Flex components using style sheets (CSS files).
    This also includes specifying skins for components if you decide to
    give something a whole new look.
    I'm a bit biased here, but I think using ColdFusion (version
    7.0.2) with Flex 2 is very easy. But it depends on your needs,
    budget, deployment, etc. WIth CF 7.0.2 and Flex Builder 2 you get
    wizards to be build both CFC (ColdFusion components) and matching
    ActionScript objects so that you exchange objects, not just data,
    between Flex and CF.
    WebServices can also be used (with CF, too). This gives you
    more choices to the backend. If you have a large amount of data or
    it is complex, consider Flex Data Services as that has data
    management capabilities.
    Flex 2 has localization capabilties. You create a 'resource
    bundle' in various languages and build SWFs for each one. When the
    end user choses their preference, take them to the page that loads
    the appropriate SWF.
    HTH

  • Configuring Log4j for weblogic

    Hi
    can any one tell me how to configure Log4j for weblogic. I have added the log4j jar files to the weblogic classpath but it does not seem to work..
    Thanks and Regards
    Narayan

    You must make a new directory on the same level with applications directory, place "log4j.properties" file in it, include this directory in the "PRE_CLASSPATH" entry in your startup script and that's all.
    Sample line in "startWebLogic.cmd" script
    'set PRE_CLASSPATH=%_LIBJARS%;classes'
    in classes dir you have "log4j.properties"
    Should work,
    Cristian Negoita

  • Common library class (with injection) for different EJB projects

    I want to write a utility class named DBUtil
    with methods like
    bool checkExist(String tableName, String columnName, String value);This class will use a EntityManager reference to have access to a database.
    The point is that I would like it to be injected the EntityManager corresponding
    to the EJB project where it is used. This is,
    if DBUtil is used in project EJB-A with EntityManager-A then DBUtil accesses
    EntityManager-A, but it accesses EntityManager-B if used in project EJB-B.
    What is the best approach?
    I tried DBUtil having a constructor receiving an EntityManager ref.
    But I failed to instantiate DBUtil from the default constructor of a SessionBean
    in a EJB project. (It is like that default constructor is not used).
    Perhaps I have to deepen into SessioBean lifecycle.
    Any suggestion will be very appreciated.
    JordiBM

    I respond to myself:
    JordiBM wrote:
    I want to write a utility class named DBUtil
    with methods like
    bool checkExist(String tableName, String columnName, String value);This class will use a EntityManager reference to have access to a database.
    The point is that I would like it to be injected the EntityManager corresponding
    to the EJB project where it is used. This is,
    if DBUtil is used in project EJB-A with EntityManager-A then DBUtil accesses
    EntityManager-A, but it accesses EntityManager-B if used in project EJB-B.
    What is the best approach?
    I tried DBUtil having a constructor receiving an EntityManager ref.
    But I failed to instantiate DBUtil from the default constructor of a SessionBean
    in a EJB project. (It is like that default constructor is not used).
    Yes. The constructor of the SessionBean is not the right place to do that.
    The right place is to write a method in the SessionBean class
    annotated with @PostConstruct
    This method is called after the injection has taken place:
    @Stateful
    public class MySessionBean {
       @PersistencyContext
       private Entitymanager em; // the EM of *this* project
       private DBUtil myUtil;  // the utility class of many projects
      @PostConstruct
      public void my_init () {
        myUtil = new DBUtil (em); // we pass it this project's EM.
      public void aMethod () {
        // use myUtil
        myUtil.doSomething();
    }

  • Configuration docs for construction engineering projects.

    Dear Gurus,
    pls provide the conf steps and blue print for construction engineering projects.
    The following are the diff sales senarios.
    1.Residential sales
    2.commercial sales
    3.service
    4.lease
    5.scrap sales
    Regards
    RAMS

    Hi Rams,
    {Do reward points for good answers so that you are encouraging the members to help you and others in a better and clear way}
    Residential Customers:
    http://www8.sap.com/businessmaps/BEED3A34D61C4FA4BCE5839375C4545E.htm
    Regards
    AK

  • Help on Configuring Log4j for Websphere

    Hi All,
    I want to disable logging for my application.its writing huge output.
    i changed log4j.properties file but no effect,even if i am completely removing this prop file ,its writing.wat could be the reason?.I think its taking from some other location but couldnt find.i am new to websphere so please help me.is it posible that its not using log4j at all??
    Cheers:
    Akash.

    Hello,
    the ´ip address dhcp´ command was introduced in IOS version 12.1(2)T. You are running 12.0, so you would have to upgrade your IOS in order for the command to be supported...
    Regards,
    Nethelper

  • Log4j for EJB3

    How can I configure log4j for ejb3? for example in jsf I create servlet listener initialize logger with some config file (defined in web.xml) and call
    it from my beans.
    private Logger log = null;
    constructor () {
    log = Logger.getLogger(MyRegister.class);
    }ho can i do this correctly only for EJB3?

    I think a better way of logging EJBs is the use of interceptor. This is the approach I use.
    Get a regular java class that offers logging services using log4j
    create a business interceptor for you EJB business services
    add the interceptor annotation to your EJBs with the class name for you interceptor.
    I think this approach is better so you don't mingle business code with utility code.
    thank God for interceptor.
    Regards.

  • EJB project IDE build dos not include properties files

    We have property files also which we want included as part of the build process
    for EJB projects but if we use the IDE build it does not include them. We have
    to therefore export the IDE build and customize it to include *.properties like
    this
    <zip basedir="${dest.path}" zipfile="${ejb.outputJar}" encoding="UTF8"> <!-- JARs
    filenames are encoded UTF8 --> <zipfileset dir="${project.local.directory}" includes="*.properties"
    /> </zip>
    which causes a problem for us because the exported build file is specific to a
    user's local PC and cannot be used in a team environment.
    How can we have the IDE build include all the files within an EJB project i.e.
    include properties files also.

    Hey Jamie,
    Currently there is no support to include other .properties files into
    the internal build. There's a build.properties that you get as part of
    an EJB project which you could place your values into and use that as
    your template for your team based development and check that into your
    source control.
    If you'd really like to get gross and hack Workshop a little bit you
    could modify the default EJB project template to use your .properties
    file for every EJB project you create. This would then splat a copy of
    your .properties file into the root of the EJB project.
    To do that you'd go to {your BEAHOME}\workshop\templates and crack open
    the ejb-project.zip template zip file and merge your settings into the
    existing build.properties file. This has the same
    effect as replacing the .properties file after you've created your
    project only it keeps you from having to perform that step each time.
    The downside of this is that each person on your team would then have to
    update that template zip file in their workshop installation. (I'd make
    sure to backup the original template file before performing this
    activity so you can always go back to the original template).
    Hope this helps,
    -Michael
    Jamie wrote:
    We have property files also which we want included as part of the build process
    for EJB projects but if we use the IDE build it does not include them. We have
    to therefore export the IDE build and customize it to include *.properties like
    this
    <zip basedir="${dest.path}" zipfile="${ejb.outputJar}" encoding="UTF8"> <!-- JARs
    filenames are encoded UTF8 --> <zipfileset dir="${project.local.directory}" includes="*.properties"
    /> </zip>
    which causes a problem for us because the exported build file is specific to a
    user's local PC and cannot be used in a team environment.
    How can we have the IDE build include all the files within an EJB project i.e.
    include properties files also.

  • Workshop, ant, and ejb project

    I exported an ant build file from the workshop for an ejb project. I ran
    the build from the command line. I got the following exception:
    java.lang.NoClassDefFoundError: com/bea/ide/Application
    at
    com.bea.wls.build.DeleteModuleTask.execute(DeleteModuleTask.java:32)
    at org.apache.tools.ant.Task.perform(Task.java:319)
    at org.apache.tools.ant.Target.execute(Target.java:309)
    at org.apache.tools.ant.Target.performTasks(Target.java:336)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
    at org.apache.tools.ant.Main.runBuild(Main.java:610)
    at org.apache.tools.ant.Main.start(Main.java:196)
    at org.apache.tools.ant.Main.main(Main.java:235)
    Any ideas, suggestions, workarounds?
    Your help in this regard is greatly appreciated...

    DESCRIPTION:
    If you have overloaded methods with the same parameter name but the different parameter type and running EJBGen on the bean, all the overloaded methods are not included in the Remote interface.
    Like if you have the following methods:
    1)-public Record getRecord(Integer pRecordId)
    2)-public Record getRecord(Integer pRecordId, String str)
    3)-public Record getRecord(Integer pRecordId, double str)
    running EJBGen on it will include only the method 1 and the method 2 in the remote interface.
    Does this match what you were seeing? (the WLS CR is marked as fixed in 10.0 - patch is requested for 9.2/9.1)

  • EJB project creation in Eclipse

    Hi All,
    i am using Eclipse 3.2 to create an EJB module.
    i created a new EJB project......in it in ejbModule, i created a package and a JAVA class in it...........
    when in the JAVA class, i wrote import javax.ejb.SessionBean; it gave error on javax.ejb saying "javax.ejb cant be resolved"............
    Can anybody suggest how to rectify this error.
    Thanks,
    Rajeev Gupta

    Hi All,
    i created a jar file for my ejb project...........
    Now i imported that jar file in a new java prj, then i am able to instantiate that ejb class in the main method of the new java prj.........
    In the window i can also see all methods of the ejb class.........
    My ejb-jar xml file is having the below content:
    <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
         <description>Hello World EJB description</description>
         <display-name>prjHelloWorldEJB</display-name>
         <enterprise-beans>          
                   <ejb-name>HelloWorldEJB</ejb-name>
                   <ejb-class>pkgHelloWorldEJB.HelloWorldEJB</ejb-class>               
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>          
         </enterprise-beans>
    </ejb-jar>
    Like i declared a function:
    public String strReturn(){
              return "Hello JAVA EJB World";     
    When i called this function by obj.strReturn() then no compilation error was there.
    <b>But when i run this JAVA prj application, it gave error java.lang.NoClassDefFoundError: pkgEJB/ClassEJB
         at pkg.class.main of JAVA prj application</b>.
    Can anybody suggest me what should i do to rectify this situation.
    Thanks,
    Rajeev Gupta

  • EJB project in Eclipse 3.2

    Hi All,
    i am trying to develop a demo EJB project in Eclipse 3.2 so after it i can use it in some other demo project.....i am not developing a adapter module.....i am developing a simple EJB project by implementing SessionBean only.
    now i am facing a problem that     i am not able to see EJB Candidate   in  my EJB-Project, so i am not able to add my class file to ejb-jar xml file........i am also not able to see ejb-j2ee-engine.xml............
    So can anybody help me to rectify this situation.
    Thanks,
    Rajeev Gupta

    Hi Wang,
    i am not developing a adapter module......i am developing just a demo ejb project in Eclipse 3.2 for using it in another java prj.....well my above problem is resolved now...........
    now i am facing the below issue:
    i created a jar file for my ejb project...........then i imported that jar file in a new java prj, then i am able to instantiate that ejb class in the main method of the new java prj.........
    In the window i can also see all methods of the ejb class.........
    My ejb-jar xml file is having the below content:
    <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
    <description>Hello World EJB description</description>
    <display-name>prjHelloWorldEJB</display-name>
    <enterprise-beans>
    <ejb-name>HelloWorldEJB</ejb-name>
    <ejb-class>pkgHelloWorldEJB.HelloWorldEJB</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </enterprise-beans>
    </ejb-jar>
    Like i declared a function:
    public String strReturn(){
    return "Hello JAVA EJB World";
    When i called this function by obj.strReturn() then no compilation error was there.
    <b>But when i run this JAVA prj application, it gave error java.lang.NoClassDefFoundError: pkgEJB/ClassEJB
    at pkg.class.main of JAVA prj application.</b>
    Can anybody suggest me what should i do to rectify this situation.
    Thanks,
    Rajeev Gupta

  • How to call external jar files in EJB project for CE

    Hi,
    I would be thankful if someone could help me with this -
    I need to call the external jar files into my EJB project - Here is what I have done and am getting runtime exception as  -
    java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/glance/pdf/pt/PTDoc
    1. Created a EJB  project" HelloWorld "  using Java perspective in NWDS 7.1 called with client as HelloWorldClient and EAR project as HelloWorldEAR.
    2. Am working on HelloWorld project (1st one).
    3. In my code I am instantiating a class which is a class in one of  the external jar file that I need to refer in my project.
    4. I have set the Java Build path but it works only for the compile time and fails during runtime.
    5. Have read I need to create external library DC and refer in my project "HelloWorld".
    Can anyone help me with exact steps what needs to be done - during creation of external library project and then for my "HelloWorld" EJB project. How would I be able to reference or set the external library project in my EJB project?
    Looking forward to hear from experts.
    Thanks,
    Shiv
    Edited by: Shiv Khullar on Aug 30, 2010 9:39 PM

    Hi Edson,
    I tried it , but it still gives me runtime exception.
    javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/glance/pdf/pt/PTDoc
    java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/glance/pdf/pt/PTDoc
    Steps I performed are -
    1. Created a library project and created 2 Public parts "Compilation" and "Assembly"
    2. Build the library project.
    Now in my EJB project using Project Explorer - set the classpath and added both compilation jar and assembly jar files.
    This is how the classpath entries for external library looks like -
    <classpathentry kind="lib" path="/LocalDevelopmentLocalDevelopmentexternallibrarypdftoolsforwatermarkingdemo.sap.com/gen/default/public/WatermarkAssembly/lib/java/demo.sap.comexternallibrarypdftoolsforwatermarking~WatermarkAssembly.jar"/>
         <classpathentry kind="lib" path="/LocalDevelopmentLocalDevelopmentexternallibrarypdftoolsforwatermarkingdemo.sap.com/gen/default/public/WatermarkCompilation/lib/java/demo.sap.comexternallibrarypdftoolsforwatermarking~WatermarkCompilation.jar"/>
    I have also added the jar files I used in my external library project as "User Library" from Java Build Path . I dont do it , then the code fails during compilation itself.
    Regards,
    Shiv

  • How to configur log4j logging for weblogic 10.1

    Hi,
    I am tried to set log4j logging for my application running in weblogic 10.1. I set a log4j.properties file and loaded the properties by a servlet. Where its load the properties files and configure it by PropertyConfigurator.
    The same logic has worked out in websphere. But in weblogic, it is not working. I set the server logging and domain logging to Log4j in Admin console. Now it is writing all the log statements.
    If i write a property for a package to Error level and root level is Debug. Its not working, all debug statements are getting written.
    Can you please tell me the steps to configure log4j logging in weblogic 10.1.
    Thanks & Regards,
    Nasrin.N

    Did you manage to get this working?
    If yes ... what did you do?
    I am having the same problem implementing commons-logging with log4j

  • Problem in getting Updated EJB methods in JSC for a Same Project

    I'm Using Sun Studio Enterprise for developing EJB sets.After that i'm importing the EJB set in to JSC & using it my Project.
    If i need to add some more business methods/edit the business method i'm able to do that in the Sun Enterprise IDE.After editing the EJB ,redeploying & reimporting to JSC i couldn't get the updated version of EJB in my Current Project.
    We could be able to get the updated EJBs,if we are using it in a new project other than using it in the Previous one.
    It's being a great problem for me.Vat shall i do for this problem?Please help me,a project is in Pending stage because of this problem.
    Regards
    Kajanan

    Hi MWH@Keystroke,
    Thanks for your consideration of my problem.I also use an EJB layer built in Sun Enterprise for the backend to my Creator-based web application.My Current problem is getting the updated EJB sets to my current project.
    For Ex:
    If i add a new Business method called doSomething( ),then i should be able to get that method in JSC using FinalFacadeRemoteClient1.doSomething().
    But after typing FinalFacadeRemoteClient. , doSomething() method is not displaying.
    If i use that in a new project [Previously not used Same Session Facades]all the updated EJB business methodss are coming.I want to use updated EJBs in the project i'm already working.
    Regards
    Kajanan

  • OSB: EJB Transport Configuration - Workshop for Weblogic 10.3

    Hi
    I'm using the latest Workshop for Weblogic 10.3. to test the EJB Transport Typed Service for Oracle Service Bus 10R3.
    When I importing the EJB client jar on the EJB Transport tab of the business service configuration, the import itself first seems to work fine.
    But when I try to save the business service, I get an error on that page, which says "Error in field content". There is also a message appearing on the top of the wizard, which is only partly readable and says
    BUILD FAILED
    java.lang.NoClassDefFoundError: javax/tools/Diagnostic
    I'm trying the sample in chapter 8 from the Apress book "The definitive guide to SOA - Oracle Service Bus" and can't see what I have done wrong.
    Anyone can help?
    Thanks
    Guido
    Edited by: gschmutz on Feb 4, 2009 11:33 AM

    Make sure your JAVA_HOME is set to JRockit JDK - for details see CR374557 on [http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/relnotes/relnotes.html]:
    ClassNotFoundExceptions on Linux when configuring a client jar for an EJB business service.
    On a Linux system, if you do not specify the path to the correct version of Java correctly, you may experience ClassNotFoundException when configuring a client JAR for an EJB business service.
    Workaround: The correct Java version is 1.6.0_05.
    To check the version of Java you are using, execute java -version from a shell. If you are using some other version, you must update the PATH environment variable to point to the location of a 1.6.0_05 version of Java. Be sure to place this location before the location of the incorrect java. For example:
    export PATH=/home/user/bea/jrockit_160_05/bin:$PATH
    After making this fix, you may experience error: Generate: Error during generation of the WSDL. If so, you must update the JAVA_HOME environment variable to point to same version of Java as above. For example:
    export JAVA_HOME=/home/user/bea/jrockit_160_05
    Cheers
    Dani

Maybe you are looking for

  • SQLPLUS. How can I re-direct default outpu?

    Hello I have a problem with a program runnig on sqlplus client that never finish and I can´t get his output. Maybe, it`s blocked. I tried to get the output playing with this params: SET SERVEROUTPUT ON SIZE 1000000 SET FLUSH ON | OFF but I don´t ge

  • ALTER SYSTEM SET SGA_TARGET

    Hi, in 10g R2 should I stop/start database when I change sGA_TARGET : ALTER SYSTEM SET SGA_TARGET=value [SCOPE={SPFILE|MEMORY|BOTH}] Thank you.

  • Pictures look fine in iphoto, tiny when uploaded

    I've tried uploading pictures from my iPhoto library to Facebook, and the pictures come out really small for some reason. It's not my camera, like I orginally thought, b/c it's doing the same thing with both my and my brother's camera. It's not faceb

  • Can someone tell me what's wrong with this LOV query please?

    This query works fine.. select FILTER_NAME display_value, FILTER_ID return_value from OTMGUI_FILTER where username = 'ADAM' But this one.. select FILTER_NAME display_value, FILTER_ID return_value from OTMGUI_FILTER where username = apex_application.g

  • T61p + Windows 7 64bit + Intel AMT Drivers.

    Hi all, I've recently installed Windows 7 x64 on my T61p (6459-CTO). I've installed the drivers and all the devices and running fine except two: PCI Serial Port PCI Simple Communications Controller After a failing to find drivers for these, I googled