• Home
  • Contact
  • Inspirational
  • Programming Languages
  • Recent findings…

Learners Guide

~ Survivors of Programming Era

Learners Guide

Tag Archives: Deployment

Python Script to Deploy the Application in Weblogic

26 Friday Sep 2014

Posted by learnersguide in Python

≈ Leave a comment

Tags

Deployment, Python, weblogic

Using jdeveloper to host the application is painful. It abstracts lot of things. when we try to build and deploy our application by our own code, we will come to  know lot of stuffs happening behind the scenes.

Start the web logic server (.sh file)

WEBLOGIC_DOMAIN_HOME/bin/startWebLogic.sh

we need to set the web logic environment, it sets few variables like WL_HOME, JAVA_HOME, CLASSPATH, PATH, etc.

. $WEBLOGIC_HOME/bin/setWLSEnv.sh
java weblogic.WLST ./weblogicdeploy.py

The following is the python code to deploy our application in web logic server.

import re
warPath = 'WebService/target/build/dist/webservice.ear'
appName = 'webservice'
weblogicUrl = 't3://127.0.0.1:7101'  //change the port number depending on our weblogic server configuration
userName = 'weblogic'
password = 'weblogic1'
connect(userName, password, weblogicUrl)
appList = re.findall(appName, ls('/AppDeployments'))
if len(appList) >= 1:
print 'undeploying application'
undeploy(appName)
deploy(appName, path = warPath, retireTimeout = -1, upload = 'True')
exit()

you can use a war if it contain simple java classes and libs, ear contains same with wars inside (can have multiple applications inside it).

Difference between ear, war, jar:
http://stackoverflow.com/questions/1594667/war-vs-ear-file
Ear Structure:
http://middlewaremagic.com/weblogic/wp-content/uploads/2010/06/EAR_Application_Diagram.jpg

My git repository https://github.com/dineshkumar-cse/Team-Amazing which contains the scrips and application.

 

 

 

Advertisements

Share this:

  • Share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to share on Flattr (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)

Like this:

Like Loading...

NoSuchMethodException while deploying application in jdeveloper

05 Friday Sep 2014

Posted by learnersguide in Java

≈ Leave a comment

Tags

ClassLoader, Deployment, Jdeveloper, NoSuchMethodException

In Jdeveloper, I’ve created an application for Hibernate to provide DB Service using annotation to map class with DB, and I created jar of that and used in other project WebService. When i run the Hibernate Project Separately it works fine.

while deployment the web service application it reports NoSuchMethod Exception.

Error 500--Internal Server
java.lang.ExceptionInInitializerError
Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
         at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:936)
         at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:824)
         at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3788)
         at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3742)
         at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)
         at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
         at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)

After some research, its known that

The libraries used by the application after deployment is different than the library that is attached to the application in case of deployed application. The ClassLoader loads the class from different location.

The following code tells from which jar the class gets loaded.

Table.class.getProtectionDomain().getCodeSource().getLocation()

Using this its been found that while running as an application it uses the right library (hibernate) from right location /WEB-INF/lib/hibernate-jpa-2.1-api-1.0.0.Final.jar.

In deployed web service it uses older version of library which doesn’t have this method support. (its introduced in later versions) and its location was web logic /User_Home/Oracle/Middleware/modules/javax.persistence_1.0.0.0_1-0-2.jar (or the location of the weblogic libraries)

To solve this we can tell the weblogic to prefer the library from web-inf (our project libraries), if you don’t have one create it under WEB-INF directory.
by Adding the following in weblogic-application.xml (Application Resources)

<prefer-application-packages>
 <package-name>javax.persistence.*</package-name>
<prefer-application-packages>

To understand reason behind this issue check this resource http://docs.oracle.com/cd/E15051_01/wls/docs103/programming/classloading.html

Share this:

  • Share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to share on Flattr (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)

Like this:

Like Loading...

Recent Posts

  • Decorator in Python | Tracking method calls
  • Hosting openshift bottle app with mongodb
  • Psql Horizontal Table Display And Editor
  • Python List Mutating while looping over elements

Archives

  • May 2016
  • March 2016
  • November 2015
  • March 2015
  • February 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013

Categories

  • functional Programming
  • Git
  • IDE
  • Inspirational
  • Java
  • Mac
  • mongodb
  • Openshift
  • Programming Languages
  • Python
  • Scala
  • Shell Program
  • Ubuntu
  • Unit Testing
Advertisements

Recent Posts

  • Decorator in Python | Tracking method calls
  • Hosting openshift bottle app with mongodb
  • Psql Horizontal Table Display And Editor
  • Python List Mutating while looping over elements
  • Restarting Node Server With fswatch command

Blog at WordPress.com.

%d bloggers like this: