You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kenneth Henriksen <ph...@gmail.com> on 2009/12/16 20:33:24 UTC

How to deploy JiBX Maven project from Ant specifications

Hi,

I'm building a Maven project by looking at this project build by Ant:


http://soa.dzone.com/articles/pattern-based-development-with-0?page=0,3


Everything works fine, except that I can't figure out where to put the
"InsuranceMapping.xml" file used by JiBX. It is not referenced anywhere
except in the original Ant build.xml script seen hereunder ("." infront of
"param" is to make sure the whole post is shown):

<target name="deploy-insurance" description="Deploy the insurance example">
        <echo message="Creating insurance service units" />
                <antcall target="gn:create-serviceunit">
                        <.param name="servicemix-conf"
value="servicemix/insurance-jms-su" />
                        <.param name="service-dest-file"
value="insurance-jms-su.zip" />
                        <.param name="jibx-mapping"
value="jibx/InsuranceMapping.xml" />
                        <.param name="include-classes"
value="esb/dzone/servicemix/model/*" />
                        <.param name="include-resource-dir"
value="servicemix/insurance-jms-su/resources" />

                </antcall>
                <antcall target="gn:create-serviceunit">
                        <.param name="servicemix-conf"
value="servicemix/insurance-file-su" />
                        <.param name="service-dest-file"
value="insurance-file-su.zip" />
                        <.param name="include-classes"
value="esb/dzone/servicemix/model/*" />
                        <.param name="jibx-mapping"
value="jibx/InsuranceMapping.xml" />
                        <.param name="include-resource-dir"
value="servicemix/insurance-file-su/resources" />
                </antcall>


How du I do the same thing in my Maven project. Shoud the
"InsuranceMapping.xml" be referenced from some POM file?

Kind regards,
Kenneth H

Re: How to deploy JiBX Maven project from Ant specifications

Posted by Kenneth Henriksen <ph...@gmail.com>.
Hi again John,

Sorry for the late answer, I just made a new project which should be an
exact (Maven) copy of the Ant project I posted a link to. I did this to make
sure that I wasn't wasting you time with a "renaming" error from my part. I
got the same error though.

Line 51 is the exception itself:

catch (Exception e) {throw new JiBXException("Error marshalling XML to
Object",e);

>> Could you get the XML the method is seeing logged perhaps, or the value
of the src parameter?  Maybe inspect the cause and message of the exception
in catch block?
These are good ideas, but I don't know how to do it. Java's "println" does
not work, so it is possible til write directly to the ServiceMix console, so
we can see the content of the variables we're interested in?

Kind regards
Kenneth H

Re: How to deploy JiBX Maven project from Ant specifications

Posted by John Prystash <st...@yahoo.com>.
Glad you got a bit farther.  The exception cites line 51, which line is that from your method?  I agree there doesn't look like much to go on from the exception.
Could you get the XML the method is seeing logged perhaps, or the value of the src parameter?  Maybe inspect the cause and message of the exception in catch block?




________________________________
From: Kenneth Henriksen <ph...@gmail.com>
To: Maven Users List <us...@maven.apache.org>
Sent: Wed, December 16, 2009 7:04:42 PM
Subject: Re: How to deploy JiBX Maven project from Ant specifications

Thank you for your answer John. I believe the TerrorMapping.xml is now
included.

I still get this error when deploying on ServiceMix though:

javax.jms.JMSException: Error sending JBI exchange
        at
org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:575)
        at
org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint$1.onMessage(JmsConsumerEndpoint.java:505)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:518)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:479)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.jibx.runtime.JiBXException: Error marshalling XML to Object
        at terror.util.JiBXUtil.marshalDocument(JiBXUtil.java:51)
        at
terror.util.TerrorJMSMarshaler.populateMessage(TerrorJMSMarshaler.java:19)
        at
org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler.createExchange(DefaultConsumerMarshaler.java:99)
        at
org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:544)
        ... 10 more

The queue I'm sending the "TerrorTypeRequest1" object to is defined like
this:


       xmlns:fork="http://henriksenweb.com/FORK">

    .....

  <jms:consumer service="fork:terrorReceiver"
       endpoint="jmsEndpoint"
       targetService="fork:terrorDSLRouter"
       destinationName="terror.in"
       connectionFactory="#connectionFactory"
       marshaler="#TerrorJMSMarshaler"/>

</beans>

The "JiBXUtil.marshalDocument" function is defined like this:

public static Source marshalDocument(Object src, String encoding) throws
JiBXException {
  Source result = null;
  try {
   ByteArrayOutputStream bOut = new ByteArrayOutputStream();
   IMarshallingContext ctx =
BindingDirectory.getFactory(src.getClass()).createMarshallingContext();
   ctx.marshalDocument(src, "UTF-8", null, bOut);
   result = new StreamSource(new ByteArrayInputStream(bOut.toByteArray()));
  }
  catch (Exception e) {
   throw new JiBXException("Error marshalling XML to Object",e);
  }
  return result;
}

The relevant part of the TerrorMapping.xml:

<mapping name="TerrorType1Request" class="terror.model.TerrorType1Request"
ns="http://henriksenweb.com/terror">
   <namespace uri="http://henriksenweb.com/terror" default="elements"/>
    <value name="buildYear" field="buildYear"/>
    <value name="carType" field="carType"/>
    <value name="companyCar" field="companyCar"/>
    <value name="numberPlate" field="numberPlate"/>
    <value name="requestID" field="requestID"/>
    <value name="startDate" field="startDate"
    serializer="terror.util.DateJiBXSerializer.serialize"
    deserializer="terror.util.DateJiBXSerializer.deserialize"/>
</mapping>

And finally the object I'm sending is an instance of the (simple) class
"TerrorType1Request":


import java.io.Serializable;
import java.util.Date;

public class TerrorType1Request implements Serializable {

private static final long serialVersionUID = -507216273438778375L;
private String requestID;
private String numberPlate;
private String carType;
private int buildYear;
private boolean companyCar;
private Date startDate;

public String getRequestID() {
  return requestID;
}
public void setRequestID(String requestID) {
  this.requestID = requestID;
}
public String getNumberPlate() {
  return numberPlate;
}
public void setNumberPlate(String numberPlate) {
  this.numberPlate = numberPlate;
}
public String getCarType() {
  return carType;
}
public void setCarType(String carType) {
  this.carType = carType;
}
public int getBuildYear() {
  return buildYear;
}
public void setBuildYear(int buildYear) {
  this.buildYear = buildYear;
}
public boolean isCompanyCar() {
  return companyCar;
}
public void setCompanyCar(boolean companyCar) {
  this.companyCar = companyCar;
}
public Date getStartDate() {
  return startDate;
}
public void setStartDate(Date startDate) {
  this.startDate = startDate;
}

}


So where does it go wrong? Could it be something about namespaces? I don't
think the exception is telling me much.

Kind regards,
Kenneth H



      

Re: How to deploy JiBX Maven project from Ant specifications

Posted by Kenneth Henriksen <ph...@gmail.com>.
Thank you for your answer John. I believe the TerrorMapping.xml is now
included.

I still get this error when deploying on ServiceMix though:

javax.jms.JMSException: Error sending JBI exchange
        at
org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:575)
        at
org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint$1.onMessage(JmsConsumerEndpoint.java:505)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:518)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:479)
        at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
        at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
        at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.jibx.runtime.JiBXException: Error marshalling XML to Object
        at terror.util.JiBXUtil.marshalDocument(JiBXUtil.java:51)
        at
terror.util.TerrorJMSMarshaler.populateMessage(TerrorJMSMarshaler.java:19)
        at
org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler.createExchange(DefaultConsumerMarshaler.java:99)
        at
org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:544)
        ... 10 more

The queue I'm sending the "TerrorTypeRequest1" object to is defined like
this:

<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
       xmlns:fork="http://henriksenweb.com/FORK">

    .....

  <jms:consumer service="fork:terrorReceiver"
       endpoint="jmsEndpoint"
       targetService="fork:terrorDSLRouter"
       destinationName="terror.in"
       connectionFactory="#connectionFactory"
       marshaler="#TerrorJMSMarshaler"/>

</beans>

The "JiBXUtil.marshalDocument" function is defined like this:

public static Source marshalDocument(Object src, String encoding) throws
JiBXException {
  Source result = null;
  try {
   ByteArrayOutputStream bOut = new ByteArrayOutputStream();
   IMarshallingContext ctx =
BindingDirectory.getFactory(src.getClass()).createMarshallingContext();
   ctx.marshalDocument(src, "UTF-8", null, bOut);
   result = new StreamSource(new ByteArrayInputStream(bOut.toByteArray()));
  }
  catch (Exception e) {
   throw new JiBXException("Error marshalling XML to Object",e);
  }
  return result;
}

The relevant part of the TerrorMapping.xml:

<mapping name="TerrorType1Request" class="terror.model.TerrorType1Request"
ns="http://henriksenweb.com/terror">
   <namespace uri="http://henriksenweb.com/terror" default="elements"/>
    <value name="buildYear" field="buildYear"/>
    <value name="carType" field="carType"/>
    <value name="companyCar" field="companyCar"/>
    <value name="numberPlate" field="numberPlate"/>
    <value name="requestID" field="requestID"/>
    <value name="startDate" field="startDate"
    serializer="terror.util.DateJiBXSerializer.serialize"
    deserializer="terror.util.DateJiBXSerializer.deserialize"/>
</mapping>

And finally the object I'm sending is an instance of the (simple) class
"TerrorType1Request":


import java.io.Serializable;
import java.util.Date;

public class TerrorType1Request implements Serializable {

 private static final long serialVersionUID = -507216273438778375L;
 private String requestID;
 private String numberPlate;
 private String carType;
 private int buildYear;
 private boolean companyCar;
 private Date startDate;

 public String getRequestID() {
  return requestID;
 }
 public void setRequestID(String requestID) {
  this.requestID = requestID;
 }
 public String getNumberPlate() {
  return numberPlate;
 }
 public void setNumberPlate(String numberPlate) {
  this.numberPlate = numberPlate;
 }
 public String getCarType() {
  return carType;
 }
 public void setCarType(String carType) {
  this.carType = carType;
 }
 public int getBuildYear() {
  return buildYear;
 }
 public void setBuildYear(int buildYear) {
  this.buildYear = buildYear;
 }
 public boolean isCompanyCar() {
  return companyCar;
 }
 public void setCompanyCar(boolean companyCar) {
  this.companyCar = companyCar;
 }
 public Date getStartDate() {
  return startDate;
 }
 public void setStartDate(Date startDate) {
  this.startDate = startDate;
 }

}


So where does it go wrong? Could it be something about namespaces? I don't
think the exception is telling me much.

Kind regards,
Kenneth H

Re: How to deploy JiBX Maven project from Ant specifications

Posted by John Prystash <st...@yahoo.com>.
Hey Kenneth, there is a JiBX Maven plugin you could try.  In this example POM snippet below from one of my projects, the binding files are kept in src/main/resources.  You could put your insuranceMapping.xml in the includes directly or use a wildcard:

      <plugin>
        <groupId>org.jibx</groupId>
        <artifactId>maven-jibx-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
          <directory>src/main/resources</directory>
          <includes>
            <includes>*-binding.xml</includes>
          </includes>
          <verbose>true</verbose>
        </configuration>
        <executions>
          <execution>
            <phase>process-classes</phase>
            <goals>
              <goal>bind</goal>
            </goals>
          </execution>
       </executions>
      </plugin>
JiBX dependency:

    <dependency>
      <groupId>org.jibx</groupId>
      <artifactId>jibx-bind</artifactId>
      <version>1.2.1</version>
    </dependency>
Hope this helps




________________________________
From: Kenneth Henriksen <ph...@gmail.com>
To: users@maven.apache.org
Sent: Wed, December 16, 2009 2:33:24 PM
Subject: How to deploy JiBX Maven project from Ant specifications

Hi,

I'm building a Maven project by looking at this project build by Ant:


http://soa.dzone.com/articles/pattern-based-development-with-0?page=0,3


Everything works fine, except that I can't figure out where to put the
"InsuranceMapping.xml" file used by JiBX. It is not referenced anywhere
except in the original Ant build.xml script seen hereunder ("." infront of
"param" is to make sure the whole post is shown):

<target name="deploy-insurance" description="Deploy the insurance example">
        <echo message="Creating insurance service units" />
                <antcall target="gn:create-serviceunit">
                        <.param name="servicemix-conf"
value="servicemix/insurance-jms-su" />
                        <.param name="service-dest-file"
value="insurance-jms-su.zip" />
                        <.param name="jibx-mapping"
value="jibx/InsuranceMapping.xml" />
                        <.param name="include-classes"
value="esb/dzone/servicemix/model/*" />
                        <.param name="include-resource-dir"
value="servicemix/insurance-jms-su/resources" />

                </antcall>
                <antcall target="gn:create-serviceunit">
                        <.param name="servicemix-conf"
value="servicemix/insurance-file-su" />
                        <.param name="service-dest-file"
value="insurance-file-su.zip" />
                        <.param name="include-classes"
value="esb/dzone/servicemix/model/*" />
                        <.param name="jibx-mapping"
value="jibx/InsuranceMapping.xml" />
                        <.param name="include-resource-dir"
value="servicemix/insurance-file-su/resources" />
                </antcall>


How du I do the same thing in my Maven project. Shoud the
"InsuranceMapping.xml" be referenced from some POM file?

Kind regards,
Kenneth H



      

Re: Source for maven-jibx-plugin

Posted by Kalle Korhonen <ka...@gmail.com>.
On Wed, Mar 3, 2010 at 3:00 PM, marilysa <ma...@cisco.com> wrote:
> Does anyone know how to get the source code and license information for
> maven-jibx-plugin?  The web site gives a link to the license, but that link
> is broken.  It gives a link to the source code repository, but access to
> that page is disabled.  It gives instructions for using CVS to fetch the
> source as an anonymous user, but the commands do not work.  Several of us
> here have tried to obtain the sources and license, with no success.

It's still in the cvs. The code is browsable via
http://jibx.cvs.sourceforge.net/viewvc/jibx/maven-jibx-plugin/

Cvs works, use the Sourceforge project developer page for access
details: http://sourceforge.net/projects/jibx/develop

> My company is using maven-jibx-plugin in building one of our products, and
> we have strict requirements regarding use of Open Source IP.  We are
> required to have the sources stored in a central IP database, as well as the
> complete text of the license.

jibx is under BSD license. Storing the sources is not required for
code under BSD-style licenses (take my word for it :) )

Kalle

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Source for maven-jibx-plugin

Posted by marilysa <ma...@cisco.com>.
Hello, Maven users,

Does anyone know how to get the source code and license information for
maven-jibx-plugin?  The web site gives a link to the license, but that link
is broken.  It gives a link to the source code repository, but access to
that page is disabled.  It gives instructions for using CVS to fetch the
source as an anonymous user, but the commands do not work.  Several of us
here have tried to obtain the sources and license, with no success.

My company is using maven-jibx-plugin in building one of our products, and
we have strict requirements regarding use of Open Source IP.  We are
required to have the sources stored in a central IP database, as well as the
complete text of the license.

Any help or advice on getting the sources would be appreciated.

Thanks,
Marilyn Sander


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org