Sunday, February 20, 2011

Access JPA2 entitites using Servlet and Session EJB

Introduction to Oracle Enterprise Pack for Eclipse 11g JPA Workbench
http://www.oracle.com/technetwork/articles/cioroianu-eclipse-jpa-084626.html

1.create Eclipse Web project testWeb


2.create Servlet calling Session EJB
package dave;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Set;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class TestJPAServlet
*/
public class TestJPAServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public TestJPAServlet() {
super();
// TODO Auto-generated constructor stub
}


@EJB
SessionJPA2EJBRemote remoteBusinessIntf;


/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

String nameParam = request.getParameter("emp");

Author author = remoteBusinessIntf.findAuthorByName(nameParam);

System.out.println("author " + author);

PrintWriter out = response.getWriter();

out.println("author" + author);

// Books
Set<Book> books = author.getBooks();

for (Book book : books) {
System.out.println("book " + book);
out.println("book" + book);
}
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}

}




3. call servlet using URL composed of testWeb project and Servlet
http://localhost:7001/testWeb/TestJPAServlet?name=dave



[EL Finest]: 2011-02-20 15:15:14.763--ServerSession(10406216)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--End deploying Persistence Unit books; session file:/home/dave/workspace/wls1033/testJPA2/build/classes/_books; state Deployed; factoryCount 1
[EL Finer]: 2011-02-20 15:15:14.763--ServerSession(10406216)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--client acquired
[EL Finer]: 2011-02-20 15:15:14.763--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--TX binding to tx mgr, status=STATUS_ACTIVE
[EL Finest]: 2011-02-20 15:15:14.764--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadObjectQuery(referenceClass=Author sql="SELECT ID, NAME, INSERT_TIMESTAMP FROM AUTHOR WHERE (ID = ?)")
[EL Finest]: 2011-02-20 15:15:14.764--ServerSession(10406216)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--reconnecting to external connection pool
[EL Fine]: 2011-02-20 15:15:14.765--ServerSession(10406216)--Connection(3587614)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--SELECT ID, NAME, INSERT_TIMESTAMP FROM AUTHOR WHERE (ID = ?)
bind => [1]
[EL Finer]: 2011-02-20 15:15:14.767--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--TX beforeCompletion callback, status=STATUS_ACTIVE
[EL Finer]: 2011-02-20 15:15:14.767--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--begin unit of work commit
[EL Finer]: 2011-02-20 15:15:14.768--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--TX afterCompletion callback, status=COMMITTED
[EL Finer]: 2011-02-20 15:15:14.769--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--end unit of work commit
[EL Finer]: 2011-02-20 15:15:14.769--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--release unit of work
[EL Finer]: 2011-02-20 15:15:14.769--ClientSession(26961217)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--client released
author dave.Author@1fbc274
[EL Finest]: 2011-02-20 15:15:14.77--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadAllQuery(name="books" referenceClass=Book )
[EL Finest]: 2011-02-20 15:15:14.77--ServerSession(10406216)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--reconnecting to external connection pool
[EL Fine]: 2011-02-20 15:15:14.771--ServerSession(10406216)--Connection(11941411)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--SELECT ID, TITLE, COUNTER, INSERT_TIMESTAMP, AUTHOR_ID FROM BOOK WHERE (AUTHOR_ID = ?)
bind => [1]
[EL Finest]: 2011-02-20 15:15:14.773--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadObjectQuery(name="author" referenceClass=Author )
[EL Finest]: 2011-02-20 15:15:14.774--UnitOfWork(25911694)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Register the existing object dave.Book@9c71bf
book dave.Book@9c71bf

Create JPA2 Weblogic 10.3.4 project in Eclipse 3.6 (OEPE)

Oracle Enterprise Pack for Eclipse User Guide
http://download.oracle.com/docs/cd/E15315_07/help/oracle.eclipse.tools.common.doc/html/index.html
Object-Relational Mappings: Configuring the Persistence Provider for JPA Projects
http://download.oracle.com/docs/cd/E15315_07/help/oracle.eclipse.tools.orm.doc/html/files/libAndFacetForJPA.html

Introduction to Oracle Enterprise Pack for Eclipse 11g JPA Workbench
By Andrei Cioroianu
http://www.oracle.com/technetwork/articles/cioroianu-eclipse-jpa-084626.html

It is necessary to change PRE_CLASSPATH in WLS10.3.4 to enable JPA2.

1.configure Server Runtime for WLS 10.3.4
http://www.oracle.com/technetwork/developer-tools/eclipse/downloads/index.html

2.create JPA project




3.create test entity tables
CREATE TABLE  "AUTHOR" 
( "ID" NUMBER,
"NAME" VARCHAR2(255),
"INSERT_TIMESTAMP" TIMESTAMP (6) DEFAULT sysdate,
CONSTRAINT "AUTHOR_PK" PRIMARY KEY ("ID") ENABLE
)
/


CREATE OR REPLACE TRIGGER "BI_AUTHOR"
before insert on "AUTHOR"
for each row
begin
select "ID_GEN".nextval into :NEW.ID from dual;
end;

/
ALTER TRIGGER "BI_AUTHOR" ENABLE
/





CREATE TABLE  "BOOK" 
( "AUTHOR_ID" NUMBER NOT NULL ENABLE,
"TITLE" VARCHAR2(256),
"INSERT_TIMESTAMP" TIMESTAMP (6) DEFAULT sysdate,
"COUNTER" NUMBER(*,0),
"ID" NUMBER(*,0) NOT NULL ENABLE,
CONSTRAINT "ID" PRIMARY KEY ("ID") ENABLE,
CONSTRAINT "BOOK_AUTHOR" FOREIGN KEY ("AUTHOR_ID")
REFERENCES "AUTHOR" ("ID") ENABLE
)
/


CREATE OR REPLACE TRIGGER "BOOK_ID"
BEFORE
insert on "BOOK"
for each row
begin3
select "ID_GEN".nextval into :NEW.ID from dual;

end;
/
ALTER TRIGGER "BOOK_ID" ENABLE
/






4.generate JPA entities from tables










package dave;

import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Set;


/**
* The persistent class for the AUTHOR database table.
*
*/
@Entity
public class Author implements Serializable {

private static final long serialVersionUID = 4224149688123855811L;

@Id
@SequenceGenerator(name="AUTHOR_ID_GENERATOR", sequenceName="ID_GEN")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="AUTHOR_ID_GENERATOR")
private long id;

@Column(name="INSERT_TIMESTAMP")
private Timestamp insertTimestamp;

private String name;

//bi-directional many-to-one association to Book
@OneToMany(mappedBy="author")
private Set<Book> books;

public Author() {
}

public long getId() {
return this.id;
}

public void setId(long id) {
this.id = id;
}

public Timestamp getInsertTimestamp() {
return this.insertTimestamp;
}

public void setInsertTimestamp(Timestamp insertTimestamp) {
this.insertTimestamp = insertTimestamp;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public Set<Book> getBooks() {
return this.books;
}

public void setBooks(Set<Book> books) {
this.books = books;
}

}

package dave;

import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.math.BigDecimal;


/**
* The persistent class for the BOOK database table.
*
*/
@Entity
public class Book implements Serializable {

private static final long serialVersionUID = -9138882871442399233L;

@Id
@SequenceGenerator(name="BOOK_ID_GENERATOR", sequenceName="ID_GEN")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BOOK_ID_GENERATOR")
private long id;

private BigDecimal counter;

@Column(name="INSERT_TIMESTAMP")
private Timestamp insertTimestamp;

private String title;

//bi-directional many-to-one association to Author
@ManyToOne
private Author author;

public Book() {
}

public long getId() {
return this.id;
}

public void setId(long id) {
this.id = id;
}

public BigDecimal getCounter() {
return this.counter;
}

public void setCounter(BigDecimal counter) {
this.counter = counter;
}

public Timestamp getInsertTimestamp() {
return this.insertTimestamp;
}

public void setInsertTimestamp(Timestamp insertTimestamp) {
this.insertTimestamp = insertTimestamp;
}

public String getTitle() {
return this.title;
}

public void setTitle(String title) {
this.title = title;
}

public Author getAuthor() {
return this.author;
}

public void setAuthor(Author author) {
this.author = author;
}

}




JPA tools Entity editor


edit persistence.xml file
<persistence version="2.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_2_0.xsd">
<persistence-unit name="books" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/XE</jta-data-source>
<class>dave.Book</class>
<class>dave.Author</class>
<shared-cache-mode>NONE</shared-cache-mode><!-- shared-cache-mode must
come after any class definitions (usually SE only) - the JPA schema is ordered -->
<properties>
<property name="eclipselink.target-server" value="WebLogic_10" />
<property name="eclipselink.target-database" value="Oracle" />
<property name="eclipselink.logging.level" value="FINEST" />
<!-- new for 10.3.4.0 http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging#Server_Logging -->
<property name="eclipselink.logging.logger" value="DefaultLogger" />
<!-- turn off DDL generation after the model is stable -->
<!-- property name="eclipselink.ddl-generation" value="drop-and-create-tables"/ -->
<!-- property name="eclipselink.ddl-generation.output-mode" value="database"/ -->
</properties>
</persistence-unit>
</persistence>




5. create Session EJB to access JPA entities

package dave;

import java.util.Set;

import javax.ejb.Stateless;
import javax.persistence.PersistenceContext;

import weblogic.javaee.CallByReference;

/**
* Session Bean implementation class SessionJPA2EJB
*/
@Stateless(mappedName = "SessionJPA2EJB")
@CallByReference
public class SessionJPA2EJB implements SessionJPA2EJBRemote, SessionJPA2EJBLocal {

/**
* Default constructor.
*/
public SessionJPA2EJB() {
// TODO Auto-generated constructor stub
}

@PersistenceContext
private javax.persistence.EntityManager books;

/* (non-Javadoc)
* @see dave.SessionJPA2Remote#findAuthor(long)
*/
@Override
public Author findAuthor(long authorId) {

Author author = books.find(Author.class, authorId);

System.out.println("author " + author);

//Books
Set<Book> books = author.getBooks();

for(Book book : books){
System.out.println("book " + book);
}

return author;
}

/* (non-Javadoc)
* @see dave.SessionJPA2Remote#findBook(long)
*/
@Override
public Book findBook(long bookId) {

Book book = books.find(Book.class, bookId);

System.out.println("book " + book);

if (book != null) {
Author author = book.getAuthor();

System.out.println("author " + author);
}

return book;
}


}




Initial loading of Persistence Unit in Weblogic
[EL Finest]: 2011-02-20 15:15:06.076--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Begin predeploying Persistence Unit books; session file:/home/dave/workspace/wls1033/testJPA2/build/classes/_books; state Initial; factoryCount 0
[EL Finest]: 2011-02-20 15:15:06.076--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--property=eclipselink.orm.throw.exceptions; default value=true
[EL Finest]: 2011-02-20 15:15:06.076--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--property=eclipselink.weaving.changetracking; default value=true
[EL Finest]: 2011-02-20 15:15:06.077--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--property=eclipselink.weaving.lazy; default value=true
[EL Finest]: 2011-02-20 15:15:06.077--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--property=eclipselink.weaving.eager; default value=false
[EL Finest]: 2011-02-20 15:15:06.077--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--property=eclipselink.weaving.fetchgroups; default value=true
[EL Finest]: 2011-02-20 15:15:06.077--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--property=eclipselink.weaving.internal; default value=true
[EL Finest]: 2011-02-20 15:15:06.078--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--property=eclipselink.jpa.uppercase-column-names; default value=false
[EL Finer]: 2011-02-20 15:15:06.078--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Searching for default mapping file in file:/home/dave/workspace/wls1033/testJPA2/build/classes/
[EL Finer]: 2011-02-20 15:15:06.079--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Searching for default mapping file in file:/home/dave/workspace/wls1033/testJPA2/build/classes/
[EL Config]: 2011-02-20 15:15:06.084--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The access type for the persistent class [class dave.Author] is set to [FIELD].
[EL Config]: 2011-02-20 15:15:06.085--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The target entity (reference) class for the one to many mapping element [field books] is being defaulted to: class dave.Book.
[EL Config]: 2011-02-20 15:15:06.086--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The access type for the persistent class [class dave.Book] is set to [FIELD].
[EL Config]: 2011-02-20 15:15:06.086--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The target entity (reference) class for the many to one mapping element [field author] is being defaulted to: class dave.Author.
[EL Config]: 2011-02-20 15:15:06.087--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The alias name for the entity class [class dave.Author] is being defaulted to: Author.
[EL Config]: 2011-02-20 15:15:06.088--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The table name for entity [class dave.Author] is being defaulted to: AUTHOR.
[EL Config]: 2011-02-20 15:15:06.088--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The column name for element [field id] is being defaulted to: ID.
[EL Config]: 2011-02-20 15:15:06.088--ServerSession(10406216)--Thread(Thread[[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--The column name for element [field name] is being defaulted to: NAME.


Execution of JPA query
[EL Fine]: 2011-02-20 11:25:09.515--ServerSession(14527944)--Connection(16230875)--Thread(Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--SELECT ID, TITLE, COUNTER, INSERT_TIMESTAMP, AUTHOR_ID FROM BOOK WHERE (AUTHOR_ID = ?)
bind => [1]
[EL Finest]: 2011-02-20 11:25:09.516--UnitOfWork(20720277)--Thread(Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadObjectQuery(name="author" referenceClass=Author )
[EL Finest]: 2011-02-20 11:25:09.517--UnitOfWork(20720277)--Thread(Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Register the existing object dave.Book@1b09a99
book dave.Book@1b09a99
[EL Finer]: 2011-02-20 11:25:09.517--UnitOfWork(20720277)--Thread(Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--TX beforeCompletion callback, status=STATUS_ACTIVE
[EL Finer]: 2011-02-20 11:25:09.517--UnitOfWork(20720277)--Thread(Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--begin unit of work commit
[EL Finer]: 2011-02-20 11:25:09.518--UnitOfWork(20720277)--Thread(Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--TX afterCompletion callback, status=COMMITTED
[EL Finer]: 2011-02-20 11:25:09.519--UnitOfWork(20720277)--Thread(Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--end unit of work commit
[EL Finer]: 2011-02-20 11:25:09.519--UnitOfWork(20720277)--Thread(Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--release unit of work
[EL Finer]: 2011-02-20 11:25:09.519--ClientSession(24495389)--Thread(Thread[[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--client released
[EL Finer]: 2011-02-20 11:52:37.358--ServerSession(14527944)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--client acquired
[EL Finer]: 2011-02-20 11:52:37.358--UnitOfWork(953536)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--TX binding to tx mgr, status=STATUS_ACTIVE
[EL Finest]: 2011-02-20 11:52:37.359--UnitOfWork(953536)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Execute query ReadObjectQuery(referenceClass=Author sql="SELECT ID, NAME, INSERT_TIMESTAMP FROM AUTHOR WHERE (ID = ?)")
[EL Finest]: 2011-02-20 11:52:37.359--ServerSession(14527944)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--reconnecting to external connection pool
[EL Fine]: 2011-02-20 11:52:37.361--ServerSession(14527944)--Connection(20630989)--Thread(Thread[[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--SELECT ID, NAME, INSERT_TIMESTAMP FROM AUTHOR WHERE (ID = ?)
bind => [1]
author dave.Author@19d6908

Saturday, February 19, 2011

Enable JPA2 in Weblogic 10.3.4

WebLogic Server 10.3.4 Released - Key APIs of Java EE 6 and More
http://blogs.oracle.com/WebLogicServer/2011/01/weblogic_server_1034_released.html

Running JPA 2.0 API on WebLogic 10.3
http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#20110115:_JPA_2.0_using_EclipseLink_on_WebLogic_10.3.4.0

Enable JPA2 by adding JPA2 jar on PRE_CLASSPATH
http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#CIHDJHHI

# Set up BEA Home
BEA_HOME="/usr/app"

PRE_CLASSPATH=$BEA_HOME/modules/javax.persistence_1.0.0.0_2-0-0.jar:$BEA_HOME/modules/com.oracle.jpa2support_1.0.0.0_2-0.jar



Create JPA2 project in Eclipse Helios 3.6
Update Server Runtime to WLS 10.3.4


Create WLS 10.3.4 domain


Edit EJB project facets


Edit JPA facet


Create JPA entities from tables


Generated JPA class
package dave;

import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.math.BigDecimal;


/**
* The persistent class for the BOOKS database table.
*
*/
@Entity
@Table(name="BOOKS")
public class Book implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@SequenceGenerator(name="BOOKS_ID_GENERATOR", sequenceName="ID_GEN")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BOOKS_ID_GENERATOR")
private long id;

private String author;

private BigDecimal counter;

@Column(name="INSERT_TIMESTAMP")
private Timestamp insertTimestamp;

private String title;

public Book() {
}

public long getId() {
return this.id;
}

public void setId(long id) {
this.id = id;
}

public String getAuthor() {
return this.author;
}

public void setAuthor(String author) {
this.author = author;
}

public BigDecimal getCounter() {
return this.counter;
}

public void setCounter(BigDecimal counter) {
this.counter = counter;
}

public Timestamp getInsertTimestamp() {
return this.insertTimestamp;
}

public void setInsertTimestamp(Timestamp insertTimestamp) {
this.insertTimestamp = insertTimestamp;
}

public String getTitle() {
return this.title;
}

public void setTitle(String title) {
this.title = title;
}

}


Edit persistence.xml
<persistence version="2.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_2_0.xsd">
<persistence-unit name="example" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/XE</jta-data-source>
<class>dave.Book</class>
<shared-cache-mode>NONE</shared-cache-mode><!-- shared-cache-mode must come after any class definitions (usually SE only) - the JPA schema is ordered -->
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.target-database" value="Oracle"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<!-- new for 10.3.4.0 http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging#Server_Logging -->
<property name="eclipselink.logging.logger" value="DefaultLogger"/>
<!-- turn off DDL generation after the model is stable -->
<!-- property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
<!-- property name="eclipselink.ddl-generation.output-mode" value="database"/-->
</properties>
</persistence-unit>
</persistence>

Tuesday, February 8, 2011

ANTLR - SWIFT fields parser

grammar SwiftBlock;

@header {
package generated;
import java.util.Map;
import java.util.HashMap;
}

@lexer::header {
package generated;
}

@members {
HashMap message = new HashMap();

public Map<String,String> getMessage(){
return message;
}

}
message : block+;

block : '{' '1' ':' expr {System.out.println("expr1=" + $expr.text);} '}' |
'{' '2' ':' expr {System.out.println("expr2=" + $expr.text);} '}' |
'{' '3' ':' expr3* '}' |
'{' '4' ':' expr4+ '}' |
'{' '5' ':' expr5+ '}' ;

expr3 : '{' key ':' expr '}' {System.out.println("expr3=" + $expr3.text);message.put($key.text,$expr.text);} ;

expr4 : ('\n'|'\r')+ (':' key ':' expr {System.out.println("expr4=" + $expr.text); message.put($key.text,$expr.text);} | '-')+;

expr5 : ('\n'|'\r')+ '{' key ':' expr '}' {System.out.println("expr5=" + $expr.text);message.put($key.text,$expr.text);} ;

key : FIELDVALUE* {System.out.println("key=" + $key.text);} ;
expr : FIELDVALUE* {System.out.println("expr=" + $expr.text);} ;


/*------------------------------------------------------------------
* LEXER RULES
*------------------------------------------------------------------*/
FIELDVALUE : (~('-'|':'|'}'|'{'))+;



Compile grammar
java -cp /app/antlr-3.3/lib/antlr-3.3-complete.jar org.antlr.Tool -o generated SwiftBlock.g 




Test program

import generated.SwiftBlockLexer;
import generated.SwiftBlockParser;

import java.io.FileInputStream;
import java.util.Map;

import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CommonTokenStream;

public class AntlrSwiftBlock {
public static void main(String[] args) throws Exception {
FileInputStream fileInputStream = new FileInputStream("/home/dave/workspace/wls1033/testAntlr/src/swift.txt");
ANTLRInputStream input = new ANTLRInputStream(fileInputStream);
SwiftBlockLexer lexer = new SwiftBlockLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SwiftBlockParser parser = new SwiftBlockParser(tokens);
parser.message();

System.out.println("Message:");

for(Map.Entry<String,String> entry : parser.getMessage().entrySet()){
System.out.println(entry);
}
}
}


SWIFT message
{1:F01AAAABB99BSMK3513951576}{2:O9400934081223BBBBAA33XXXX03592332770812230834N}{3:{113:xxxx}{108:abcdefgh12345678}}{4:
:20:0112230000000890
:25:SAKG800030155USD
:28C:255/1
:60F:C011223USD175768,92
:61:0112201223CD110,92NDIVNONREF//08 IL053309
/GB/2542049/SHS/312,
:62F:C011021USD175879,84
-}{5:
{CHK:0F4E5614DD28}
{MAC:0F4E5614DD28}}


Result output
Message:
20=0112230000000890

62F=C011021USD175879,84

113=xxxx
CHK=0F4E5614DD28
108=abcdefgh12345678
25=SAKG800030155USD

MAC=0F4E5614DD28
60F=C011223USD175768,92

61=0112201223CD110,92NDIVNONREF//08 IL053309
/GB/2542049/SHS/312,

28C=255/1


Saturday, February 5, 2011

Connect to Weblogic server using JMX

Accessing WebLogic Server MBeans with JMX
http://download.oracle.com/docs/cd/E14571_01/web.1111/e13728/accesswls.htm#i1116377

Sample WebLogic JMX Client
http://blogs.oracle.com/WebLogicServer/2009/09/sample_weblogic_jmx_client.html


Weblogic MBean reference
DomainRuntimeServiceMBean
http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e13951/core/index.html

Understanding WebLogic Server MBeans
http://download.oracle.com/docs/cd/E14571_01/web.1111/e13728/understandwls.htm#i1081115


JMX Javadoc
http://download.oracle.com/javase/6/docs/api/javax/management/remote/package-summary.html
JMXServiceURL
http://download.oracle.com/javase/6/docs/api/javax/management/remote/JMXServiceURL.html


Java Management Extensions (JMX) tutorial
http://download.oracle.com/javase/tutorial/jmx/index.html

Java Management Extensions (JMX) Technology
http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html



package dave;

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Hashtable;

import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;

public class PrintServerState {

private static MBeanServerConnection connection;
private static JMXConnector connector;
private static final ObjectName service;

// Initializing the object name for DomainRuntimeServiceMBean
// so it can be used throughout the class.
static {
try {
service = new ObjectName(
"com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean");
} catch (MalformedObjectNameException e) {
throw new AssertionError(e.getMessage());
}
}

/*
* Initialize connection to the Domain Runtime MBean Server
*/
public static void initConnection(String hostname, String portString,
String username, String password) throws IOException,
MalformedURLException {
String protocol = "t3";
Integer portInteger = Integer.valueOf(portString);
int port = portInteger.intValue();
String jndiroot = "/jndi/";
String mserver = "weblogic.management.mbeanservers.domainruntime";
JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port,
jndiroot + mserver);
Hashtable h = new Hashtable();
h.put(Context.SECURITY_PRINCIPAL, username);
h.put(Context.SECURITY_CREDENTIALS, password);
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,
"weblogic.management.remote");
connector = JMXConnectorFactory.connect(serviceURL, h);
connection = connector.getMBeanServerConnection();
}

/*
* Print an array of ServerRuntimeMBeans. This MBean is the root of the
* runtime MBean hierarchy, and each server in the domain hosts its own
* instance.
*/
public static ObjectName[] getServerRuntimes() throws Exception {
return (ObjectName[]) connection
.getAttribute(service, "ServerRuntimes");
}

/*
* Iterate through ServerRuntimeMBeans and get the name and state
*/
public void printNameAndState() throws Exception {
ObjectName[] serverRT = getServerRuntimes();
System.out.println("got server runtimes");
int length = (int) serverRT.length;
for (int i = 0; i < length; i++) {
String name = (String) connection.getAttribute(serverRT[i], "Name");
String state = (String) connection.getAttribute(serverRT[i],
"State");
System.out.println("Server name: " + name + ". Server state: "
+ state);
}
// Get the ObjectName of the domain's DomainMBean by getting the value
// of the DomainRuntimeServiceMBean DomainConfiguration attribute
ObjectName domainconfig = (ObjectName) connection.getAttribute(service,
"DomainConfiguration");

// Get the ObjectNames for all ServerMBeans in the domain by getting the
// value of the DomainMBean Servers attribute
ObjectName[] servers = (ObjectName[]) connection.getAttribute(
domainconfig, "Servers");
printMBeans(servers);

// get all server runtimes
ObjectName[] serverRuntimes = (ObjectName[]) connection.getAttribute(
service, "ServerRuntimes");
printMBeans(serverRuntimes);

// print attributes for each server
for (ObjectName server : serverRuntimes) {
System.out.println(server);
String[] attributes = new String[] { "CurrentDirectory", "State",
"ListenAddress", "ListenPort" };
AttributeList values = connection.getAttributes(server, attributes);
for (Object attribute : values) {
System.out.println(attribute);
}
ObjectName jvmRuntime = (ObjectName) connection.getAttribute(
server, "JVMRuntime");
attributes = new String[] { "HeapSizeCurrent", "HeapSizeFree",
"ThreadStackDump" };
values = connection.getAttributes(jvmRuntime, attributes);
for (Object attribute : values) {
System.out.println(attribute);
}

//ExecuteThreadTotalCount
//PendingRequestCurrentCount
//ExecuteThreads
ObjectName[] executeQueueRuntimes = (ObjectName[] ) connection.getAttribute(
server, "ExecuteQueueRuntimes");

// print attributes for each queue runtime
for (ObjectName queueRuntime : executeQueueRuntimes) {
attributes = new String[] { "ExecuteThreadTotalCount",
"PendingRequestCurrentCount", "ExecuteThreads" };
values = connection.getAttributes(queueRuntime, attributes);
for (Object attribute : values) {
System.out.println(attribute);
}
}
}

}

private static void printMBeans(ObjectName[] mbeans) {
for (ObjectName mbeanName : mbeans) {
System.out.println(mbeanName);
}
}

public static void main(String[] args) throws Exception {
String hostname = args[0];
String portString = args[1];
String username = args[2];
String password = args[3];

PrintServerState s = new PrintServerState();
initConnection(hostname, portString, username, password);
s.printNameAndState();
connector.close();
}
}




got server runtimes
Server name: AdminServer. Server state: RUNNING
Server name: ManagedServer. Server state: RUNNING
com.bea:Name=AdminServer,Location=base_domain,Type=Server
com.bea:Name=ManagedServer,Location=base_domain,Type=Server
com.bea:Name=AdminServer,Location=AdminServer,Type=ServerRuntime
com.bea:Name=ManagedServer,Location=ManagedServer,Type=ServerRuntime
com.bea:Name=AdminServer,Location=AdminServer,Type=ServerRuntime
CurrentDirectory = /usr/app/domains/base_domain/.
State = RUNNING
ListenAddress = localhost/127.0.0.1
ListenPort = 7001
HeapSizeCurrent = 259588096
ThreadStackDump = "VDE Replication Thread" waiting for lock com.octetstring.vde.replication.Replication@90f767 TIMED_WAITING
java.lang.Object.wait(Native Method)
com.octetstring.vde.replication.Replication.wait30sec(Replication.java:384)
com.octetstring.vde.replication.Replication.run(Replication.java:350)

"[ACTIVE] ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock com.sun.jmx.remote.internal.ArrayNotificationBuffer@162c3e6 TIMED_WAITING
java.lang.Object.wait(Native Method)
com.sun.jmx.remote.internal.ArrayNotificationBuffer.fetchNotifications(ArrayNotificationBuffer.java:417)
com.sun.jmx.remote.internal.ArrayNotificationBuffer$ShareBuffer.fetchNotifications(ArrayNotificationBuffer.java:209)
com.sun.jmx.remote.internal.ServerNotifForwarder.fetchNotifs(ServerNotifForwarder.java:258)
javax.management.remote.rmi.RMIConnectionImpl$2.run(RMIConnectionImpl.java:1227)
javax.management.remote.rmi.RMIConnectionImpl$2.run(RMIConnectionImpl.java:1225)
java.security.AccessController.doPrivileged(Native Method)
javax.management.remote.rmi.RMIConnectionImpl.fetchNotifications(RMIConnectionImpl.java:1233)
javax.management.remote.rmi.RMIConnectionImpl_WLSkel.invoke(Unknown Source)
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

"[ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'" RUNNABLE
sun.management.ThreadImpl.getThreadInfo0(Native Method)
sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:145)
weblogic.platform.VM15.threadDumpAsString(VM15.java:22)
weblogic.platform.VM.threadDumpAsString(VM.java:137)
weblogic.t3.srvr.JVMRuntime.getThreadStackDump(JVMRuntime.java:114)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
weblogic.management.jmx.modelmbean.WLSModelMBean.getAttribute(WLSModelMBean.java:525)
weblogic.management.jmx.modelmbean.WLSModelMBean.getAttributes(WLSModelMBean.java:585)
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttributes(DefaultMBeanServerInterceptor.java:726)
com.sun.jmx.mbeanserver.JmxMBeanServer.getAttributes(JmxMBeanServer.java:665)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$13.run(WLSMBeanServerInterceptorBase.java:353)
java.security.AccessController.doPrivileged(Native Method)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase.getAttributes(WLSMBeanServerInterceptorBase.java:351)
weblogic.management.mbeanservers.internal.JMXContextInterceptor.getAttributes(JMXContextInterceptor.java:198)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$13.run(WLSMBeanServerInterceptorBase.java:353)
java.security.AccessController.doPrivileged(Native Method)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase.getAttributes(WLSMBeanServerInterceptorBase.java:351)
weblogic.management.mbeanservers.internal.SecurityInterceptor.getAttributes(SecurityInterceptor.java:307)
weblogic.management.jmx.mbeanserver.WLSMBeanServer.getAttributes(WLSMBeanServer.java:292)
weblogic.management.mbeanservers.domainruntime.internal.ManagedMBeanServerConnection.getAttributes(ManagedMBeanServerConnection.java:309)
weblogic.management.mbeanservers.domainruntime.internal.FederatedMBeanServerInterceptor.getAttributes(FederatedMBeanServerInterceptor.java:318)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$13.run(WLSMBeanServerInterceptorBase.java:353)
java.security.AccessController.doPrivileged(Native Method)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase.getAttributes(WLSMBeanServerInterceptorBase.java:351)
weblogic.management.mbeanservers.internal.JMXContextInterceptor.getAttributes(JMXContextInterceptor.java:198)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$13.run(WLSMBeanServerInterceptorBase.java:353)
java.security.AccessController.doPrivileged(Native Method)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase.getAttributes(WLSMBeanServerInterceptorBase.java:351)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$13.run(WLSMBeanServerInterceptorBase.java:353)
java.security.AccessController.doPrivileged(Native Method)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase.getAttributes(WLSMBeanServerInterceptorBase.java:351)
weblogic.management.mbeanservers.internal.SecurityInterceptor.getAttributes(SecurityInterceptor.java:307)
weblogic.management.jmx.mbeanserver.WLSMBeanServer.getAttributes(WLSMBeanServer.java:292)
weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$6$1.run(JMXConnectorSubjectForwarder.java:382)
weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$6$1.run(JMXConnectorSubjectForwarder.java:380)
java.security.AccessController.doPrivileged(Native Method)
weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$6.run(JMXConnectorSubjectForwarder.java:380)
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder.getAttributes(JMXConnectorSubjectForwarder.java:375)
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1407)
javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72)
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1264)
java.security.AccessController.doPrivileged(Native Method)
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1366)
javax.management.remote.rmi.RMIConnectionImpl.getAttributes(RMIConnectionImpl.java:636)
javax.management.remote.rmi.RMIConnectionImpl_WLSkel.invoke(Unknown Source)
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

"[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock weblogic.work.ExecuteThread@1474c6c WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.work.ExecuteThread.waitForRequest(ExecuteThread.java:157)
weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

"[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock weblogic.work.ExecuteThread@14c6b5 WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.work.ExecuteThread.waitForRequest(ExecuteThread.java:157)
weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

"DynamicListenThread[Default]" RUNNABLE native
java.net.PlainSocketImpl.socketAccept(Native Method)
java.net.PlainSocketImpl.accept(PlainSocketImpl.java:390)
java.net.ServerSocket.implAccept(ServerSocket.java:453)
java.net.ServerSocket.accept(ServerSocket.java:421)
weblogic.socket.WeblogicServerSocket.accept(WeblogicServerSocket.java:38)
weblogic.server.channels.DynamicListenThread$SocketAccepter.accept(DynamicListenThread.java:535)
weblogic.server.channels.DynamicListenThread$SocketAccepter.access$200(DynamicListenThread.java:420)
weblogic.server.channels.DynamicListenThread.run(DynamicListenThread.java:171)
java.lang.Thread.run(Thread.java:619)

"weblogic.GCMonitor" waiting for lock java.lang.ref.ReferenceQueue$Lock@1738bf TIMED_WAITING
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
weblogic.platform.GCMonitorThread.waitForNotification(GCMonitorThread.java:88)
weblogic.platform.GCMonitorThread.run(GCMonitorThread.java:64)

"Thread-12" waiting for lock java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@8ea05d WAITING
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:358)
weblogic.utils.concurrent.JDK15ConcurrentBlockingQueue.take(JDK15ConcurrentBlockingQueue.java:89)
weblogic.store.internal.PersistentStoreImpl.getOutstandingWork(PersistentStoreImpl.java:650)
weblogic.store.internal.PersistentStoreImpl.run(PersistentStoreImpl.java:707)
weblogic.store.internal.PersistentStoreImpl$2.run(PersistentStoreImpl.java:464)

"[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock weblogic.work.ExecuteThread@1c2798d WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.work.ExecuteThread.waitForRequest(ExecuteThread.java:157)
weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

"Attach Listener" RUNNABLE
null
"[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock weblogic.work.ExecuteThread@ba5568 WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.work.ExecuteThread.waitForRequest(ExecuteThread.java:157)
weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

"[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock com.sun.jmx.remote.internal.ArrayNotificationBuffer@1ea7e80 TIMED_WAITING
java.lang.Object.wait(Native Method)
com.sun.jmx.remote.internal.ArrayNotificationBuffer.fetchNotifications(ArrayNotificationBuffer.java:417)
com.sun.jmx.remote.internal.ArrayNotificationBuffer$ShareBuffer.fetchNotifications(ArrayNotificationBuffer.java:209)
com.sun.jmx.remote.internal.ServerNotifForwarder.fetchNotifs(ServerNotifForwarder.java:258)
javax.management.remote.rmi.RMIConnectionImpl$2.run(RMIConnectionImpl.java:1227)
javax.management.remote.rmi.RMIConnectionImpl$2.run(RMIConnectionImpl.java:1225)
java.security.AccessController.doPrivileged(Native Method)
javax.management.remote.rmi.RMIConnectionImpl.fetchNotifications(RMIConnectionImpl.java:1233)
javax.management.remote.rmi.RMIConnectionImpl_WLSkel.invoke(Unknown Source)
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

"Thread-11" waiting for lock java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@13d1f37 WAITING
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:358)
weblogic.utils.concurrent.JDK15ConcurrentBlockingQueue.take(JDK15ConcurrentBlockingQueue.java:89)
weblogic.store.internal.PersistentStoreImpl.getOutstandingWork(PersistentStoreImpl.java:650)
weblogic.store.internal.PersistentStoreImpl.run(PersistentStoreImpl.java:707)
weblogic.store.internal.PersistentStoreImpl$2.run(PersistentStoreImpl.java:464)

"Timer-2" waiting for lock java.util.TaskQueue@1cc7971 TIMED_WAITING
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:509)
java.util.TimerThread.run(Timer.java:462)

"DoSManager" TIMED_WAITING
java.lang.Thread.sleep(Native Method)
com.octetstring.vde.DoSManager.run(DoSManager.java:433)

"VDE Transaction Processor Thread" waiting for lock com.octetstring.vde.backend.standard.TransactionProcessor@1391097 WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
com.octetstring.vde.backend.standard.TransactionProcessor.waitChange(TransactionProcessor.java:367)
com.octetstring.vde.backend.standard.TransactionProcessor.run(TransactionProcessor.java:212)

"ExecuteThread: '2' for queue: 'weblogic.socket.Muxer'" waiting for lock weblogic.socket.PosixSocketMuxer$1@1705951 BLOCKED
weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:95)
weblogic.socket.SocketReaderRequest.run(SocketReaderRequest.java:29)
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:42)
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)

"ExecuteThread: '1' for queue: 'weblogic.socket.Muxer'" RUNNABLE native
weblogic.socket.PosixSocketMuxer.poll(Native Method)
weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:102)
weblogic.socket.SocketReaderRequest.run(SocketReaderRequest.java:29)
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:42)
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)

"ExecuteThread: '0' for queue: 'weblogic.socket.Muxer'" waiting for lock weblogic.socket.PosixSocketMuxer$1@1705951 BLOCKED
weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:95)
weblogic.socket.SocketReaderRequest.run(SocketReaderRequest.java:29)
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:42)
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)

"[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock weblogic.work.ExecuteThread@f7fc8f WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.work.ExecuteThread.waitForRequest(ExecuteThread.java:157)
weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

"weblogic.timers.TimerThread" waiting for lock weblogic.timers.internal.TimerThread@e615e9 TIMED_WAITING
java.lang.Object.wait(Native Method)
weblogic.timers.internal.TimerThread$Thread.run(TimerThread.java:262)

"weblogic.time.TimeEventGenerator" waiting for lock weblogic.time.common.internal.TimeTable@1a883d8 TIMED_WAITING
java.lang.Object.wait(Native Method)
weblogic.time.common.internal.TimeTable.snooze(TimeTable.java:286)
weblogic.time.common.internal.TimeEventGenerator.run(TimeEventGenerator.java:117)
java.lang.Thread.run(Thread.java:619)

"[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock weblogic.work.ExecuteThread@67e3fd WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.work.ExecuteThread.waitForRequest(ExecuteThread.java:157)
weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

"Timer-1" waiting for lock java.util.TaskQueue@a9059c TIMED_WAITING
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:509)
java.util.TimerThread.run(Timer.java:462)

"Timer-0" waiting for lock java.util.TaskQueue@af7a72 WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
java.util.TimerThread.mainLoop(Timer.java:483)
java.util.TimerThread.run(Timer.java:462)

"Signal Dispatcher" RUNNABLE
null
"Finalizer" waiting for lock java.lang.ref.ReferenceQueue$Lock@8feb56 WAITING
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" waiting for lock java.lang.ref.Reference$Lock@a3846c WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)

"main" waiting for lock weblogic.t3.srvr.T3Srvr@14adb17 WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.t3.srvr.T3Srvr.waitForDeath(T3Srvr.java:902)
weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:465)
weblogic.Server.main(Server.java:67)


ExecuteThreadTotalCount = 3
PendingRequestCurrentCount = 0
ExecuteThreads = [Lweblogic.management.runtime.ExecuteThread;@1b03c1a
com.bea:Name=ManagedServer,Location=ManagedServer,Type=ServerRuntime
CurrentDirectory = /usr/app/domains/base_domain/.
State = RUNNING
ListenAddress = localhost/127.0.0.1
ListenPort = 7003
HeapSizeCurrent = 259588096
ThreadStackDump = "[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'" RUNNABLE
sun.management.ThreadImpl.getThreadInfo0(Native Method)
sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:145)
weblogic.platform.VM15.threadDumpAsString(VM15.java:22)
weblogic.platform.VM.threadDumpAsString(VM.java:137)
weblogic.t3.srvr.JVMRuntime.getThreadStackDump(JVMRuntime.java:114)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
weblogic.management.jmx.modelmbean.WLSModelMBean.getAttribute(WLSModelMBean.java:525)
weblogic.management.jmx.modelmbean.WLSModelMBean.getAttributes(WLSModelMBean.java:585)
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttributes(DefaultMBeanServerInterceptor.java:726)
com.sun.jmx.mbeanserver.JmxMBeanServer.getAttributes(JmxMBeanServer.java:665)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$13.run(WLSMBeanServerInterceptorBase.java:353)
java.security.AccessController.doPrivileged(Native Method)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase.getAttributes(WLSMBeanServerInterceptorBase.java:351)
weblogic.management.mbeanservers.internal.JMXContextInterceptor.getAttributes(JMXContextInterceptor.java:198)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$13.run(WLSMBeanServerInterceptorBase.java:353)
java.security.AccessController.doPrivileged(Native Method)
weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase.getAttributes(WLSMBeanServerInterceptorBase.java:351)
weblogic.management.mbeanservers.internal.SecurityInterceptor.getAttributes(SecurityInterceptor.java:307)
weblogic.management.jmx.mbeanserver.WLSMBeanServer.getAttributes(WLSMBeanServer.java:292)
weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$6$1.run(JMXConnectorSubjectForwarder.java:382)
weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$6$1.run(JMXConnectorSubjectForwarder.java:380)
java.security.AccessController.doPrivileged(Native Method)
weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$6.run(JMXConnectorSubjectForwarder.java:380)
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder.getAttributes(JMXConnectorSubjectForwarder.java:375)
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1407)
javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72)
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1264)
java.security.AccessController.doPrivileged(Native Method)
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1366)
javax.management.remote.rmi.RMIConnectionImpl.getAttributes(RMIConnectionImpl.java:636)
javax.management.remote.rmi.RMIConnectionImpl_WLSkel.invoke(Unknown Source)
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

"DynamicListenThread[Default]" RUNNABLE native
java.net.PlainSocketImpl.socketAccept(Native Method)
java.net.PlainSocketImpl.accept(PlainSocketImpl.java:390)
java.net.ServerSocket.implAccept(ServerSocket.java:453)
java.net.ServerSocket.accept(ServerSocket.java:421)
weblogic.socket.WeblogicServerSocket.accept(WeblogicServerSocket.java:38)
weblogic.server.channels.DynamicListenThread$SocketAccepter.accept(DynamicListenThread.java:535)
weblogic.server.channels.DynamicListenThread$SocketAccepter.access$200(DynamicListenThread.java:420)
weblogic.server.channels.DynamicListenThread.run(DynamicListenThread.java:171)
java.lang.Thread.run(Thread.java:619)

"weblogic.GCMonitor" waiting for lock java.lang.ref.ReferenceQueue$Lock@1e71d39 TIMED_WAITING
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
weblogic.platform.GCMonitorThread.waitForNotification(GCMonitorThread.java:88)
weblogic.platform.GCMonitorThread.run(GCMonitorThread.java:64)

"Thread-12" waiting for lock java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@2f925d WAITING
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:358)
weblogic.utils.concurrent.JDK15ConcurrentBlockingQueue.take(JDK15ConcurrentBlockingQueue.java:89)
weblogic.store.internal.PersistentStoreImpl.getOutstandingWork(PersistentStoreImpl.java:650)
weblogic.store.internal.PersistentStoreImpl.run(PersistentStoreImpl.java:707)
weblogic.store.internal.PersistentStoreImpl$2.run(PersistentStoreImpl.java:464)

"[STANDBY] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock weblogic.work.ExecuteThread@13246f3 WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.work.ExecuteThread.waitForRequest(ExecuteThread.java:157)
weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

"Thread-11" waiting for lock java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@1d017d4 WAITING
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:358)
weblogic.utils.concurrent.JDK15ConcurrentBlockingQueue.take(JDK15ConcurrentBlockingQueue.java:89)
weblogic.store.internal.PersistentStoreImpl.getOutstandingWork(PersistentStoreImpl.java:650)
weblogic.store.internal.PersistentStoreImpl.run(PersistentStoreImpl.java:707)
weblogic.store.internal.PersistentStoreImpl$2.run(PersistentStoreImpl.java:464)

"Timer-2" waiting for lock java.util.TaskQueue@cc831a TIMED_WAITING
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:509)
java.util.TimerThread.run(Timer.java:462)

"DoSManager" TIMED_WAITING
java.lang.Thread.sleep(Native Method)
com.octetstring.vde.DoSManager.run(DoSManager.java:433)

"VDE Transaction Processor Thread" waiting for lock com.octetstring.vde.backend.standard.TransactionProcessor@b3519c WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
com.octetstring.vde.backend.standard.TransactionProcessor.waitChange(TransactionProcessor.java:367)
com.octetstring.vde.backend.standard.TransactionProcessor.run(TransactionProcessor.java:212)

"ExecuteThread: '2' for queue: 'weblogic.socket.Muxer'" RUNNABLE native
weblogic.socket.PosixSocketMuxer.poll(Native Method)
weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:102)
weblogic.socket.SocketReaderRequest.run(SocketReaderRequest.java:29)
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:42)
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)

"ExecuteThread: '1' for queue: 'weblogic.socket.Muxer'" waiting for lock weblogic.socket.PosixSocketMuxer$1@b2e25b BLOCKED
weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:95)
weblogic.socket.SocketReaderRequest.run(SocketReaderRequest.java:29)
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:42)
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)

"ExecuteThread: '0' for queue: 'weblogic.socket.Muxer'" waiting for lock weblogic.socket.PosixSocketMuxer$1@b2e25b BLOCKED
weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:95)
weblogic.socket.SocketReaderRequest.run(SocketReaderRequest.java:29)
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:42)
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)

"[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'" waiting for lock weblogic.work.ExecuteThread@2ae278 WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.work.ExecuteThread.waitForRequest(ExecuteThread.java:157)
weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

"weblogic.timers.TimerThread" waiting for lock weblogic.timers.internal.TimerThread@17a5010 TIMED_WAITING
java.lang.Object.wait(Native Method)
weblogic.timers.internal.TimerThread$Thread.run(TimerThread.java:262)

"weblogic.time.TimeEventGenerator" waiting for lock weblogic.time.common.internal.TimeTable@11e67eb TIMED_WAITING
java.lang.Object.wait(Native Method)
weblogic.time.common.internal.TimeTable.snooze(TimeTable.java:286)
weblogic.time.common.internal.TimeEventGenerator.run(TimeEventGenerator.java:117)
java.lang.Thread.run(Thread.java:619)

"[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'" RUNNABLE
java.lang.Thread.currentThread(Native Method)
weblogic.security.service.SubjectManagerImpl.getCurrentSubject(SubjectManagerImpl.java:72)
weblogic.security.service.SecurityManager.getCurrentSubject(SecurityManager.java:46)
weblogic.security.service.SecurityServiceManager.getCurrentSubjectForWire(SecurityServiceManager.java:1029)
weblogic.rmi.internal.wls.WLSRMIEnvironment.getCurrentSubjectForWire(WLSRMIEnvironment.java:244)
weblogic.rjvm.RJVMImpl.getRequestStream(RJVMImpl.java:555)
weblogic.rjvm.RJVMImpl.getOutboundRequest(RJVMImpl.java:787)
weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:159)
weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:211)
weblogic.management.logging.DomainLogHandlerImpl_1033_WLStub.publishLogEntries(Unknown Source)
weblogic.logging.DomainLogBroadcasterClient$2.run(DomainLogBroadcasterClient.java:209)
weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

"Timer-1" waiting for lock java.util.TaskQueue@1387c07 TIMED_WAITING
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:509)
java.util.TimerThread.run(Timer.java:462)

"Timer-0" waiting for lock java.util.TaskQueue@156d418 WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
java.util.TimerThread.mainLoop(Timer.java:483)
java.util.TimerThread.run(Timer.java:462)

"Signal Dispatcher" RUNNABLE
null
"Finalizer" waiting for lock java.lang.ref.ReferenceQueue$Lock@17e9b52 WAITING
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" waiting for lock java.lang.ref.Reference$Lock@10765e2 WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)

"main" waiting for lock weblogic.t3.srvr.T3Srvr@b201fd WAITING
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:485)
weblogic.t3.srvr.T3Srvr.waitForDeath(T3Srvr.java:902)
weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:465)
weblogic.Server.main(Server.java:67)


ExecuteThreadTotalCount = 3
PendingRequestCurrentCount = 0
ExecuteThreads = [Lweblogic.management.runtime.ExecuteThread;@f07355

Tuesday, February 1, 2011

ANTLR - insert current indent - rewrite multiple lines

See ANTLR4 for other solution using Listener
https://theantlrguy.atlassian.net/wiki/display/ANTLR4/Parse+Tree+Listeners
http://media.pragprog.com/titles/tpantlr2/listener.pdf

Get current indent from token stream using direct Java access to token stream - get all token on HIDDEN channel on current line
How do I access hidden tokens from parser?
http://www.antlr.org/wiki/pages/viewpage.action?pageId=557063



        int startIndex = input.getTreeAdaptor().getTokenStartIndex(retval.start);
        int stopIndex = input.getTreeAdaptor().getTokenStopIndex(retval.start);
        int line = ((Token) input.getTokenStream().get(startIndex)).getLine();
        System.out.println("\nLINE: line" + line + " retval.start" + startIndex + " stop=" + stopIndex);  

        int currentIndex = stopIndex;
        Token token;
        // print all tokens on line
        while (currentIndex >= startIndex &&
                (token = (Token) input.getTokenStream().get(currentIndex)).getLine() == line
        ) {
            System.out.println("currentIndex=" + currentIndex +
                    " line=" + token.getLine() +
                    " token" + token);
            currentIndex--;
        }

        // set current to indent whitespace
        currentIndex = startIndex - 1;
        System.out.println("START: currentIndex=" + currentIndex);

        StringBuffer indent = new StringBuffer();
        while (currentIndex > -1 &&  (token = (Token) input.getTokenStream().get(currentIndex)).getChannel() == Parser.HIDDEN ) {
            System.out.println("INDENT: currentIndex=" + currentIndex + "channel=" +
                    token.getChannel() + " text" + token.getText()
                    + " type=" + token.getType());
            if(token.getText().matches("[\t ]+")){
                indent.append(token.getText());
            }
            currentIndex--;
        }
        if(indent.length() > 0){
            ((primaryExpression_scope) primaryExpression_stack.peek()).indent = indent.toString();

        } else {
            ((primaryExpression_scope) primaryExpression_stack.peek()).indent = "";
        }



Pass current indent to StringTemplate using scope variable
primaryExpression
scope {
  boolean isMethodCall;
  String indent;
}


Rewrite rule
|   ^(METHOD_CALL  primaryExpression {$primaryExpression::isMethodCall=true;} genericTypeArgumentList? arguments)
     
       {
         // Java code inserted here
       }
        -> 
      methodCall(indent={$primaryExpression::indent}, methodCallText={$text})


StringTemplate
group Java;

methodCall(indent,methodCallText) ::= <<
<methodCallText>
<indent>log("Called <methodCallText>")
>>


Log output - getting indent and rewritten HelloWorld program
LINE: line15 retval.start69 stop=72
currentIndex=72 line=15 token[@72,217:217=')',<43>,15:9]
currentIndex=71 line=15 token[@71,216:216='x',<164>,15:8]
currentIndex=70 line=15 token[@70,215:215='(',<29>,15:7]
currentIndex=69 line=15 token[@69,210:214='print',<164>,15:2]
START: currentIndex=68
INDENT: currentIndex=68channel=99 text     type=180
INDENT: currentIndex=67channel=99 text     type=180
INDENT: currentIndex=66channel=99 text
 type=180
INDENT: currentIndex=65channel=99 text  type=180

LINE: line17 retval.start78 stop=85
currentIndex=85 line=17 token[@85,256:256=')',<43>,17:35]
currentIndex=84 line=17 token[@84,242:255='"Hello,world!"',<170>,17:21]
currentIndex=83 line=17 token[@83,241:241='(',<29>,17:20]
currentIndex=82 line=17 token[@82,234:240='println',<164>,17:13]
currentIndex=81 line=17 token[@81,233:233='.',<15>,17:12]
currentIndex=80 line=17 token[@80,230:232='out',<164>,17:9]
currentIndex=79 line=17 token[@79,229:229='.',<15>,17:8]
currentIndex=78 line=17 token[@78,223:228='System',<164>,17:2]
START: currentIndex=77
INDENT: currentIndex=77channel=99 text     type=180
INDENT: currentIndex=76channel=99 text     type=180
INDENT: currentIndex=75channel=99 text
 type=180
INDENT: currentIndex=74channel=99 text
 type=180

LINE: line22 retval.start112 stop=119
currentIndex=119 line=22 token[@119,323:323=')',<43>,22:22]
currentIndex=118 line=22 token[@118,322:322='x',<164>,22:21]
currentIndex=117 line=22 token[@117,321:321='(',<29>,22:20]
currentIndex=116 line=22 token[@116,314:320='println',<164>,22:13]
currentIndex=115 line=22 token[@115,313:313='.',<15>,22:12]
currentIndex=114 line=22 token[@114,310:312='out',<164>,22:9]
currentIndex=113 line=22 token[@113,309:309='.',<15>,22:8]
currentIndex=112 line=22 token[@112,303:308='System',<164>,22:2]
START: currentIndex=111
INDENT: currentIndex=111channel=99 text     type=180
INDENT: currentIndex=110channel=99 text     type=180
INDENT: currentIndex=109channel=99 text
 type=180

Tokens:

public class HelloWorld {

    static int x;

    /**
     * This is test class for ANTLR Java source code transformation
     * @param args
     */
    public static void main(String args[]) {

        int x;
        int y;
        
        x = 1; 
        print(x)
         log("Called print(x)");

        System.out.println("Hello,world!")
        log("Called System.out.println("Hello,world!")");

    }
    
    private static  void print(int x){
        System.out.println(x)
        log("Called System.out.println(x)");
    }

}