Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Tuesday, July 17, 2012

Configuring Web Logic 10.3.5 and log4j for your Java Application

I recently spent several days trying to track this down why Apache log4j for my Java application was working when deployed to Oracle WebLogic Server 10.3.5. I am posting my findings here in the hopes of saving others some time. I found several blogs that talked about this, but the end result was that log4j was still not working correctly. There was always one step missing. A co-worker and I finally figured it out for both Linux and Windows.

1. Copy wllog4j.jar from your WebLogic server/lib directory and place it in your domain_root/lib folder.
2. Copy your version of log4j.jar to your domain_root/lib folder.
3. Copy your log4j.xml to your domain_root folder.
4. Log in to the your WebLogic admin server console. Click on Servers -> Admin Server -> Logging. Click on advanced mode, and change the logging implementation from JDK to Log4J. Save your changes.

Most of the blogs had these items, but the one critical piece that was missing:
5. (Linux)Edit the setDomainEnv.sh file in the domain_root/bin directory. and find the following code:

if [ "${LOG4J_CONFIG_FILE}" != "" ] ; then
       JAVA_PROPERTIES="${JAVA_PROPERTIES} -Dlog4j.configuration=file:${LOG4J_CONFIG_FILE}"
       export JAVA_PROPERTIES
fi

Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:

LOG4J_CONFIG_FILE=”/u01/app/oracle/middleware/user_projects/domains/base_domain/log4j.xml”
Export LOG4J_CONFIG_FILE

5. (Windows)
Edit the setDomainEnv.cmd file in the domain_root/bin directory. and find the following code:

if NOT "%LOG4J_CONFIG_FILE%"=="" (                                                          
            set JAVA_PROPERTIES=%JAVA_PROPERTIES% -Dlog4j.configuration=file:%LOG4J_CONFIG_FILE%
)

Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:

set LOG4J_CONFIG_FILE=”C:\Oracle\Middleware\user_projects\domains\base_domain\log4j.xml”


6. Activate the changes and restart the admin server.

Here is a sample log4j.xml file. Obviously, you will need to update it for a valid location for your file appender, and replace yourcompany and yourproject with valid values.





   
   
   
    
        
        
            
            
        
    

    
        
        
        
            
        
    

    
    

    
      
    

    
        
    

    
        
    

    
    
    
        
        
    


Again, I hope that this will save someone the pain I went through to track this down.

Friday, November 11, 2011

Apache SSL with JBoss

Prerequisites
Jboss-4.2.2.GA installed

1. Install Apache 2.2
C:\Program Files\


2. Copy Apache server to new server
i. C:\Program Files\Apache Software Foundation\Apache2.2\conf\
httpd.conf
ii. C:\Program Files\Apache Software Foundation\Apache2.2\conf\uriworkermap.properties
iii. C:\Program Files\Apache Software Foundation\Apache2.2\conf\worker2.properties
iv. C:\Program Files\Apache Software Foundation\Apache2.2\conf\workers.properties.minimal
v. C:\Program Files\Apache Software Foundation\Apache2.2\conf\workers.properties

3. Get the .crt file and .key file and store it in
C:\Program Files\Apache Software Foundation\Apache2.2\conf\


4. Copy Apache server to new server (All files in module directory)
i. C:\Program Files\Apache Software Foundation\Apache2.2\modules


5. In file C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf make following changes.
i.
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkMountFile conf/uriworkermap.properties
JkMountCopy All
ii.
Uncomment/add lines

Include conf/extra/httpd-ssl.conf


iii
ServerName 127.0.0.1:443 {host name like host.domain.com}


6. In file C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-ssl.conf

make following changes.

i. {apache server ip and SSL port}

ii. ServerName 127.0.0.1:443 {host name like host.domain.com}

iii. Change the .crt and .key file name
SSLCertificateFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/ssl.crt"
SSLCertificateKeyFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/ssl.key"

7. In file C:\Program Files\Apache Software Foundation\Apache2.2\conf\workers.properties

make following changes.
i. worker.tomcat1.host=192.168.1.246 {Jboss server ip}
ii. worker.tomcat2.host=192.168.1.246 {Jboss server ip}
iii. worker.tomcat3.host=192.168.1.246 {Jboss server ip}

8. Restart Apache and type URL with apache server ip
(https://192.168.1.46/testapp/Server.jsp) {Here ip address is of Apache server }