Weblogic Portal – Create Streaming Desktop Page Definition Error
| Posted by watashii | Filed under Programming, WebGot the following error when (re)creating a streaming desktop from an updated .portal file, using the Create Desktop Wizard on Portal Admin Console.
javax.ejb.EJBException: SQL Error while trying to createPageDefinition: SQL [insert into PF_PAGE_DEFINITION ( PAGE_DEFINITION_ID, MARKUP_DEFINITION_ID, IS_PUBLIC, IS_HIDDEN, INTERSECTION_ID, PAGE_LABEL, WEBAPP_NAME) values (?,?,?,?,?,?,?)] database error code [25,222] SQL state [22028] .; nested exception is: java.sql.SQLException: Data exception -- row already exist in index AX1_PAGE_DEF on table PF_PAGE_DEFINITION.
To temporarily bypass this error this so the streaming desktop can be created with the wizard, remove all the Pages manually from the Library.
The problem is one of the Page definition(s) in the .portal file is corrupted which prevents the library page resource from being refreshed. You will need to work out which page is causing the problem, then the redo the page in the .portal file via Weblogic Portal Workshop.
Tags: error, portal, streaming desktop, weblogic
Java Send Email (In a Jar)
| Posted by watashii | Filed under Programming, WebStep 1
Download the JavaMail and Activation Framework library .jar files
• If using Java SE, you’ll need to download JavaMail, eg mail-1.4.3.jar
• If using below Java SE 6, you’ll need to download and include Activation Framework, eg activation-1.1.1.jar
Read the rest of this entry »
Tags: classpath, jar, java, mail
Start & Stop Weblogic Without Username & Password
| Posted by watashii | Filed under Oracle, WebIn a Weblogic Server domain running in production mode, username and password is always prompted during startup and shutdown (admin server and managed servers). To bypass this manual step, we can store the username and password credentials in the boot.properties file (although this is somewhat the same as development mode)…
Tags: encrypt, password, security, weblogic
Weblogic Portal Authorization – Get and Check User’s Roles
| Posted by watashii | Filed under Programming, WebThe Authorization class provides runtime methods for security policies and roles checks. The following code fragment obtains the set of roles the logged-in user belongs to. Note the user must be authenticated first, see Authentication class.
String entAppName = ApplicationHelper.getNonVersionedAppName();
String webAppName = ApplicationHelper.getWebAppName(request);
EnterpriseRoleResource resource = new EnterpriseRoleResource(entAppName,webAppName,EntitlementConstants.P13N_ROLE_POLICY_POOL,"");
Map userRoles = Authorization.getRoles((P13nResource) resource);
if (Authorization.isUserInRole("Admin", userRoles)) {
return true;
}
Global and Enterprise Application roles are obtained using EnterpriseRoleResource. For Global, Enterprise, and Web Application roles, use WebappRoleResource.
com.bea.p13n.security.Authentication
Tags: authentication, authorization, portal, roles, weblogic
Getting the HttpServletRequest from PortletRequest Object
| Posted by watashii | Filed under Programming, WebIn my JSF / icefaces based portlet running on Weblogic Portal, I got the following error:
com.icesoft.faces.webapp.http.portlet.PortletExternalContext cannot be cast to javax.servlet.http.HttpServletRequest
It turned out I cannot simply obtain the HTTPServletRequest object like this:
FacesContext ctx = FacesContext.getCurrentInstance(); HttpServletRequest portletRequest = (HttpServletRequest) ctx.getCurrentInstance().getExternalContext().getRequest();
In a portlet environment, to get the request/response objects, we must obtain the javax.portlet.PortletRequest/PortletResponse objects instead (which inherits methods from java.servlet.HTTPServletRequest/HTTPServletResponse):
FacesContext ctx = FacesContext.getCurrentInstance(); PortletRequest portletReq = (PortletRequest) ctx.getExternalContext().getRequest();
However sometimes we may require the HttpServletRequest / HttpServletResponse object. To obtain this, we must extract an attribute from the PortletRequest / PortletResponse object:
FacesContext ctx = FacesContext.getCurrentInstance();
PortletRequest portletReq = (PortletRequest) ctx.getExternalContext().getRequest();
HttpServletRequest httpServletReq = (HttpServletRequest) portletReq.getAttribute("javax.servlet.request");
Tags: javax, jsf, portlet, request, response, servlet, weblogic portal
Reading Portlet Preferences in Weblogic Portal
| Posted by watashii | Filed under Programming, WebPortlet preferences enables portlets to be associated with external application data. This data should generally be used to store (or update) configuration data in a portlet. For example, to store/update dynamic stock codes in a stock quotes portlet. A portlet preference is basically a name-value pair data structure.
Portlet preferences can be added/updated in the following ways:
- During design-time on Workshop for Weblogic Portal (screenshot above)
- Invoked programmatically at request-time using javax.portlet.* API
- Manually during run-time of a portal (via Portal Administration Console when a portal desktop is created)
When we have added our preferences, we can read them using using the Weblogic Portal API’s. The following sample code fragments are for JSP Portlets, and JSF Portlets:
Tags: java, jsp, portal, portlets, preferences, weblogic
Encrypt Passwords With Weblogic Server
| Posted by watashii | Filed under Oracle, WebIn a Weblogic Server environment, sometimes passwords must be unavoidably stored in text files, for example database connection details within JDBC configuration files. When running Weblogic in production mode, only encrypted password is accepted to ensure that the password is never exposed as clear text. To generate the encrypted password, the weblogic.security.Encrypt utility can be used, which generates a hashed password with a “{3DES}” prepended.
In Unix environment:
$ cd /opt/bea/user_projects/domains/mydomain/bin
$ . setDomainEnv.sh
$ java weblogic.security.Encrypt mycleartextpasswordhere
{3DES}xLLwrOm7asb4imZOYYwxz5TcBqDBEe6S
In Windows environment:
C:\>cd c:\bea\domains\mydomain\bin
C:\bea\domains\mydomain\bin>setDomainEnv.cmd
C:\bea\domains\mydomain\bin>java weblogic.security.Encrypt mycleartextpasswordhere
{3DES}lieJgIkTqg1xSBBoy3YxnHbPuz+tMxhY
Note that running the same command on different environment (or different Weblogic server installation) will produce a different password.
Tags: encrypt, oracle, password, security, weblogic
Disable Google Reader’s Social Features (Antisocial Mode)
| Posted by watashii | Filed under WebIf you like reading your feeds on Google Reader however dont use the social features (eg sharing items and following other people), there is a way to turn off this feature.
Tags: google, reader, rss, social
Simple Content Repository Search Example
| Posted by watashii | Filed under Programming, Web
Here is a simple code fragment to perform search on the Weblogic Portal 10 Content Repository using the search api. The important part is the query string to extract the content, and the sort order. Some examples here.
Read the rest of this entry »
Tags: node, portal, properties, search, weblogic
Using JSF 1.2 on Oracle Workshop for Weblogic (Portal 10.3)
| Posted by watashii | Filed under Programming, WebWhen choosing facets during the creation of a new portal web project, the built-in Sun RI JSF 1.2 (together with JSTL 1.2) facets cannot be selected. Here are the recommended (by Oracle) steps to get around this problem. Note that this is because Apache Beehive Page Flow has a dependecy with JSF 1.2, therefore only follow this if not using the page flow integration components provided by Beehive.





