Search
Calendar
March 2024
S M T W T F S
« Sep    
 12
3456789
10111213141516
17181920212223
24252627282930
31  
Your widget title
Archives

Posts Tagged ‘JOnAS’

PostHeaderIcon Hot Redeploy EJBs on JOnAS

Case

I ogten have to redeploy my JEE application on JOnAS. Basically, I stopped the server, copied the files (EAR, JAR, etc.), then started up again the server. I was fed up with implementing this method.
How to speed up?

Solution

Below is a proposal of solution, without any pretention (I am not fond of JOnAS…), based on an Ant script running under Maven. The code is commented, in a summary: build the EAR (or JAR, WAR, etc.), then copy it to JOnAS deploy folder, undeploy the beans, check which beans are still deployed, deploy the new version of the beans, check which beans are deployed:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>copyToJonas</id>
                        <phase>install</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <property name="jonas.root" value="${env.JONAS_ROOT}"/>
                                <property name="jonas.base" value="${env.JONAS_BASE}"/>
                                <echo>Copy files</echo>
                                <copy todir="${jonas.base}/deploy" overwrite="true">
                                    <fileset dir="${build.directory}/">
                                        <include name="*.*ar"/>
                                    </fileset>
                                </copy>
                                <echo>Undeploy beans</echo>
                                <exec executable="${jonas.root}/bin/jonas.bat">
                                    <arg line="admin -r ${jonas.base}/deploy/${artifactId}-${version}.${packaging}"/>
                                </exec>
                                <echo>Currently deployed beans:</echo>
                                <exec executable="${jonas.root}/bin/jonas.bat">
                                    <arg line="admin -j"/>
                                </exec>
                                <echo>Deploy beans:</echo>
                                <exec executable="${jonas.root}/bin/jonas.bat">
                                    <arg line="admin -a ${jonas.base}/deploy/${artifactId}-${version}.${packaging}"/>
                                </exec>
                                <echo>Currently deployed beans:</echo>
                                <exec executable="${jonas.root}/bin/jonas.bat">
                                    <arg line="admin -j"/>
                                </exec>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

At first glance I assume I should swap the phases of copying file and undeploying beans. Anyway, this scripts works for me and allows to redeploy after each mvn clean install 😉

PostHeaderIcon (long tweet) JOnAS / GenIC / Method … of interface … should NOT throw RemoteException

Case

On generating Locals and Remotes of EJBs (let’s say JonathanBean) to be deployed on JOnAS, the GenIC raises:

GenIC.fatalError : GenIC fatal error: Cannot read the Deployment Descriptors from /foo/goo/jonathan-server.jar: Method foo of interface lalou.jonathan.JonathanLocal should NOT throw RemoteException

Within the EJB2, the method foo is declared to be Local and to throw RemoteException

Quickfix

The error is explicit.

A Local EJB cannot throw RemoteException.
Especially, the considered method can be declared with the right XDocLet tag, ie:

* @ejb.interface-method view-type="remote"

but can with neither:

* @ejb.interface-method view-type="both"

nor:

* @ejb.interface-method view-type="local"

As a quickfix, I suggest to surround with a try/catch block a throw a RuntimeException if needed.

PostHeaderIcon (long tweet) JOnAS / no security manager: RMI class loader disabled

On server side:

an EJB2 packaged in a JAR within an EAR, deployed on JOnAS 5.

On client side:

java.lang.ClassNotFoundException: org.ow2.jonas_gen.com.clam.indice.api.interfaces.JOnASHelloWorldService150707405Home_Stub (no security manager: RMI class loader disabled)]

Explanation:

This means there is some kind of issue with generated Stubs on client side. Should check whether the Stubs depended on are available in classpath.

PostHeaderIcon Problems when invoking main method from GenIC … error in fastrmic

Case

Trying to deploy an EAR on JOnAS, I got the following error:

Problems when invoking main method from GenIC: java.lang.RuntimeException: error in fastrmic (null)

More detail:

JOnASEJBService.__checkGenIC : Cannot apply GenIC on the file 'C:\jonathan\jonathan_2012.05.11-13.47.29.ear\jonathan-server.jar' with the args '[-classpath, C:\jonathan\jonathan_2012.05.11-13.47.29.ear\jonathan-server.jar, -protocols, jrmp, -invokecmd]'.
org.ow2.jonas.service.ServiceException : Problems when invoking main method from GenIC: java.lang.RuntimeException: error in fastrmic (null)
        at org.ow2.jonas.generators.genic.wrapper.GenicServiceWrapper.callGenic(GenicServiceWrapper.java:79)
        at org.ow2.jonas.ejb2.internal.JOnASEJBService.__callGenic(JOnASEJBService.java:2017)

Quickfix

Edit $JONAS_BASE/conf/jonas.properties.
The properties jonas.services and jonas.service.ejb2.auto-genic must be consistent.

Especially, if GenIC is enabled (jonas.service.ejb2.auto-genic true), then check ejb2 is among the services pointed at by jonas.services, eg:
jonas.services jtm,db,security,resource,ejb2,web,ear.

PostHeaderIcon Configure JProfiler 5 to work with JOnAS 5

JOnAS 4 (and older) and JProfiler 4 (and older) were used to working smoothly. JOnAS 5 makes a large use of OSGi libraries… which may “blind” JProfiler.

Here is a workaround, slightly different from former version, to bypass this issue, in order to make JProfiler 5 work with JOnAS 5:

  • let’s assume you have installed JOnAS in a folder, let’s say JONAS_ROOT
  • install JProfiler 5 with default options, set the JDK, licence key, etc., let’s say in a folder C:\win32app\jprofiler5\ also known as JPROFILER_HOME.
  • edit %JONAS_ROOT%/bin/setEnv.bat:
    • set: JAVA_OPTS=-agentlib:jprofilerti=port=8849 "-Xbootclasspath/a:C:\win32app\jprofiler5\bin\agent.jar" %JAVA_OPTS%
  • edit %JONAS_ROOT%/conf/osgi/default.properties
    • in the property bootdelegation-packages, add the JProfiler packages:
bootdelegation-packages com.sun.corba, \
                              com.sun.corba.*, \
                              (...)
                              com.jprofiler, \
                              com.jprofiler.*, \
                              com.jprofiler.agent, \
                              com.jprofiler.agent.*
  • add JPROFILER_HOME\bin\windows to your environment variable PATH.
  • startup JOnAS, you should see the following block in standard output:
JProfiler> Protocol version 25
JProfiler> Using JVMTI
JProfiler> 32-bit library
JProfiler> Listening on port: 8849.
JProfiler> Native library initialized
JProfiler> Waiting for a connection from the JProfiler GUI ...
JProfiler> Using dynamic instrumentation
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
JProfiler> Hotspot compiler enabled
JProfiler> Starting org/ow2/jonas/commands/admin/ClientAdmin ...
  • run JProfiler, follow the wizard, take caution to set JProfiler port at 8849 (or remain consistent with the port set in JOnAS config file)