Wednesday, May 26, 2010

Start and stop Weblogic server using boot.properties

Starting and Stopping Weblogic Server
http://download.oracle.com/docs/cd/E12839_01/web.1111/e13708/overview.htm#i1068520


Specify location of boot.properties file using -Dweblogic.system.BootIdentityFile=filename

connect(url='t3://localhost:7001')
shutdown('AdminServer','Server')
exit()



connect command

connect([username, password], [url], [timeout])
connect([userConfigFile, userKeyFile], [url], [timeout])
connect([url], [adminServerName], [timeout])

adminServerName parameter (Name of the domain's Administration Server. ) is not needed.
Causes the connect command to use the credentials that are stored in the Administration Server's boot.properties file. If the Administration Server's boot.properties file is located in the domain directory, then you do not need to specify this argument.
http://download.oracle.com/docs/cd/E12839_01/web.1111/e13708/overview.htm#i1068520

Saturday, May 22, 2010

Foreign JNDI provider - call remote EJB

Create two domains - base_domain and remote_domain.


Setup Foreign JNDI provider on base_domain pointing to remote_domain.


http://download.oracle.com/docs/cd/E12840_01/wls/docs103/ConsoleHelp/taskhelp/jndi/ConfigureForeignJNDIProvider.html






Create session EJB calling remote session EJB and deploy to base_domain.
package testEAR;

import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import remoteEAR.RemoteEJBRemote;

/**
* Session Bean implementation class CallRemoteBean
*/
@Stateless
public class CallRemoteBean implements CallRemoteBeanLocal {

public CallRemoteBean() {
}


public void callRemoteBean(){


RemoteEJBRemote remoteEJB = null;
try {
remoteEJB = (RemoteEJBRemote)new InitialContext().lookup("RemoteEJB");
} catch (NamingException e) {
e.printStackTrace();
}
System.out.println("Calling remote");
String response = remoteEJB.hello();

System.out.println("Response remote=" + response);

}

}


Create session bean on remote_domain

package remoteEAR;

import javax.ejb.Stateless;

/**
* Session Bean implementation class RemoteEJB
*/
@Stateless(mappedName = "RemoteEJB")
public class RemoteEJB implements RemoteEJBRemote {

/**
* Default constructor.
*/
public RemoteEJB() {
}

public String hello(){
System.out.println("In remote");
return "Hello from remote";
}

}


All projects created in Eclipse 3.5


EJB3 reference injection problems
http://forums.oracle.com/forums/thread.jspa?messageID=4030853

http://msikora.typepad.com/michael_sikora_on_java_ee/page/2/

http://m-button.blogspot.com/2008/07/reminder-on-how-to-use-ejb3-with.html

http://biese.wordpress.com/2008/02/20/how-to-call-ejb3-from-jsp-servlet-and-stand-alone-application/

Sunday, May 16, 2010

EclipseLink Weblogic persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="testJPA" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

<jta-data-source>jdbc/OracleDS</jta-data-source>
<non-jta-data-source>jdbc/OracleDS</non-jta-data-source>


<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
</properties>

</persistence-unit>
</persistence>


Oracle JPA Tutorial
http://www.oracle.com/technology/pub/articles/cioroianu-eclipse-jpa.html

Eclipse JPA Tutorial
http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial#Tutorial_Source

Saturday, May 15, 2010

EclipseLink Oracle Junit persistence.xml file

Running example from
Professional Oracle WebLogic Server

Using EclipseLink2.0.2
http://www.eclipse.org/eclipselink/downloads/


<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">


<persistence-unit name="TestPU" transaction-type="RESOURCE_LOCAL">

<!-- <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> -->

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

<class>com.bigrez.jpa.ValueObject</class>
<class>com.bigrez.jpa.DomainEntity</class>
<class>com.bigrez.domain.RoomType</class>
<class>com.bigrez.domain.ReservationRate</class>
<class>com.bigrez.domain.Reservation</class>
<class>com.bigrez.domain.Rate</class>
<class>com.bigrez.domain.Property</class>
<class>com.bigrez.domain.Offer</class>
<class>com.bigrez.domain.Money</class>
<class>com.bigrez.domain.Inventory</class>
<class>com.bigrez.domain.GuestProfile</class>
<class>com.bigrez.domain.CardDetails</class>
<class>com.bigrez.domain.Address</class>

<properties>

<!-- property name="eclipselink.target-server" value="WebLogic_10"/-->

<property name="eclipselink.logging.level" value="FINEST"/>
<property name="eclipselink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="eclipselink.jdbc.platform" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform"/>
<property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:xe"/>
<property name="eclipselink.jdbc.user" value="xxxxxx"/>
<property name="eclipselink.jdbc.password" value="xxxxx"/>



</properties>
</persistence-unit>
</persistence>




[EL Info]: 2010-05-15 14:38:02.033--ServerSession(22118235)--Thread(Thread[Main Thread,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.0.2.v20100323-r6872
[EL Fine]: 2010-05-15 14:38:09.491--Thread(Thread[Main Thread,5,main])--Detected Vendor platform: org.eclipse.persistence.platform.database.oracle.Oracle10Platform
[EL Config]: 2010-05-15 14:38:10.404--ServerSession(22118235)--Connection(24925706)--Thread(Thread[Main Thread,5,main])--connecting(DatabaseLogin(
platform=>Oracle10Platform
user name=> "bigrez"
datasource URL=> "jdbc:oracle:thin:@localhost:1521:xe"
))
[EL Config]: 2010-05-15 14:38:11.016--ServerSession(22118235)--Connection(24928619)--Thread(Thread[Main Thread,5,main])--Connected: jdbc:oracle:thin:@localhost:1521:xe
User: BIGREZ
Database: Oracle Version: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
Driver: Oracle JDBC driver Version: 10.2.0.1.0XE
[EL Config]: 2010-05-15 14:38:11.023--ServerSession(22118235)--Connection(24936732)--Thread(Thread[Main Thread,5,main])--connecting(DatabaseLogin(
platform=>Oracle10Platform
user name=> "bigrez"
datasource URL=> "jdbc:oracle:thin:@localhost:1521:xe"
))
[EL Config]: 2010-05-15 14:38:11.05--ServerSession(22118235)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--Connected: jdbc:oracle:thin:@localhost:1521:xe
User: BIGREZ
Database: Oracle Version: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
Driver: Oracle JDBC driver Version: 10.2.0.1.0XE
[EL Info]: 2010-05-15 14:38:12.474--ServerSession(22118235)--Thread(Thread[Main Thread,5,main])--file:/home/dave/workspace/javaEE/bigRezGenerated/build/classes/_TestPU login successful
[EL Fine]: 2010-05-15 14:38:12.941--ServerSession(22118235)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--SELECT COMMON_SEQUENCE.NEXTVAL FROM DUAL
[EL Fine]: 2010-05-15 14:38:15.348--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--INSERT INTO GUESTPROFILE (ID, LASTNAME, PHONE, EMAIL, LOGON, FIRSTNAME, PASSWORD, VERSION, CARDNUM, CARDTYPE, CARDEXP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [551, null, null, null, gp1, null, password, 1, null, null, null]
[EL Fine]: 2010-05-15 14:38:15.616--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--INSERT INTO PROPERTY (ID, PHONE, DESCRIPTION, FEATURES, IMAGEFILE, VERSION, POSTALCODE, ADDRESS1, STATECODE, ADDRESS2, CITY) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [552, phone, description, features, null, 1, 5, 1, 4, 2, 3]
[EL Fine]: 2010-05-15 14:38:15.714--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--INSERT INTO ROOMTYPE (ID, SMOKINGFLAG, DESCRIPTION, FEATURES, NUMROOMS, MAXADULTS, VERSION, PROPERTY_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
bind => [553, false, description, features, 0, 0, 1, 552]
[EL Fine]: 2010-05-15 14:38:15.8--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--INSERT INTO GUESTPROFILE (ID, LASTNAME, PHONE, EMAIL, LOGON, FIRSTNAME, PASSWORD, VERSION, CARDNUM, CARDTYPE, CARDEXP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [557, null, null, null, gp2, null, password, 1, null, null, null]
[EL Fine]: 2010-05-15 14:38:15.805--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--INSERT INTO RESERVATION (ID, DEPART, CONFIRMNUM, ARRIVE, VERSION, GUESTPROFILE_ID, ROOMTYPE_ID, CARDNUM, CARDTYPE, CARDEXP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [555, 1970-01-01, 1722831502, 1970-01-01, 1, 551, 553, number, type, expiry]
[EL Fine]: 2010-05-15 14:38:15.816--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--INSERT INTO RESERVATION (ID, DEPART, CONFIRMNUM, ARRIVE, VERSION, GUESTPROFILE_ID, ROOMTYPE_ID, CARDNUM, CARDTYPE, CARDEXP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [556, 1970-01-01, 1722791483, 1970-01-01, 1, 557, 553, number, type, expiry]
[EL Fine]: 2010-05-15 14:38:15.817--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--INSERT INTO RESERVATION (ID, DEPART, CONFIRMNUM, ARRIVE, VERSION, GUESTPROFILE_ID, ROOMTYPE_ID, CARDNUM, CARDTYPE, CARDEXP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [554, 1970-01-01, 1723770378, 1970-01-01, 1, 551, 553, number, type, expiry]
[EL Fine]: 2010-05-15 14:38:15.987--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--SELECT ID, LASTNAME, PHONE, EMAIL, LOGON, FIRSTNAME, PASSWORD, VERSION, CARDNUM, CARDTYPE, CARDEXP FROM GUESTPROFILE WHERE (ID = ?)
bind => [551]
[EL Fine]: 2010-05-15 14:38:16.074--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--SELECT ID, DEPART, CONFIRMNUM, ARRIVE, VERSION, GUESTPROFILE_ID, ROOMTYPE_ID, CARDNUM, CARDTYPE, CARDEXP FROM RESERVATION WHERE (GUESTPROFILE_ID = ?)
bind => [551]
[EL Fine]: 2010-05-15 14:38:16.171--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--SELECT ID, SMOKINGFLAG, DESCRIPTION, FEATURES, NUMROOMS, MAXADULTS, VERSION, PROPERTY_ID FROM ROOMTYPE WHERE (ID = ?)
bind => [553]
[EL Fine]: 2010-05-15 14:38:16.19--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--SELECT ID, PHONE, DESCRIPTION, FEATURES, IMAGEFILE, VERSION, POSTALCODE, ADDRESS1, STATECODE, ADDRESS2, CITY FROM PROPERTY WHERE (ID = ?)
bind => [552]
[EL Fine]: 2010-05-15 14:38:16.206--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--SELECT ID, LASTNAME, PHONE, EMAIL, LOGON, FIRSTNAME, PASSWORD, VERSION, CARDNUM, CARDTYPE, CARDEXP FROM GUESTPROFILE WHERE (ID = ?)
bind => [557]
[EL Fine]: 2010-05-15 14:38:16.227--ClientSession(21859967)--Connection(24939581)--Thread(Thread[Main Thread,5,main])--SELECT ID, DEPART, CONFIRMNUM, ARRIVE, VERSION, GUESTPROFILE_ID, ROOMTYPE_ID, CARDNUM, CARDTYPE, CARDEXP FROM RESERVATION WHERE (GUESTPROFILE_ID = ?)
bind => [557]