Posts tagged weblogic
In this blog I will show you how you can call a webservice programmatically in Java without using a webservice library like JAX-WS or Apache Axis. Normally you would use of course a webservice library, but in some cases this can be useful and quick; for example when you have problems generating a client proxy with a webservice library or if you only need some small specific parts of the SOAP response XML tree. Â It shows that a SOAP call is just XML over HTTP, from a plain piece of Java code.Â Then, I will show you an example how you can use this and make your own servlet webservice-tester like a simple SoapUI in JDeveloper 184.108.40.206.
With the PS3 release of the SOA Suite a new version, 10.3.4, of Weblogic has been released. Amongst others, this release also includes a new Weblogic Maven plugin (weblogic-maven-plugin) that allows interaction with Weblogic from within a Maven environment. As far as I know, this plugin is the successor of the Codehaus Weblogic plugin. That one was a bit difficult to use because it required some other not publicly available Weblogic dependencies which have now been included with the new plugin. Unfortunately, this plugin is not (yet?!) available in any of the public Maven repositories so you have to put it in your own repository. Because of the size (more than 50 MB) the plugin is not included with Weblogic as-is but must be created first just as other weblogic client utilities. The documentation of the new plugin describes in detail how to create and use the plugin. In this blog I’ll summarize them (NB, I assume you’re a little bit familiar Maven).
- Create the plugin.
- Deploy it to an artifact repository.
- Use the plugin in your project.
Although this should not be so complicated I run into some problems I would like to share in this post. In general it is quit simple to generate a window service that starts a weblogic server. If you read the manual you see you need to create a script that sets some environment variables and finally calls the %WL_HOME%\server\bin\installSvc.cmd script to do the actual creation of the Windows NT Service. Here you can see a sample (I will call this script installAdminServerSvc.cmd)
[sourcecode language="powershell"] @echo off SETLOCAL set DOMAIN_NAME=SOA_DOMAIN set USERDOMAIN_HOME=D:\Oracle\Middleware11gR1PS3\user_projects\domains\SOA_DOMAIN set SERVER_NAME=AdminServer set PRODUCTION_MODE=false set WLS_USER=weblogic set WLS_PW=welcome1 set JAVA_OPTIONS=-Dweblogic.Stdout="D:\Oracle\Middleware11gR1PS3\user_projects\domains\SOA_DOMAIN\AdminServer-stdout.txt" -Dweblogic.Stderr="D:\Oracle\Middleware11gR1PS3\user_projects\domains\SOA_DOMAIN\AdminServer-stderr.txt" set JAVA_VM=-client set MEM_ARGS=-Xms40m -Xmx250m set MAX_CONNECT_RETRIES=3 set HOST=localhost set PORT=7001 call "D:\Oracle\Middleware11gR1PS3\wlserver_10.3\server\bin\installSvc.cmd" ENDLOCAL [/sourcecode]
You need to make one More >
Logging is a very important aspect of application development as it offers run-time access to the behaviour and data of the application. It’s important for debugging purposes but also to investigate exception situations on production. The Java developer has a choice between logging frameworks but Log4J is probably the most used one. The usage is quite simple: grab a Logger, e.g. private static Logger log = Logger.getLogger(MyBean.class);, and then use that logger to log the actual message at the required level, log.debug(“This is a debug message”);. To print the logmessages, the Log4J is configured externally with a properties file that defines the location (e.g. console, file, database etc.) and the format of the logmessages. Other logging frameworks, like Java Util Logging, are used in a similar way. It’s actually a good practice to not use Log4J directly, but to use a wrapping or facade framework, that allows switching of the actual logging implementation itself. In the past that would have been Apache Commons Logging (ACL), but now SLF4J is commonly used because it doesn’t have the classloader issues of ACL and it provides some nice message formatting (and performance) More >
When you configure yor domain in WebLogic 11g, by screen install or by scripts, when you choose Production Mode security will be more strict as in Development Mode.
Normally it would require a boot.properties afterwards to create in order to start; anyway, all kinds of unnecessary steps.
In a scripted install with WLST , here is a way to override it… watch wonderous python!:lol:
First, in your script define some variables:
def createBootPropertiesFile(domain_dir, username, password) : if not os.path.exists(domain_dir + “/servers/” + “AdminServer” + “/security”): os.makedirs(domain_dir + “/servers/” + “AdminServer” + “/security”) filename=(domain_dir + “/servers/” + “AdminServer” + “/security/boot.properties”) f=open(filename, ‘w’) line=’username=’ + username + ‘\n’ f.write(line) line=’password=’ + password + ‘\n’ f.write(line) f.close() else: print ‘domain_dir + “/servers/” + “AdminServer” + “/security” exists’
Then, finally in your WriteDomain statement includewriteDomain(properties.domain_dir) if (properties.production_mode_enabled): createBootPropertiesFile(properties.domain_dir, ‘weblogic’, properties.weblogic_password) else: print ‘Dry run completed, if you still have an More >
Run it with $WL_HOME/ common/bin/wlst.sh -loadPropertiesÂ <property_file> <script_name>Â Â ($WL_HOME is the location of your WebLogic server directory, like /opt/oracle/Middleware/wlserver_10.3)
Property file(properties.py): admin_server=<name adminserver> admin_server_port= wluser=weblogic wlpassword=<password> clustername=[name] domain=<domain_name> Â
#Definition to print a running servers state def printState(AdminServer): connect(wluser, wlpassword, ‘t3://’+ admin_server + ‘:’ + admin_server_port) serverConfig() state(“AdminServer”) state(“[name of managed server1]“) state(“[name_of managed_server2]“)
#Definition to disconnect from a server def disconnectFromServer(): disconnect() exit()
#Calling connectToServer definition with no arguments #connectToServer()
#Calling printstateDetails with arguments printState(‘AdminServer’)
#Calling disconnectFromServer definition with no arguments #disconnectFromServer()