Sunday, November 24, 2013

CreateProcess error=87, The parameter is incorrect Using JBoss eap WSConsume and Ant

Trying to run an ant file, when I got this error:

D:\workspace\test\wsclient-ant.xml:33: java.io.IOException: Cannot run program "C:\Java\jdk1.6.0_20\jre\bin\java.exe": CreateProcess error=87, The parameter is incorrect


This error is generated due to this part of my ant file:

<wsconsume 
fork="true"
keep="true"
verbose="true"
destdir="${binDir}"
sourcedestdir="${sourceDir}"
wsdl="${wsdlUrl}"
binding="${basedir}/jaxbCalendarBinding.xml"/>


and the command invoked was :

Command invoked: org.jboss.ws.tools.cmd.WSConsume -k -b D:\workspace\test\jaxbCalendarBinding.xml -o D:\workspace\test\build\bin\classes -s D:\workspace\test\build\src -v http://localhost:8080/MyService/MyService?wsdl

As the command was too long, and I have specified using fork=true that I would like to generate this task in a separate VM, eclipse was enable to do it.

The solution was to put the fork=false.

Thursday, November 21, 2013

Monitoring SOAP Messages : Logging SOAP Request / Response

When developing a web service, we need sometime to see the traffic sent and received between the Server and the client. So we need to watch the SOAP Requests and Responses exchanged.

To do this using metro, we can add just one code line :

Server Side :
com.sun.xml.ws.transport.http.HttpAdapter.dump=true;

Client Side:
com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true;  

As I am using JBoss, so I have added these parameters in the VM :

  •  Dump the SOAP messages on the client side: 

-Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true 

  • Dump the SOAP messages on the Server side:

-Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true 


Wednesday, November 20, 2013

JBoss7.x JBoss eap 6- NoClassDefFoundError ClassNotFoundException JBoss dependency


JBoss eap 6 comes with implicit and explicit dependencies loading. The implicit dependencies loaded by Jboss as 7 or Jboss eap 6 are listed in this link.
Once your application uses other dependencies, you should explicitly declare them in order to be loaded by JBoss.
You can also explicitely tell JBoss that you will exclude the loading of implicit jars. This is done in the jboss-deployment-structure.xml. An example of an exclusion of JBoss Logger module is explained here.

When we forget to declare a dependency, we will have  NoClassDefFoundError or ClassNotFoundException. Thus you should declare your dependencies in the META-INF/Manifest.MF or WEB-INF/jboss-deployment-structure.xml.




In my application, I use javax.servlet.api and org.jboss.ironjacamar.jdbcadapters. These names should be copied from the module.xml which is located in the specific jboss module.










Tuesday, November 19, 2013

Error in JBoss-deployment-structure.xml cvc-complex-type.2.4.a: Invalid content was found starting with element 'deployment'. One of '{ear-subdeployments-isolated, deployment, sub- deployment, module}' is expected.

When creating a JBoss-deployment-structure.xml, I have this error

 cvc-complex-type.2.4.a: Invalid content was found starting with element 'deployment'. One of '{ear-subdeployments-isolated, deployment, sub-  deployment, module}' is expected.


There is a Bug created for this error in JBoss.

Solution :

Delete the xmlns. 


Migration to JBoss EAP 6: How to migrate your project from old JBoss Version to JBoss EAP 6




Step 1: JBoss AS7 / EAP6 download

Download the JBoss EAP 6

Step 2: Configure the DataSource and the JDBC.

The datasource in JBoss AS7 or EAP6 is configured differently from the previous version. Please see this post, which explain how to do it.

Step 3: Hibernate configuration.

Jboss comes with Hibernate 4 version. Once JBoss detests Persistance.xml file, he add implicitely the Hibernate jars. So there is no need to declare an explicit dependency. But in my application, the used version was Hibernate 3. I don't like to move yet to Hibernate 4. So I have created a Hibernate 3 Module which is quit easy as we have the Hibernate module. Please see this post.

Step 4: Configure the Logging

JBoss comes with a logging module, which really is a good think as we are no more obliged to bundle the log4j jars. In the directory "C:\jboss-eap-6.1\standalone\configuration" you find a file named logging.properties, which you can configure to tell JBoss about your preferences. As this task isn't an urgent one, I will left him to later time. So I just configured JBoss to act as in previous version but this should be configured as JBoss implicitely ass the logging jars. To do this, please refer to the post of exclusion jboss logging.

Step 5: Add explicit dependencies 

JBoss comes with a module concept. The class loading is different from old version. So in JBoss, there is implicit loading and explicit loading. The list of implicit module loading is available here.
An explicit JBoss module, is available in JBoss but is not loaded unless the developer specify it in the WEB-INF/Jboss-deployment-structure.xml or  META-INF/Manifest.mf.
The post is under developemt, so it will be available later with more details.

Step 6: Configure the ClassPath and Resolve the Import errors

When changing the JBoss Runtime in the classpath, different errors appears in the imports. Please refer to this post in order to fix the errors.



Resolved : JBoss Eap 6 Problem in setting JBoss Eap classpath :System lib not found and Errors in the imports

I was facing a problem when migrating to JBoss Eap 6. In fact when changing the Runtime in the Java Build Path from an old one to a JBoss Enterprise Application Plateform6.1 Runtime, I have different errors in the Import. No libraries are found in the added JBoss in the Eclipse Project--> Preferences --> Java Build Path.

It seems that eclipse did not support yet JBoss Eap 6 as it comes with new look and many changes by introducing the module concept. So what to do.

Step 1: Move to JBoss Developer Studio

 Ok as we have trouble using Eclipse. We can chose the JBoss AS 7.1 Runtime. But is it a good idea, as JBoss Eap 6 is supporting JBoss as 7.2. I would like to have clean work. I have decided to work with JBoss Developer Studio which is based finally on eclipse but with some modification to support the new version of JBoss.
So all what you have to do is to login in the Red Hat web Site, and then go to the downloads.


Download the Red Hat JBoss Developer Studio 7:


Step 2 : Add the module to the default classpath Entries

Based on this jboss issue, I have tried the solution given by Rob.


  • Go to Windows --> Preferences --> Server --> Runtime Environments --> Default Classpath Entries 
  • Select JBoss Eap 6 Platform and clic on Add.
  • Give the Root Directory to the Module you would like to include, it may be system modules as your own modules.
  • Clic OK and let it do a full build to add the changements on the projects.



The JBoss EAP 6 Runtime looks like this : I have added the ironjacamar/ Jdbcadapter as I have problem in the import of org.jboss.jca.adapters.jdbc.jdk6.WrappedPreparedStatementJDK6



That's all for this ;)

Saturday, November 16, 2013

Add Hibernate 3 to JBoss AS 7 JBoss EAP 6 Migrate Hibernate 3 to JBoss 7 JBoss eap6

JBoss comes with Hibernate 4 jars. The Hibernate Module is located in

C:\jboss-eap-6.1\modules\system\layers\base\org\hibernate\main

Jboss adds Hibernate if he detects the presence of an @PersistenceUnit, @PersistenceContext annotation, or a <persistence-unit-ref> or <persistence-context-ref> . So we don't need to declare dependency in the jboss-deployment-structure.xml.

But in my case, my application is using Hibernate 3.3, so I have errors in my Hibernate imports as Hibernate 3 differs from Hibernate 4. What to doooooo.


Ok, as I would like to use Hibernate 3 in different application, I prefer to create a new module in JBoss. But this time it will be easier as I have a Hibernate in my modules. So let's start:

Step1:

Create a folder named 3 under "C:\jboss-eap-6.1\modules\system\layers\base\org\hibernate\"



Step2:

Working with Hibernate 3.3, I have downloaded it and put it in the directory 3 with the file module.xml. But I have an error :

javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'org.hibernate.ejb.HibernatePersistence' not found


In fact 'org.hibernate.ejb.HibernatePersistence' don’t exists at all in Hibernate 3.3, I have upgrated the application to use Hibernate3.6 and the error disappeared. So my hibernate/3 directory looks like this :


And my module.xml associated is this one:


There is no need to add anything to jboss-dependency-structure.xml as it will be loaded implicitely.

Step3: 

Make changes in the persistence.xml

In fact you should delete the provider from persistence.xml, which was org.hibernate.ejb.HibernatePersistence and add this line.

<property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />

The persistence.xml looks like this :




Monday, November 11, 2013

Disable, Exclude JBoss EAP 6 Logging : Exclude Logmanager Module

The JBoss EAP 6 comes with a new look :). It is no more the same directory structure, modules ...


I was trying to move from JBoss as 5 to JBoss 6. After a hard work, I have discovered that the JBoss 6 is End Of Life.


Ok no prblem. Let's move to JBoss EAP6 which uses JBoss as7. Go go go.
After fixing the dataSource configuration, which you can consult in this link. I was happy to deploy for the first time my application. And here Boooom. I get multiple errors ;(.

I have this error message :

[org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."myapp.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myapp.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "myapp.war"

Caused by: java.lang.NoClassDefFoundError: javax/mail/internet/AddressException
at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.6.0_20]
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) [rt.jar:1.6.0_20]
at java.lang.Class.getConstructor0(Class.java:2699) [rt.jar:1.6.0_20]
at java.lang.Class.newInstance0(Class.java:326) [rt.jar:1.6.0_20]
at java.lang.Class.newInstance(Class.java:308) [rt.jar:1.6.0_20]
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:247) [log4j-jboss-
Caused by: java.lang.ClassNotFoundException: javax.mail.internet.AddressException from [Module "org.jboss.log4j.logmanager:main" from local module loader @1b64e6a (finder: local module finder @1d62270 (roots: C:\jboss-eap-6.1\modules,C:\jboss-eap-6.1\modules\system\layers\base))]

In fact, as my application uses log4j which is also provided by JBoss. This later will try implicitly to load this module. In the internet, I have discovered that there is an open bug regarding this error. So in order to control this loading, JBoss proposes to use the jboss-deployment-structure.xml. We will not use the Log4j provided by JBoss and use the old method by providing our jar and log4j.xml file.

Step 1 :

Create a jboss-deployment-structure.xml under WEB-INF/  directory.



Step 2 :

Make sure that you put the log4j.jar in the  WEB-INF/lib  directory.


Finally add this parameter "-Dorg.jboss.as.logging.per-deployment=false "in the VM:



Coool it's deploying now :)

Resolved genwsdl-ant.xml:5: taskdef class com.sun.tools.ws.ant.WsGen cannot be found or taskdef class com.sun.tools.ws.ant.WsImport

I have problem when generating the WSDL usinf metro.

The error was :
genwsdl-ant.xml:5: taskdef class com.sun.tools.ws.ant.WsGen cannot be found.

In the classpath defined in the ant file, the jaxws-tools.jar and jaxws-rt.jar should be explicitely mentioned.

<taskdef classname="com.sun.tools.ws.ant.WsGen" name="wsgen">
<classpath path="${metroLib}/jaxws-tools.jar:${metroLib}/jaxws-rt.jar"></classpath>
</taskdef>

Where metroLib= C:/jaxws-ri-2.2.8/jaxws-ri/lib

Another error which accured also was :

You are running on JDK6 which comes with JAX-WS 2.1 API, but this tool requires JAX-WS 2.2 API

To resolve this problem, the jaxb-api.jar and jaxws-api.jar, you should create an endorsed directory in JAVA_Home/jre/lib/endorsed


Configure DataSource Setting in JBoss EAP6

In the previous version of JBoss, the configuration of Datasource was quit easy: the datasource file is defined in the JBoss_Home/server/default/deploy/*-ds.xml, while the JDBC driver is just placed in the JBoss_Home/server/default/lib directory.

In the JBoss EAP 6 is quit different and this is done as below.
In the Jbosseap6/modules, create the directory hierarchy : org/postgresql/main. Put in the main directory the database jdbc. 
In the same directory, create a file named module.xml and put the following code. Make sure to change the JDBC version according to the used one.






I prefer to manually configure the driver by making changes in the standalone.xml located in "C:\jboss-eap-6.1\standalone\configuration" I add Datasource in the Datasources balise and Driver in Drivers.


In my code I have :
private static final String POSTGRES_DS = "java:jboss/datasources/myPostgresDS";

I run after my server and it's OK ! 

Sunday, November 10, 2013

Web service Jbossws cxf: Enhance the Performance to get the service and the port getSertvice and getPort resolved

I was testing a Web Service developed respecting the JAX-WS specification and deployed on Jboss 6. The stack used by the Jboss is the JBossws-cxf 3.4.

Every time I call the getPort, it takes a good laps of time :

myService = new mydevelopedWSService();
System.out.println("take a port takes time " +System.currentTimeMillis());
mydevelopedWS myPort = myService.getmydevelopedWSPort();

In fact what I have find in the internet and in different forum, is that initializing the service involves reading and parsing the wsdl, and getting the port involves the creation of a dynamic port. Oracle specifies that by getting a dynamic client proxy, the application retrieves and interprets the WSDL and dynamically constructs calls. A dynamic proxy client enables a Web service client to invoke a web servicto invoke a Web service based on a service endpoint interface (SEI) dynamically at run-time (without using clientgen, wsconsume in jboss or wsimport in metro). This option does not rely upon a specific service implementation, providing greater flexibility, but also a greater performance hit.

In JBoss, I was trying to reduce this call time, and have seen that by chanding a properti in a file in the deployers, it can reduce considerably the time.

Here is the change to do. Open the file "stack-agnostic-jboss-beans.xml" located in "C:\jboss-6.1.0.Final\server\myconf\deployers\jbossws.deployer\META-INF". This property

<property name="webServiceHost">${jboss.bind.address}</property>
<property name="modifySOAPAddress">false</property>

 The default value is set to true, which means that JBoss is re-writing the soap-address in the WSDL every time we are retrieving it even if the specified address is valid. I have changed this property to false in order to disable this re-write and the application performance was better.

In JBoss eap 6.1, this parameter can be changed in the Standalone.xml located in JBoss-eap-6.1HOME\standalone\configuration.



Sunday, November 3, 2013

Invalid endpoint address in port portName in service ServiceLocator: REPLACE_WITH_ACTUAL_URL


When developing a web service, we often generate WSDL automatically using Wsimport in metro or Wsprovide in Jboss.
When I was trying creating a Wb Service client, I have had this error:
Invalid endpoint address in port portName in service ServiceLocator: REPLACE_WITH_ACTUAL_URL

In fact, in the generated WSDL, there was

<soap:address location="REPLACE_WITH_ACTUAL_URL"></soap:address>

where the Address should be replaced by the service Address

<soap:address location="http://localhost:8080/service/myService.ws"></soap:address>

Saturday, November 2, 2013

How to Get a Heap Dump : Analyze an OutOfMemoryError Java heap space - Part1 -

A Heap Dump is a snapshot of the memory of a Java process at a certain point of time. This snapshot contains information about the Java Objects and Classes in the heap. 

Step 1: Configure the JVM to generate a Heap Dump on an OutofMemory

In order to generate a heap dump when an "java.lang.OutOfMemoryError: Java heap space" exception occurs, the first thing to do is to add -XX:+HeapDumpOnOutOfMemoryError in the VM parameters. I am using Jboss6 server, so belong are the modifications. If you want to have a heap dmp on "CTRL BREAK", you can also add this parameter -XX:+HeapDumpOnCtrlBreak.






When an OutofMemory happens, this will generate a java_pid*.hprof file in the "C:\jboss-6.1.0.Final\bin" directory. This path can be changed in the VM parameters : -XX:HeapDumpPath= path_of_the_dump_file.

Step 2: Force the generation of a Heap Dump 

1- Using JConsole

Another way to generate a heap Dump is by using the JCONSOLE which can be found in the "C:\Java\jdk1.6.0_20\bin" directory.

 Select the dumpHeap operation from the com.sun.management.HotSpotDiagnostic MBean. As parameter p0 you should specify the full path to the heap dump file (exp "C:\hprof_Directory"). The file name should ends with .hprof. Clic to the dumpHeap button, a file will be generated in the choosen directory.


2- Using Memory Analyzer from Eclipse

Another way to have a Heap Dump is to use the Memory Analizer Plugin which can be added to eclipse. Please refer to this link. 
Open the Memory Analysis.






Then acquire a heap dump:


Step 2: Heap Dump Analysis

 

Once you have created your heap dump, you can analyze it using MAT (Memory Analzer). So Open the heap dump and navigate in the different options.




Articles les plus consultés