Showing posts with label Weblogic Server. Show all posts
Showing posts with label Weblogic Server. Show all posts

Friday, June 17, 2011

Cygwin Java and Classpath Problem

" The cygpath program is a utility that converts Windows native filenames to Cygwin POSIX-style pathnames and vice versa. "
-- Cygwin Utilities

If you are trying to run a Java Class using a Shell Script running off Cygwin, you are sure to see a ClassNotFoundException.

The problem is due to these :-

  • java.exe is a Windows executable program
  • java.exe expects its paths & classpaths to be in the Windows Format - paths separated by semi-colon ( ; )
  • Cygwin wants its paths in the LINUX Format - paths separated by a colon ( : )
Ok, we know the problem now and here's a quick fix solution if you are running Shell Scripts off Cygwin :-

CLASSPATH=.:../lib/junit.jar:../lib/weblogic.jar:../lib/ojdbc6.jar

# Convert paths to help cygwin see Classpaths
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`

java -classpath "$CLASSPATH" com.test.PreLoadTester

Please be sure not to check this into a Production environment - cygpath is only available as part of the Cygwin Utilities.

Tuesday, December 22, 2009

WebLogic Server : Flush the Application Cache

" On our system, what I normally do is to stop the server with the cache that needs to be flushed, then delete the tmp and cache directories of the server "

- Java Ranch Forum Post

Weblogic server maintains certain "caches" in tmp and cache folders. The caches can sometimes prove to be nuisance - especially, the tmp folder.

You can usually find the tmp folder for your application under :-

$DOMAIN_HOME/tmp/_WL_user/myApplication/
I recently ran into this issue and it gave me a couple of sleepless nights.

I had deployed my Application and started it. I then hit the URL in my browser and promptly received an error, which indicated that my cocktail of JAR files were sour and some libraries did not like the other ones.

During the next iteration of development, decided to use newer versions of a particular library. I deleted all the old libraries, provided a "gold" set of libraries ( that were certified on the vendor's website ) and then re-deployed my application.

However, I still noticed that same error. I was baffled as I was *certain* that I had removed all the old libraries.

First, I decided to investigate which JAR file was contributing the class. I retorted to good ol' Java Reflection for this - I just put this neat little piece of code in my Servlet :-

.class.getProtectionDomain().getCodeSource().getLocation();


I printed this using a simple statement and ensured that the output gets imprinted in the Server's Domain Log.

Alright, I now redeployed my application and when I invoked the Servlet, I saw this in my log file :-

$DOMAIN_HOME/servers/tmp/_WL_user/myApplication/ub48zr/war/WEB-INF/lib/myOldJARFile .jar

Bingo ! I promptly cleared the "cache" and redeployed the application. I re-invoked my Servlet and it works fine !!

I have modified my build.xml to include this minor operation - to clear the contents of the _WL_user folder and then undeploy / redeploy.



Weblogic Server : Quick EAR Deployment using WLST

" The WebLogic Scripting Tool (WLST) is a command-line scripting environment that you can use to create, manage, and monitor WebLogic Server domains. "


You can use WLST to quickly deploy an Application EAR File in a Weblogic Server.

What do you need ?
  • the EAR file ( uploaded to a directory in the target WebLogic Server )
  • A simple WLST script
  • Credentials for the Weblogic Server ( preferrably, the weblogic user ).
How do we do it ?
  • Upload your EAR file to a directory in the target Weblogic Server
/app/home/myUser/
  • Write a simple WLST Script to do your work and save it as "myApp.py"

print '*** WEBLOGIC : START ***'

print 'connecting to admin server....'
connect( 'weblogic', 'weblogic', 't3://localhost:8001', adminServerName='AdminServer' )

print 'stopping and undeploying ....'

stopApplication('myApplication')
undeploy('myApplication')

print 'deploying....'

deploy('myApplication', '/app/home/myUser/myApplication.ear', targets='AdminServer')
startApplication('FoundationSearch')

print 'disconnecting from admin server....'
disconnect()
exit()

print '*** WEBLOGIC : STOP ***'
  • Open a Terminal Window / Command Prompt
  • Run the setDomainEnv.sh ( or setDomainEnv.bat ) script to set the required environment variables.
  • Switch to the /common/bin directory of your Weblogic Server
  • run the wlst.sh / wlst.bat script to open the Scripting Environment.
  • Execute your WLST Script :-
execfile('myApp.py')


That's it ! You can now stop an application, undeloy it, deploy it & start an application with a simple script !

You need to watch out for two small things :-

  • The WAR File and some of the classes / libs are "cached" under the /tmp/_WL_user/myApplication/ folder. You may need to delete them before you execute your script.
  • Make sure the EAR file is available in a folder in the same node as the Server.

Tuesday, February 03, 2009

WebLogic Server 10 : Deployment : Error 149003

" WebLogic Deployer:149003 Unable to access application source information "

You might bump into this error during deployment. I just noticed that someone was struggling with this error & had reported this on the OTN Forums.

The Stack Trace for the error usually looks like this :-

Error is: 'weblogic.management.DeploymentException:
[Deployer:149003]Unable to access application source information in
'/home/bea/bea/user_projects/domains/myDomain/servers/myServer/stage
app/app.war' for application 'roller'. The specific error is:
[Deployer:149158]No application files exist at
'/home/bea/bea/user_projects/domains/my/servers/myServer/stage
appapp.war'
The error occurs when the WebLogic Server is unable to locate the EAR file. The common causes for the EAR file could be :-

  • ANT Deployment : The EAR file was not uploaded to a directory that the server can access.
  • Console Deployment: You might need to look at "Source Availablity" [ Copy this application onto every target for me ], if you wish to copy the application to all the managed servers in a Cluster.
The error vanishes once the server can access the EAR file.

Monday, June 23, 2008

WebLogic Server 10 : Deployment : OutOfMemory Error

I created a connection to WebLogic Server 10 in my JDeveloper 10.1.3. Now, I am using this connection to deploy a simple Web Application that contains a single JSP.

However, I keep hitting this bug frequently :-

[BasicOperation.deriveAppName():140] : appname established as: webapp1
weblogic.deploy.api.tools.deployer.DeployerException: Java heap space
at weblogic.deploy.api.tools.deployer.Jsr88Operation.postExecute(Jsr88Operation.java:563)
at weblogic.deploy.api.tools.deployer.DeployOperation.execute(DeployOperation.java:48)
at weblogic.deploy.api.tools.deployer.Deployer.perform(Deployer.java:139)
at weblogic.deploy.api.tools.deployer.Deployer.runBody(Deployer.java:88)
at weblogic.utils.compiler.Tool.run(Tool.java:158)
at weblogic.utils.compiler.Tool.run(Tool.java:115)
at weblogic.Deployer.run(Deployer.java:70)
at weblogic.Deployer.main(Deployer.java:54)
Caused by: java.lang.OutOfMemoryError: Java heap space
[ServerConnectionImpl.close():334] : Closing DM connection
[ServerConnectionImpl.close():354] : Unregistered all listeners
[ServerConnectionImpl.closeJMX():374] : Closed JMX connection
[ServerConnectionImpl.closeJMX():386] : Closed Runtime JMX connection
[ServerConnectionImpl.closeJMX():398] : Closed Edit JMX connection
**** weblogic.deploy returned with non-zero exit status: 1
**** weblogic.deploy returned with non-zero exit status: 1
Elapsed time for deployment: 46 seconds
#### Deployment incomplete. #### Jun 20, 2008 5:53:41 PM


The error clearly tells that the Java process used for the deployment is out of memory & is unable to deploy the application.

I have to increase the heap size of the java process that is used to deploy the application in JDeveloper.

I looked at the deployment profile for my application & noticed this command for WebLogic 9.x :-

${java} ${jvm.max.heap.size}
-classpath ${weblogic.jar} weblogic.Deployer
-adminurl t3://${hostname}:${port}
-user ${username} -password ${password}
-debug -verbose -deploy -upload
-source ${ear.file} -name ${j2ee.app.name}


However, at the time of deployment, I noticed that the heap size was not used for the Java process :-

javaw.exe -classpath weblogic.jar weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password **** -debug -verbose -deploy -upload -source webapp1.ear -name webapp1

weblogic.Deployer invoked with options: -adminurl t3://localhost:7001 -user weblogic -debug -verbose -deploy -upload -source webapp1.ear -name webapp1


Hence, I hardcoded the heap size in the command in the Deployment Settings like this :-

${java} -Xms256m -Xmx512m
-classpath ${weblogic.jar} weblogic.Deployer
-adminurl t3://${hostname}:${port}
-user ${username} -password ${password}
-debug -verbose -deploy -upload
-source ${ear.file} -name ${j2ee.app.name}


At the time of depoyment, I noticed that the heap size as now being used correctly :-

javaw.exe -Xms256m -Xmx512m -classpath weblogic.jar weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password **** -debug -verbose -deploy -upload -source webapp1.ear -name webapp1

weblogic.Deployer invoked with options: -adminurl t3://localhost:7001 -user weblogic -debug -verbose -deploy -upload -source webapp1.ear -name webapp1

After making this change, I was able to get a clean deployment from my JDeveloper 10.1.3.

.
.
.
[BasicOperation.execute():425] : Initiating deploy operation for app, webapp1, on targets:
Task 2 initiated: [Deployer:149026]deploy application webapp1 on examplesServer.
Task 2 completed: [Deployer:149026]deploy application webapp1 on examplesServer.
Target state: deploy completed on Server examplesServer
.
.
.
[ServerConnectionImpl.close():354] : Unregistered all listeners
[ServerConnectionImpl.closeJMX():374] : Closed JMX connection
[ServerConnectionImpl.closeJMX():386] : Closed Runtime JMX connection
[ServerConnectionImpl.closeJMX():398] : Closed Edit JMX connection
Elapsed time for deployment: 1 minute, 45 seconds
---- Deployment finished. ---- Jun 24, 2008 11:23:54 AM

Friday, June 20, 2008

WebLogic Server 10 : Deployment : Increase Server JVM Heap Space

I had to increase the WebLogic Server's JVM Memory Arguments to circument a problem.

The JVM Memory arguments are in the file " setDomainEnv.cmd " in the folder $WEBLOGIC_HOME\wlserver_10.0\samples\domains\wl_server\bin\

You can open the file in any Text Editor and scroll down to this line :-

set MEM_ARGS=-Xms256m -Xmx512m


You can alter the memory arguments to solve the problem. The combination that worked for me is tis :-

set MEM_ARGS=-512 -Xmx512m

WebLogic Server 10 : is the HTTP server a weblogic Server

I just hit a CommunicationException in my JDeveloper 10.1.3 :-

"
Caused by: javax.naming.CommunicationException [Root exception is java.net.ConnectException: http://localhost:7001: Destination unreachable; nested exception is: java.net.ProtocolException: Tunneling result unspecified - is the HTTP server at host: 'localhost' and port: '7001' a WebLogic Server?; No available router to destination] at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:40) at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:773) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:363) at weblogic.jndi.Environment.getContext(Environment.java:307) at weblogic.jndi.Environment.getContext(Environment.java:277) at weblogic.jndi.Environment.createInitialContext(Environment.java:200) at weblogic.jndi.Environment.getInitialContext(Environment.java:184) at weblogic.jndi.Environment.getInitialContext(Environment.java:162) at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.getContext(ServerConnectionImpl.java:330) at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.getEnvironment(ServerConnectionImpl.java:302) at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.init(ServerConnectionImpl.java:141) ... 11 more
"


I was trying to deploy an application from JDeveloper 10.1.3 to WebLogic Server 10. First, I created a connection to the WebLogic Server 10 using these connection settings :-


I then created a deployment profile for my Web Application. I right-clicked on the Deployment Profile and selected the option to directly deploy to my WebLogic Server. However, I kept getting this error.

I did some Googling & came across this post on the OTN JDeveloper Forums :-

http://forums.oracle.com/forums/thread.jspa?messageID=2134174&#2134174

To summarize Deepak's solution from the post,

"

JDeveloper 10.1.3.3 configures a connection with WebLogic server with the t3 protocol.The deployment profile has the connection protocol specified as http. Modify the connection protocol in the deployment profile.

1. In the Deployment Profile Properties window select the Platform>WebLogic 9.x node.
2. In the WebLogic 9.x Deploy command modify:
-adminurl http://${hostname}:${port}  

to
-adminurl t3://${hostname}:${port}  
"


I made this change in my Deployment Profile & it worked immediately.

WebLogic Server 10 : JDeveloper : Cannot instantiate class: weblogic.jndi.WLInitialContextFactory

"

Cannot instantiate class: weblogic.jndi.WLInitialContextFactory

"

I was trying to create a connection to WebLogic Server 10 from JDeveloper 10.1.3 & I encountered this error. The Connection Wizard threw this error when I wanted to test the connection.

The problem is simple - JDeveloper cannot find the class WLInitialContextFactory required to connect to my WebLogic Server.

The class is present in the JAR File weblogic.jar. The JAR file is present in the folder $WEBLOGIC_HOME/wlserver_10.0\server\lib.

I simply copied the weblogic.jar file from $WEBLOGIC_HOME\wlserver_10.0\server\lib and put it in JDEVELOPER_HOME\jdev\lib\ext

JDeveloper was able to find the JAR File & proceed with the connection without any hitch.

WebLogic Server 10 : Error 403--Forbidden

"

Error 403--Forbidden
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.4 403 Forbidden

The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.

"

I hit this error immediately after deploying and starting the application. The error is quire eloquent, but in my humble opinion, is not very clear about the reasons for the error.

I clicked on the "Testing" link for the application & simply clicked on the "Test Point" URL mentioned on the page :-

http://10.177.226.140:7001/webapp1

I worked on this for sometime & then it hit me :-

I have to supply the complete URL for my JSP.

I tried the complete URL & it worked.

http://10.177.226.140:7001/webapp1/First.jsp

I am just posting this for future reference to newcomers like me.

WebLogic Server 10 : 503--Service Unavailable

"

Error 503--Service Unavailable
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.4 503 Service Unavailable

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay may be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.

Note: The existence of the 503 status code does not imply that a server must use it when becoming overloaded. Some servers may wish to simply refuse the connection.

"

I hit this error after deploying an application & trying out the URL for my JSP.

I have primarily worked on OC4J & expected that the steps would be pretty much the same. However, I hit this bug & was scracthing my head for quite sometime - until I realized it.

The Application has to be started after the deployment.

The application is not started by default ( as in OC4J ) & thus, was unavailable to service the requests.

I am just posting this for future reference to newcomers like me.

WebLogic Server 10 : Authentication Denied

"
Authentication Denied

The username or password has been refused by WebLogic Server. Please try again.

"
I just installed the WebLogic Server 10 & was excited to see the Welcome Screen pop-up on my browser. I then clicked on the "Start the Administration Console" button & the login page popped up.

I tried a couple of usernames and passwords, but I kept getting this error.



I finally tried this combination & it clicked :-

UserName : weblogic
Password : weblogic

Hurray ! I got into the WebLogic Server Administration Console.