Tuesday, June 21, 2011

Oracle Weblogic 10.3.4

After installing Oracle Weblogic 10.3.4 zip installation on Window XP I was wondering how to create JNDI Data Source using the admin console and did not find a way. So finally I have to write my WLST script and after that I started to like WLST and was amazed with so many things that you can do with this little tool. Below is the WLST script to create Datasource using properties file.

1. Save WLST as CreateDataSource.py
2. Save the below properties file as domain.properties
3. For running WLST scripts follow this link

#Conditionally import wlstModule only when script is executed with jython
if __name__ == '__main__': 
    from wlstModule import *#@UnusedWildImport

from java.io import FileInputStream

propInputStream = FileInputStream("PATH_TO_PROP_FILES/domain.properties")
configProps = Properties()
configProps.load(propInputStream)

print 'starting the script ....'

connect(configProps.get("domain.admin.username"),
        configProps.get("domain.admin.password"), 
        configProps.get("domain.admin.url"))


edit()
startEdit()

server= configProps.get("domain.server.name")

print 'server is ' + server

cd("Servers/"+server)
target=cmo
cd("../..")

dsname=configProps.get("domain.ds.name")
jndiname=configProps.get("domain.jndi.name")
jdbc_url =configProps.get("domain.ds.jdbc.url")
jdbc_driver= configProps.get("domain.ds.jdbc.driver") 
jdbc_user=configProps.get("domain.ds.jdbc.user")
jdbc_pwd=configProps.get("domain.ds.jdbc.pwd")

# start creation
print 'Creating JDBCSystemResource with name '+dsname
jdbcSR = create(dsname,"JDBCSystemResource")
theJDBCResource = jdbcSR.getJDBCResource()
theJDBCResource.setName(dsname)

connectionPoolParams = theJDBCResource.getJDBCConnectionPoolParams()
connectionPoolParams.setConnectionReserveTimeoutSeconds(25)
connectionPoolParams.setMaxCapacity(100)
connectionPoolParams.setTestTableName("SQL SELECT 1 FROM DUAL")
connectionPoolParams.setConnectionCreationRetryFrequencySeconds(100);

dsParams = theJDBCResource.getJDBCDataSourceParams()
dsParams.addJNDIName(jndiname)


driverParams = theJDBCResource.getJDBCDriverParams()
driverParams.setUrl(jdbc_url)
driverParams.setDriverName(jdbc_driver)

driverParams.setPassword(jdbc_pwd)
driverProperties = driverParams.getProperties()

proper = driverProperties.createProperty("user")
proper.setValue(jdbc_user)

jdbcSR.addTarget(target)

save()
activate(block="true")

print 'Done configuring the data source'

Below are the properties files

###################
 Domain-1 Details
###################
domain.name=mydomain
domain.admin.url=t3://localhost:7001
domain.admin.username=weblogic
domain.admin.password=WL_PASSWORD
domain.server.name=myserver

domain.ds.name=JDBCDataSource
domain.jndi.name=jdbc.tempDS 


domain.ds.jdbc.url=jdbc:oracle:thin:@SERVER_NAME:1521:SERVER_INSTANCE
domain.ds.jdbc.driver=oracle.jdbc.driver.OracleDriver
domain.ds.jdbc.user=scott
domain.ds.jdbc.pwd=tiger

Tuesday, August 24, 2010

Setup Prime Faces in Tomcat 6.0 or >




Prime Faces is awesome it rocks!! Components are sleek and simple. I haven't had a chance to deploy any real time applications yet but I am eagerly waiting for an opportunity to work with JSF 2.0 and Prime Faces frameworks.

Setting up prime faces is simple and the documentation for prime faces is good and has all the details but I had to do little bit of digging and it took couple of hours to setup. I will try to reduce your work.

1. Download tomcat 6 or greater.
2. Copy jsf-api-2.0.2-FCS.jar and jsf-impl-2.0.2-FCS.jar to TOMCAT_HOME\lib directory for tomcat 6 only. If you have installed tomcat 7 ignore this step. Additionally, to make JSTL-1.2 to work in tomcat6 you need to copy el-api-2.2.jar to your TOMCAT_HOME\lib folder, and the el-impl-2.2.jar to your WEB-INF/lib folder and add below context param to web.xml depending on which JSF implementation (myfaces or sun RI).


3. Download primefaces JSF 2.0 jar file primefaces-2.1-SNAPSHOT.jar
4. From MyEclipse create a new web application project. Make sure you have JDK 5 or greater. I am using JDK 1.6 version.
5. MyEclipse will create web.xml for you. Copy the below the contents to web.xml




















7. Copy all the required jar file to the project classpath and also copy them to WEB-INF\
lib directory of the web application.
8. Deploy your web app.


Update: PrimeFaces had it’s own resource servlet to load resources, now with 2.2.M1 it is gone now since primefaces migrated resource management to JSF 2.0 Resource APIs.

Tuesday, October 28, 2008

Monday, March 12, 2007

DWR-2.0.rc2 + Spring 2.0 integration

Steps to integrate DWR with Spring 2.0 using new Name Spaces that were introduced. The integration currently works with Spring 2.0 and DWR-2.0RC-2 versions only. This does not work with Spring 2.0.1 or 2.0.2 or 2.0.3 and DWR-2.0RC-2, in order to work with spring 2.0+ versions you need get the current version of DWR-2.0RC-2 from HEAD of the CVS.

Step 1: Download 2.0 version of Spring form http://www.springframework.org/
Step 2: Download DWR version 2.0-rc2 from http://getahead.org/dwr/download

Copy spring and dwr jar files to the webapplication classpath.

Step 3: Add the below lines into web.xml

<servlet>

<servlet-name>dwr-spring</servlet-name>

<servlet-class>

org.springframework.web.servlet.DispatcherServlet

</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>dwr-spring</servlet-name>

<url-pattern>*.do</url-pattern>

</servlet-mapping>

<servlet-mapping>

<servlet-name>dwr-spring</servlet-name>

<url-pattern>/dwr/*</url-pattern>

</servlet-mapping>

<welcome-file-list>

<!-- index page -->

<welcome-file>index.jsp</welcome-file>

<welcome-file>index.html</welcome-file>

</welcome-file-list>


Step 4: Create the default Spring MVC context file dwr-spring-servlet.xml under WEB-INF directory of the webapplication and configure the DWR

<?xml version="1.0"
encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

http://www.directwebremoting.org/schema/spring-dwr

http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">


<!-- DWR CONFIGURATION -->

<dwr:configuration>

<dwr:create
javascript="JDate" type="new"

class="java.util.Date" />
</dwr:configuration>




<dwr:controller id="dwrController" debug="true" />

<bean id="dwrHandlerMappings"

class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">

<property name="alwaysUseFullPath"
value="true" />

<property
name="mappings">

<props>

<prop key="/dwr/**/*">dwrController</prop>

</props>

</property>

</bean>

<!-- END OF DWR CONFIGURATION -->

</beans>

Step 5: Deploy the application in Tomcat 5.5 and point the browser to http://localhost:8080/dwr-spring/dwr/index.html

If the integartion is sucessfull it should display the page with JDate link on the page.

Blow links provides more information on how to integrate DWR and Srping

http://bram.jteam.nl/index.php/2007/01/

Saturday, January 6, 2007

Tomcat 5.5 with JDK 1.4

To setup tomcat 5.5 or grater version on JDK 1.4 you need to download JDK 1.4 Compatability Package along with windows installer form http://tomcat.apache.org/. When installing the tomcat 5.5 it will by default look for JDK 5 ver, but it will still install the tomcat but when you run the tomcat it will display a message "This release of Apache Tomcat was packaged to run on J2SE 5.0 or later". To make it run under jdk 1.4 unzip the JDK 1.4 Compatability Package and copy the .jar file bin directory to the TOMCAT_HOME\bin directory and copy the .jar files under the common\endorsed to the TOMCAT_HOME\common directory. Now you should be able to run the tomcat by type in the http://localhost:8080/ in your favorite browser.

Tomcat 5.5 with JDK 1.4

To setup tomcat 5.5 or grater version on JDK 1.4 you need to download JDK 1.4 Compatability Package along with windows installer form http://tomcat.apache.org/. When installing the tomcat 5.5 it will by default look for JDK 5 ver, but it will still install the tomcat but when you run the tomcat it will display a message "This release of Apache Tomcat was packaged to run on J2SE 5.0 or later". To make it run under jdk 1.4 unzip the JDK 1.4 Compatability Package and copy the .jar file bin directory to the TOMCAT_HOME\bin directory and copy the .jar files under the common\endorsed to the TOMCAT_HOME\common directory. Now you should be able to run the tomcat by type in the http://localhost:8080/ in your favorite browser.

PF