Posts Tagged ‘Weblogic’
Tutorial: from an application, make a clustered application, within WebLogic 10
Abstract
You have a non-clustered installation, on the host with DNS name jonathanDevDesktop
, with an admin (port: 7001), a muletier (port: 7003) and a webtier (port: 7005) instances.
You need set your muletier as a clustered installation, with two nodes, on the same server. The second node will dedeployed on port 7007.
We assume you have a configured JMS Modules (in our case: JmsMqModule, even though the bridge between WebLogic and MQ has no impact here).
Process
Batches
- Copy
$DOMAINS\jonathanApplication\start-muletier-server.bat"
as$DOMAINS\jonathanApplication\start-muletier-server-2.bat"
- Edit it:
- Possibly, modify the debug port (usually:
5006
) - Replace the line
call "%DOMAIN_HOME%\bin\startManagedWebLogic.cmd" muletier t3://jonathanDevDesktop:7001
with
call "%DOMAIN_HOME%\bin\startManagedWebLogic.cmd" muletier2 t3://jonathanDevDesktop:7001
- Possibly, modify the debug port (usually:
Second Node Creation
- Following points are not required.
- Copy the folder
%DOMAIN_HOME%\servers\muletier
as%DOMAIN_HOME%\servers\muletier2
- Delete the folders
%DOMAIN_HOME%\servers\muletier2\cache
and%DOMAIN_HOME%\servers\muletier2\logs
- Copy the folder
- Stop the server
muletier
- On WebLogic console:
- Servers > New > Server Name:
muletier2
, Server Listen Port:7007
> CheckYes, create a new cluster for this server.
> Next - Name:
jonathanApplication.cluster.muletier
> Messaging Mode:Multicast
, Multicast Address:239.235.0.4
, Multicast Port:5777
- Clusters >
jonathanApplication.cluster.muletier
> Configuration > Servers > Select a server:muletier
- Clusters >
jonathanApplication.cluster.muletier
> Configuration > Servers > Select a server:muletier2
- Servers > New > Server Name:
- Start the instances of
muletier
andmuletier2
in MS-DOS consoles. - On the WebLogic console:
- Deployments >
jonathanApplication-web
(the mule instance) > Targets > check “jonathanApplication.cluster.muletier
” and “All servers in the cluster
” > Save
- Deployments >
- On the
muletier2
DOS console, you can see the application is deployed.
JMS Configuration
The deployment of JMS on clustered environment is a little tricky.
- On WebLogic console: JMS Modules >
JmsMqModule
> Targets > check “jonathanApplication.cluster.muletier
” and “All servers in the cluster
“ - Even though it is not required, restart your muletiers. Then you can send messages either on port 7003 or 7007, they will be popped and handled the same way.
Tutorial: Use WebShere MQ as JMS provider within WebLogic 10.3.3, and Mule ESB as a client
Abstract
You have an application deployed on WebLogic 10 (used version for this tutorial: 10.3.3). You have to use an external provider for JMS, in our case MQ Series / WebSphere MQ.
The client side is a Mule ESB launched in standalone.
Prerequisites
You have:
- a running WebLogic 10 with an admin instance and an another instance, in our case: Muletier.
- a file
file.bindings
, used for MQ.
JARs installation
- Stop all your WebLogic 10 running instances.
- Get the JARs from MQ Series folders:
providerutil.jar
fscontext.jar
dhbcore.jar
connector.jar
commonservices.jar
com.ibm.mqjms.jar
com.ibm.mq.jar
- Copy them in your domain additional libraries folder (usually:
user_projects/domains/jonathanApplication/lib/
) - Start WebLogic 10 admin. A block like this should appear:
[java]<Oct 15, 2010 12:09:21 PM CEST> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory contents added to the end of the classpath:
C:\win32app\bea\user_projects\domains\jonathanApplication\lib\com.ibm.mq.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\com.ibm.mqjms.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\commonservices.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\connector.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\dhbcore.jar;C:\win32app\bea\user_projects\domains\jonathanApplication\lib\fscontext.jar;C:\win32app\bea\
user_projects\domains\jonathanApplication\lib\providerutil.jar>[/java]
Config
- Get
file.bindings
, copy it intouser_projects/domains/jonathanApplication/config/jms
, rename it as.bindings
(without any prefix) - Launch the console, login
JMS
>JMS Modules
>Create JMS System Module
>Name
: JmsMqModule. Leave other fields empty. >Next
> target serverMuleTier
>Finish
- Select
JmsMqModule
>New
>Foreign Server
> Name:MQForeignServer
> keep check MuleTier >Finish
- Select MQForeignServer >
- JNDI Initial Context Factory: replace
weblogic.jndi.WLInitialContextFactory
with:com.sun.jndi.fscontext.RefFSContextFactory
- JNDI Connection URL: set the URI of the folder containing the
.bindings
file, eg:file://c/win32app/bea/user_projects/domains/jonathanApplication/config/jms
- JNDI Initial Context Factory: replace
- Tab
Connection Factories
> New >- Name:
MQForeignConnectionFactory
- Local JNDI Name: the JNDI name on WebLogic side, eg:
jonathanApplication/jms/connectionFactory/local
(convention I could observe: separator on WebLogic: slash'/'
; unlike clients for which the separator in a dot'.'
) - Remote JNDI Name: the JNDI name on MQ side, eg:
JONATHAN_APPLICATION.QCF
- OK
- Name:
- Tab
Destinations
> New >- Queue of requests:
- Name:
JONATHAN.APPLICATION.REQUEST
- Local JNDI Name:
JONATHAN.APPLICATION.REQUEST
- Remote JNDI Name:
JONATHAN.APPLICATION.REQUEST
- Name:
- Queue of response:
- Name:
JONATHAN.APPLICATION.REPONSE
- Local JNDI Name:
JONATHAN.APPLICATION.REPONSE
- Remote JNDI Name:
JONATHAN.APPLICATION.REPONSE
- Name:
- NB: usually, MQ data are upper-cased and Java’s JNDI names are low-cased typed ; anyway (because of Windows not matching case?) here we use uppercase in for both names.
- Queue of requests:
- Select MQForeignServer >
Mule
This part of the tutorial deals with a case of Mule ESB being your client application (sending and/or receiving JMS messages).
- Get the archive
wlfullclient.jar
(56MB). Alternatively, you can generate it yourself: go to the server/lib directory of your WebLogic installation (usually:C:\win32app\bea\wlserver_10.3\server\lib
, and run:java -jar wljarbuilder.jar
- Copy the archive into
$MULE_HOME/lib/user
- Copy the seven jars above (
providerutil.jar
,fscontext.jar
,dhbcore.jar
,connector.jar
,commonservices.jar
,com.ibm.mqjms.jar
,com.ibm.mq.jar
) into the same folder:$MULE_HOME/lib/user
- You can launch the mule. The config file is similar to any other configuration using standard JMS.
Use a JDBC datasource from WebLogic’s JNDI
Case
Your application is connected to a database. The configuration of the DB connexion is set in a Spring file. You would like the connexion to be set in WebLogic, so that no URL/login/password lays in your source code.
Steps
WebLogic
Create a new data source:
- go the WebLogic console >
- JDBC >
- DataSource >
- New >
- set the name, JNDI name (eg:
database.jndi.name
), DB type (Oracle, Sybase, …) >- Next >
- Select the driver >
- Next >
- Select the targeted server(s)
- Next >
- Select the driver >
- Next >
- set the name, JNDI name (eg:
- New >
- DataSource >
- JDBC >
This will
- create a new file
<yourDomain>/config/jdbc/<datasourceName>-XXXX-jdbc.xml
. - add a
<jdbc-system-resource>
block in<yourDomain>/config/config.xml
Spring
Replace the block:
[xml]<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${database.driver}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>[/xml]
with:
[xml]<jee:jndi-lookup id="dataSource" jndi-name="${database.jndi.name}" />[/xml]
WebLogic Deployment with Maven: Dynamic Property Settings
Case
You have to deploy a WAR archive on a WebLogic server. To simplify the deployment process, you use weblogic-maven-plugin
. Then, you only have to launch a mvn clean install weblogic:deploy
to compile and deploy the WAR.
Actually, the plugin configuration expects you to hard write the settings in the pom.xml
, such as:
[xml]<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<name>myWebApplication-web</name>
<adminServerHostName>localhost</adminServerHostName>
<adminServerPort>7001</adminServerPort>
<adminServerProtocol>t3</adminServerProtocol>
<targetNames>myTargetServer</targetNames>
<userId>myUserId</userId>
<password>myPassword</password>
<securitymodel>Advanced</securitymodel>
<artifactPath>${project.build.directory}/myWebApplication-web.war</artifactPath>
</configuration>
</plugin>[/xml]
Yet, when you work on a multi-environment / multi-developper platform, hard writing the properties bothers. Production teams are not pleased, and, above all, it’s not safe.
Unworking fix
At first glance, I tried to use Maven filtering mechanisms. Anyway, this features was designed for compilation phase: properties are recopied from a property file to the actual one, and then included in the archive generated (may it be JAR, EAR or WAR); in a deployment phase, properties are not taken in account.
http://maven.apache.org/guides/getting-started/index.html#How_do_I_filter_resource_files
Unelegant fix
Another solution is to set properties by profile. This works, but is not elegant at all: the password for production environment has to reason to be readable in the pom.xml
used by a developper!
Fix
WebLogic / Maven plugin
Add the following block:
[xml]<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<name>myWebApplication-web</name>
<adminServerHostName>${weblogic.server.name}</adminServerHostName>
<adminServerPort>${weblogic.server.port}</adminServerPort>
<adminServerProtocol>${weblogic.server.protocol}
</adminServerProtocol>
<targetNames>${weblogic.target}</targetNames>
<userId>${weblogic.user}</userId>
<password>${weblogic.password}</password>
<securitymodel>${weblogic.security}</securitymodel>
<artifactPath>${project.build.directory}/myWebApplication-web.war
</artifactPath>
</configuration>
</plugin>[/xml]
Properties / Maven plugin
Under the tag, add the block:
[xml]<properties>
<weblogic.server.name>${myTargetServer.server.name}</weblogic.server.name>
<weblogic.server.port>${myTargetServer.server.port}</weblogic.server.port>
<weblogic.server.protocol>${myTargetServer.server.protocol}</weblogic.server.protocol>
<weblogic.user>${myTargetServer.user}</weblogic.user>
<weblogic.password>${myTargetServer.password}</weblogic.password>
<weblogic.target>${myTargetServer.target}</weblogic.target>
<weblogic.security>${myTargetServer.security}</weblogic.security>
</properties>[/xml]
Within the block, add the the following block:
[xml]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>conf/${maven.user}.myTargetServer.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>[/xml]
Settings.xml
Optionnaly, in your settings.xml, in your default profile, set the following property:
[xml]<profile></pre>
<id>myDefaultProfile</id>
<properties>
<maven.user>jonathan_lalou</maven.user>
</properties>
</profile>[/xml]
You can decide to bypass this step. In this case, you will have to add the following parameter on launching Maven:
-Dmaven.user=jonathan_lalou
Property file
Create a property file, with a name corresponding to the one you specified in maven.user property.
[java]
myTargetServer.server.name=localhost
myTargetServer.server.port=7001
myTargetServer.server.protocol=t3
myTargetServer.user=myUserId
myTargetServer.password=myPassword
myTargetServer.target=myTargetServer
myTargetServer.security=Advanced[/java]
Now, you can launch mvn package weblogic:deploy
. The WAR will be deployed on the right server.
weblogic-maven-plugin / java.net.MalformedURLException: no protocol: and
Case
I run mvn weblogic:deploy
, with a correct configuration inside pom.xml
file, in order to deploy a WAR on a WebLogic 10 server. My development machine runs under Windows XP, the distant server is under Linux. I get the following error:
java.net.MalformedURLException: no protocol: and
Complete stacktrace:
[java][INFO] Scanning for projects…
[INFO] Searching repository for plugin with prefix: ‘weblogic’.
[INFO] ————————————————————————
[INFO] Building myWar Maven Webapp
[INFO] task-segment: [weblogic:deploy]
[INFO] ————————————————————————
Downloading: http://repository.codehaus.org/weblogic/weblogic/9.0/weblogic-9.0.pom
[INFO] Unable to find resource ‘weblogic:weblogic:pom:9.0’ in repository codehaus.org (http://repository.codehaus.org)
Downloading: http://repo1.maven.org/maven2/weblogic/weblogic/9.0/weblogic-9.0.pom
[INFO] Unable to find resource ‘weblogic:weblogic:pom:9.0’ in repository central (http://repo1.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/weblogic/weblogic/9.0/weblogic-9.0.pom
[INFO] Unable to find resource ‘weblogic:weblogic:pom:9.0’ in repository central (http://repo1.maven.org/maven2)
Downloading: http://repository.codehaus.org/weblogic/webservices/9.0/webservices-9.0.pom
[INFO] Unable to find resource ‘weblogic:webservices:pom:9.0’ in repository codehaus.org (http://repository.codehaus.org)
Downloading: http://repo1.maven.org/maven2/weblogic/webservices/9.0/webservices-9.0.pom
[INFO] Unable to find resource ‘weblogic:webservices:pom:9.0’ in repository central (http://repo1.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/weblogic/webservices/9.0/webservices-9.0.pom
[INFO] Unable to find resource ‘weblogic:webservices:pom:9.0’ in repository central (http://repo1.maven.org/maven2)
[INFO] [weblogic:deploy]
[INFO] Weblogic Deployment beginning with parameters DeployMojoBase[adminServerHostName = myLocalHost, adminServerProtocol = t3, adminServerPort = 7001, userId = weblogic, password = myPassword, artifactPath = C:\…\target/myWar.war, projectPackaging = war, name = myWar, targetNames = oneTier, remote = true]
[INFO] Weblogic Deployment parameters [-adminurl, t3://myLocalHost:7001, -username, weblogic, -password, myPassword, -verbose, -debug, -name, myWar, -targets, muletier, -upload, -source, C:\…\target/myWar, -deploy]
weblogic.Deployer invoked with options: -adminurl t3://myLocalHost:7001 -username weblogic -verbose -debug -name myWar -targets muletier -upload -source C:\workarea\development\primeweb\primeweb\projects\strategic\myWar\target/myWar -deploy
[WebLogicDeploymentManagerImpl.<init>():103] : Constructing DeploymentManager for J2EE version V1_4
deployments
[WebLogicDeploymentManagerImpl.getNewConnection():146] : Connecting to admin server at myLocalHost:7001, as user weblogic
[ServerConnectionImpl.getEnvironment():288] : setting environment
[ServerConnectionImpl.getEnvironment():291] : getting context using t3://myLocalHost:7001
[ServerConnectionImpl.getMBeanServer():239] : Connecting to MBeanServer at service:jmx:t3://myLocalHost:7001/jndi/weblogic.management.mbeanservers.domainruntime
[ServerConnectionImpl.getMBeanServer():239] : Connecting to MBeanServer at service:jmx:t3://myLocalHost:7001/jndi/weblogic.management.mbeanservers.runtime
[DomainManager.resetDomain():36] : Getting new domain
[DomainManager.resetDomain():39] : Using pending domain: true
[MBeanCache.addNotificationListener():96] : Adding notification listener for weblogic.deploy.api.spi.deploy.mbeans.TargetCache@19ccba
[MBeanCache.addNotificationListener():107] : Disabling mbean caching due to: java.net.MalformedURLException: no protocol: and
[MBeanCache.addNotificationListener():96] : Adding notification listener for weblogic.deploy.api.spi.deploy.mbeans.ModuleCache@ae1cf
[MBeanCache.addNotificationListener():107] : Disabling mbean caching due to: java.net.MalformedURLException: no protocol: and
[ServerConnectionImpl.initialize():171] : Connected to WLS domain: myMainDomain
[ServerConnectionImpl.setRemote():482] : Running in remote mode
[ServerConnectionImpl.init():161] : Initializing ServerConnection : weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl@a0e990
[BasicOperation.dumpTmids():690] : Incoming tmids:
[BasicOperation.dumpTmids():692] : {Target=muletier, WebLogicTargetType=server, Name=myWar}, targeted=true
[BasicOperation.deriveAppName():139] : appname established as: myWar
<Aug 16, 2010 11:46:42 AM CEST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, myWar [archive: C:\workarea\development\primeweb\primeweb\projects\strategic\myWar\target\myWar], to muletier .>
[ServerConnectionImpl.upload():658] : Uploaded app to C:\win32app\bea\user_projects\domains\myMainDomain\.\servers\adminServer\upload\myWar
[BasicOperation.dumpTmids():690] : Incoming tmids:
[BasicOperation.dumpTmids():692] : {Target=muletier, WebLogicTargetType=server, Name=myWar}, targeted=true
[BasicOperation.loadGeneralOptions():607] : Delete Files:false
Timeout :3600000
Targets:
muletier
ModuleTargets={}
SubModuleTargets={}
}
Files:
null
Deployment Plan: null
App root: C:\win32app\bea\user_projects\domains\myMainDomain\.\servers\adminServer\upload\myWar
App config: C:\win32app\bea\user_projects\domains\myMainDomain\.\servers\adminServer\upload\myWar\plan
Deployment Options: {isRetireGracefully=true,isGracefulProductionToAdmin=false,isGracefulIgnoreSessions=false,rmiGracePeriod=-1,retireTimeoutSecs=-1,undeployAllVersions=false,archiveVersion=null,planVersion=null,isLibrary=false,libSpecVersion=null,libImplVersion=null,stageMode=null,clusterTimeout=3600000,altDD=null,altWlsDD=null,name=myWar,securityModel=null,securityValidationEnabled=false,versionIdentifier=null,isTestMode=false,forceUndeployTimeout=0,defaultSubmoduleTargets=true,timeout=0}
[BasicOperation.execute():424] : Initiating deploy operation for app, myWar, on targets:
[BasicOperation.execute():426] : muletier
<strong>java.net.MalformedURLException: no protocol: and</strong>
at java.net.URL.<init>(URL.java:567)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at sun.rmi.server.LoaderHandler.pathToURLs(LoaderHandler.java:751)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:147)
at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
at javax.management.remote.rmi.RMIConnectionImpl$6.run(RMIConnectionImpl.java:1513)
at java.security.AccessController.doPrivileged(Native Method)
at javax.management.remote.rmi.RMIConnectionImpl.unwrap(RMIConnectionImpl.java:1505)
at javax.management.remote.rmi.RMIConnectionImpl.access$500(RMIConnectionImpl.java:72)
at javax.management.remote.rmi.RMIConnectionImpl$7.run(RMIConnectionImpl.java:1548)
at java.security.AccessController.doPrivileged(Native Method)
at javax.management.remote.rmi.RMIConnectionImpl.unwrap(RMIConnectionImpl.java:1544)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:771)
at javax.management.remote.rmi.RMIConnectionImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
[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[/java]
Explanation
Indeed, the " and "
comes from the address of my local Maven 2 repository: C:\Documents and Settings\myLogin\.m2\repository
, which is the default location. I consider this to be a bug of Mojo’s weblogic-maven-plugin plugin
.
Fix
You do not have many choices :-(… You have to move your repository to a destination without blank spaces, such as C:\M2_repository
.
Then, take care to edit your settings.xml
, and add the following block after <settings>
tag:
[xml]<localRepository>C:\M2_repository</localRepository>[/xml]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
Error:
While launching a WebLogic (10.3.3) server, I got the exception:
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
Fix:
Indeed, I had another WebLogic (9.2) instance running. Both of them were running in Debug mode, with the same debug port.
To fix the issue, check if your are not in the same situation: two applications running on the same debug port.
Another point is a little mysterious: when I run WebLogic 10 instance before the WebLogic 9, then an error occurs, too, but the message is different:
ERROR: transport error 202: bind failed: Address already in use ["transport.c",L41]
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) ["debugInit.c",L500]
JDWP exit error JVMTI_ERROR_INTERNAL(113): No transports initializedThe application has requested the JVM to exit with an fatal error from JNI. Error message:
JDWP No transports initialized, jvmtiError=JVMTI_ERROR_INTERNAL(113)
Press any key to continue . . .
GWT in noserver mode with Tomcat or WebLogic
Abstract
You would like to work on the client side of your GWT application, without building and deploying the Jetty server. Or, in the same way, you need test some server features available in WebLogic but not in Jetty, such as the EJB.
GWT 2.0 documentation, at the segment How do I use my own server in hosted mode instead of GWT’s built-in Jetty instance? is not precise at all on the 3rd step: it simply states:
“change the URL at the end of the argument list to match the URL you recorded in step #1.”
Process
- Let’s assume your WAR is deployed on
http://distantMachine:8080/myApplication
. The servlet container may be Tomcat or WebLogic, it does not matter - In Eclipse, go in “
Run Configuration...
“. Duplicate your current and classic GWT application configuration. - Go in
Server
, uncheck “Run built-in server
“. - In
Arguments
tab, write the following line:
[java]-noserver -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -logLevel INFO -war C:\eclipse\workspace\myApplication\src\main\webapp\lalou.jonathan.web.gwt.MyApplication -startupUrl http://distantMachine:8080/myApplication lalou.jonathan.web.gwt.MyApplication[/java] - Run
- The application is available at the following address:
[html]http://distantMachine:8080/muyApplication/?gwt.codesvr=127.0.0.1:9997[/html]
Error 403 with Maven 2 deployment
Case
This morning, I tried to redeploy an EAR on a WebLogic 9.2, using Maven 2 and a classical deployment profile. I got this issue:
[java][ERROR] BUILD ERROR
[INFO] ————————————————————————
[INFO] Error executing ant tasks
Embedded error: The following error occurred while executing this line:
(…)
weblogic.deploy.api.internal.utils.DeployerHelperException: The source ‘C:\DOCUME~1\myLogin\LOCALS~1\Temp\myApplication-ear.ear’ for the application ‘my-application-ear’ could not be loaded to the server ‘http://myServer:1234/bea_wls_deployment_internal/DeploymentService’.
Response: ‘403: Forbidden’ for url: ‘http://myServer:1234/bea_wls_deployment_internal/DeploymentService'[/java]
Yesterday, I got a similar error when I launched a mvn tomcat:deploy
to deploy a WAR on a Tomcat 6.0 server:
[java][ERROR] BUILD ERROR
[INFO] ————————————————————————
[INFO] Cannot invoke Tomcat manager
Embedded error: Server returned HTTP response code: 403 for URL: http://myServer:3210/manager/deploy?path=%2FmyWebArchive&war=&update=true[/java]
Quick Fix
Running Maven2 in offline line, ie adding the option "-o"
, allows me to redeploy both the EAR on WebLogic and the WAR on Tomcat.
eg: mvn tomcat:deploy -o
I keep on investigating on this matter. I think there is an issue on the DNS. Indeed, when I deploy locally to my own machine myServer
(ie with its network name), this error is raised, but when I deploy to localhost
the build is successful.
GWT: call a remote EJB with Spring lookup
Abstract
Let’s assume you have followed the article “Basic RPC call with GWT“. Now you would like to call an actual EJB 2 as remote, via a Spring lookup.
Let’s say: you have an EJB MyEntrepriseComponentEJB
, which implements an interface MyEntrepriseComponent
. This EJB, generates a remote MyEntrepriseComponentRemote
.
Entry Point
In myApplication.gwt.xml
entry point file, after the line:
[xml]<inherits name=’com.google.gwt.user.User’/>[/xml]
add the block:
[xml]
<inherits name=’com.google.gwt.user.User’ />
<inherits name="com.google.gwt.i18n.I18N" />
<inherits name="com.google.gwt.http.HTTP" />[/xml]
Add the line:
[xml]<servlet path=’/fooService.do’/>[/xml]
Client
Under the *.gwt.client
folder:
Update the service interface. Only the annotation parameter is amended:
[java]@RemoteServiceRelativePath("services/fooService")
public interface FooService extends RemoteService {
public String getHelloFoo(String fooName);
}[/java]
You have nothing to modify in asynchronous call interface (FooServiceAsync
).
Server
Under the *.gwt.server folder
, update the implementation for service interface:
Change the super-class, replacing RemoteServiceServlet
with GWTSpringController
:
[java]public class FooServiceImpl extends GWTSpringController implements FooService {
public FooServiceImpl() {
// init
}
}
[/java]
Add new field and its getter/setter:
[java]// retrieved via Spring
private myEntrepriseComponent myEntrepriseComponent;
public myEntrepriseComponent getMyEntrepriseComponent() {
return myEntrepriseComponent;
}
public void setmyEntrepriseComponent(myEntrepriseComponent _myEntrepriseComponent) {
myEntrepriseComponent = _myEntrepriseComponent;
}[/java]
Write the actual call to EJB service:
[java]
public String getHelloFoo(String fooName) {
return myEntrepriseComponent.getMyDataFromDB();
}
}[/java]
web.xml
Fill the web.xml
file:
[xml]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!– Spring –>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>gwt-controller</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>gwt-controller</servlet-name>
<url-pattern>/myApplication/services/*</url-pattern>
</servlet-mapping>
<!– Default page to serve –>
<welcome-file-list>
<welcome-file>MyApplicationGwt.html</welcome-file>
</welcome-file-list>
</web-app>
[/xml]
JNDI
Add a jndi.properties
file in src/resources folder
:
[java]
java.naming.provider.url=t3://localhost:12345
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.security.principal=yourLogin
java.naming.security.credentials=yourPassword
weblogic.jndi.enableDefaultUser=true[/java]
These properties will be used by Spring to lookup the remote EJB. The last option is very important, otherwise you may happen to face issues with EJB if they were deployed under WebLogic.
WEB-INF
In the WEB-INF
folder, add an applicationContext.xml
file:
[xml]<?xml version="1.0" encoding="UTF-8"?>
<beans>
<util:properties id="jndiProperties" location="classpath:jndi.properties" />
<jee:remote-slsb id="myEntrepriseComponentService"
jndi-name="ejb.jonathan.my-entreprise-component"
business-interface="lalou.jonathan.myApplication.services.myEntrepriseComponent"
environment-ref="jndiProperties" cache-home="false"
lookup-home-on-startup="false" refresh-home-on-connect-failure="true" />
</beans>[/xml]
Add a gwt-controller-servlet.xml
file:
[xml]<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<bean>
<property name="order" value="0" />
<property name="mappings">
<value>
/fooService=fooServiceImpl
</value>
</property>
</bean>
<bean id="fooServiceImpl"
class="lalou.jonathan.myApplication.web.gwt.server.FooServiceImpl">
<property name="myEntrepriseComponent" ref="myEntrepriseComponentService" />
</bean>
</beans>
[/xml]
Of course, if your servlet mapping name in web.xml
is comoEstasAmigo, then rename gwt-controller-servlet.xml
as comoEstasAmigo-servlet.xml
😉
Build and deploy
Now you can compile, package your war and deploy under Tomcat or WebLogic. WebLogic server may raise an error:
java.rmi.AccessException: [EJB:010160]Security Violation: User: '<anonymous>' has insufficient permission to access EJB
This error is related to the rights required to call a method on the EJB. Indeed, two levels of rights are used by WebLogic: firstly to lookup / instanciate the EJB (cf. the property java.naming.security.principal
we set sooner), and another to call the method itself. In this second case, WebLogic requires an authentication (think of what you do when you login an web application deployed: your login and rights are kept for all the session) to grant the rights. I wish to handle this subject in a future post.
NB: thanks to David Chau and Didier Girard from SFEIR, Sachin from Mumbai team and PYC from NYC.
WebLogic deployment automatization with Maven and/or Ant
Case
I had to automatize the deployment of a basic GWT application, packaged as a WAR
archive, on a WebLogic 9.2 server.
Maven 2
Mojo Plugin
Firstly, I tried to use Mojo’s maven plugin for Weblogic. I had to add some lines in my pom.xml, almost identical to those available in Mojo’s documentation.
The main issue I encountered was to retrieve the jars mandatory to the plugin, and install them in my local Maven repository. Since the missing jars names given by Maven are not so obvious, here are the paths to retrieve these jars, all included with WebLogic 9.2 installation:
[java]mvn install:install-file -DgroupId=weblogic -DartifactId=xbean -Dversion=9.2 -Dpackaging=jar -Dfile=%BEA_HOME%\server\lib\wlxbean.jar
mvn install:install-file -DgroupId=weblogic -DartifactId=wlw-langx -Dversion=9.2 -Dpackaging=jar -Dfile=%BEA_HOME%\server\lib\wlw-langx.jar
mvn install:install-file -DgroupId=weblogic -DartifactId=wlw-util -Dversion=9.2 -Dpackaging=jar -Dfile="%BEA_HOME%\common\lib\wlw-util.jar"
mvn install:install-file -DgroupId=weblogic -DartifactId=bcel -Dversion=5.1 -Dpackaging=jar -Dfile="%BEA_HOME%\javelin\lib\bcel-5.1.jar"
mvn install:install-file -DgroupId=weblogic -DartifactId=javelinx -Dversion=9.2 -Dpackaging=jar -Dfile="%BEA_HOME%\javelin\lib\javelinx.jar"
mvn install:install-file -DgroupId=weblogic -DartifactId=weblogic-container-binding -Dversion=9.2 -Dpackaging=jar -Dfile="%BEA_HOME%\server\lib\schema\weblogic-container-binding.jar"[/java]
Issues
Once this issue fixed, I tried to launch the deployment (with mvn weblogic:deploy
). But I encountered the following error:
Response: '404: Not Found' for url: 'http://localhost:7070/bea_wls_deployment_internal/DeploymentService'
Complete stacktrace in debug and verbose mode:
[java]weblogic.deploy.api.internal.utils.DeployerHelperException: The source ‘C:\LOCALS~1\Temp\appliGWT-1.0-SNAPSHOT.war’ for the application ‘iVarGwt’ could not be loaded to the server ‘http://localhost:7070/bea_wls_deployment_internal/DeploymentService’.
Response: ‘404: Not Found’ for url: ‘http://localhost:7070/bea_wls_deployment_internal/DeploymentService’
at weblogic.deploy.api.internal.utils.JMXDeployerHelper.uploadSource(JMXDeployerHelper.java:658)
at weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.upload(ServerConnectionImpl.java:653)
at weblogic.deploy.api.spi.deploy.internal.BasicOperation.uploadFiles(BasicOperation.java:319)
at weblogic.deploy.api.spi.deploy.internal.BasicOperation.execute(BasicOperation.java:411)
at weblogic.deploy.api.spi.deploy.internal.BasicOperation.run(BasicOperation.java:169)
at weblogic.deploy.api.spi.deploy.WebLogicDeploymentManagerImpl.deploy(WebLogicDeploymentManagerImpl.java:369)
at weblogic.deploy.api.tools.deployer.DeployOperation.execute(DeployOperation.java:47)
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 org.codehaus.mojo.weblogic.DeployMojoBase.executeDeployer(DeployMojoBase.java:510)
at org.codehaus.mojo.weblogic.DeployMojo.execute(DeployMojo.java:49)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)[/java]
Deploying another application worked, deploying my application using WebLogic console worked too… After many hours of search, I gave up Maven2 way.
Ant
After retiring from using Mojo’s plugin, I used a way I feared would be less elegant: Ant.
Indeed, Ant script is very short and efficient:
[xml]<?xml version="1.0" encoding="UTF-8"?>
<project name="redeploy" basedir="." default="deploy">
<property file="redeploy.properties" />
<target name="init-weblogic-task">
<available file="${env.WL_HOME}/server/lib/weblogic.jar"
property="weblogic-jar.present" />
<fail unless="weblogic-jar.present">${env.WL_HOME}/server/lib/weblogic.jar does not
exist</fail>
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy"
classpath="${env.WL_HOME}/server/lib/weblogic.jar" />
</target>
<target name="deploy" depends="init-weblogic-task">
<wldeploy action="deploy" source="${source}"
name="${name}" user="${user}" password="${password}" verbose="true"
adminurl="${adminurl}" debug="true" targets="${targets}" upload="true"
securitymodel="${securitymodel}" stage="stage" />
</target>
</project>[/xml]
In the same folder, I created a property file, gathering the properties hinted at in Ant build.xml
.
[java]env.WL_HOME=C:/bea/weblogic_9_2
adminurl=t3://localhost:7070
name=appliGWT
user=weblogic
password=myPassword
targets=myTarget
securitymodel=Advanced
source=../../../target/appliGWT-1.0-SNAPSHOT.war
[/java]
I launched Ant and the deployment was successful.
Maven anyway, but with Ant
Yet, since I build with Maven, I do not want to have to build, change folder, and then deploy: I want a unique command line to package and deploy. To perform that, I added a profile in my pom.xml
, using a Maven plugin to call Ant tasks:
[xml] <profiles>
<profile>
<id>deploy</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<ant antfile="./src/resources/ant/build.xml"
target="deploy"
inheritall="false" inheritrefs="false"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>[/xml]
At last, my target was OK: I can build and deploy with a simple mvn package -Pdeploy