Tuesday, December 2, 2008

Антран плагины: нельзя два в одном и как проверить проперть

Если вы напишете в поме два плагина антран, то будет валидный только второй.

Вот пример:

===\/=====================================
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>000</id>
<phase>clean</phase>
<configuration>
<tasks>
<echo>=== ECHO === [${project.build.directory}] ===</echo>
<echo>=== ECHO === 000 ===</echo>
<echo>=== ECHO === 000 ===</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>0</id>
<phase>clean</phase>
<configuration>
<tasks>
<echo>=== ECHO === [${project.build.directory}] ===</echo>
<echo>=== ECHO === 0 ===</echo>
<echo>=== ECHO === 0 ===</echo>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
===/\=====================================

Результат работы:

[INFO] [clean:clean]
[INFO] [antrun:run {execution: 0}]
[INFO] Executing tasks
[echo] === ECHO === [/home/alexey/java/eXoProjects/portlet-container/trunk/applications/tck-tests/target] ===
[echo] === ECHO === 0 ===
[echo] === ECHO === 0 ===
[INFO] Executed tasks


Кстати, таким образом антран плагином можно проверить наличие системной проперти при помощи ECHO!

Затягиваем в Эклипс несобирающийся проект.


Всем привет!

1. Редактируем файл "pom.xml":
    сразу за тегом "<build>" вставляем строки:
-------------------------------------
           <sourceDirectory>src/nosources</sourceDirectory>
    <testSourceDirectory>src/notest</testSourceDirectory>
-------------------------------------

2. Выполняем команду "mvn eclipse:eclipse"
  можно использовать до этого mvn eclipse:clean

3. Редактируем файл ".classpath"
  Сразу после тега " <classpath>" заменяем строки:
-------------------------------------
  <classpathentry kind="src" path="src/main/java"
including="**/*.xml|**/*.xsl|**/*.properties|**/*.ion|**/*.conf|**/*.config"
excluding="**/*.java"/>
  <classpathentry kind="src" path="src/main/resources"
including="**/*.xml|**/*.xsl|**/*.properties|**/login.conf|**/*.ion|**/*.conf|**/*.config"
excluding="**/*.java"/>
  <classpathentry kind="src" path="src/test/java"
output="target/test-classes"
including="**/*.properties|**/*.xml|**/*.txt|**/*.conf|**/*.config"
excluding="**/*.java"/>
  <classpathentry kind="output" path="target/classes"/>
-------------------------------------

на строки:
-------------------------------------
        <classpathentry kind="src" path="src/main/java"/>

        <classpathentry kind="src" path="target/generated"/>

        <classpathentry excluding="**/*.java" including="**/*.xml" kind="src"
path="src/main/resources"/>

        <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
-------------------------------------

Потом фиксим уже в Эклипсе чего-там не собирается, при этом проверяем
билд с восстановленным файлом "pom.xml"

С уважением,
Алексей.


Monday, December 1, 2008

SAXParseException: Content is not allowed in prolog.

[org.xml.sax.SAXParseException: Content is not allowed in prolog.]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:510)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:215)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:190)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:241)
at org.exoplatform.services.wsrp2.utils.StandardPayload.getUnmarshalledObject(StandardPayload.java:95)
at org.exoplatform.services.wsrp2.utils.StandardClasses.getUnmarshalledObject(StandardClasses.java:71)
at org.exoplatform.services.wsrp2.utils.JAXBEventTransformer.getUnmarshalledObject(JAXBEventTransformer.java:254)
at org.exoplatform.services.wsrp2.utils.JAXBEventTransformer.getEventsUnmarshal(JAXBEventTransformer.java:132)
at org.exoplatform.services.wsrp2.consumer.impl.WSRPConsumerPlugin.processAction(WSRPConsumerPlugin.java:745)


Where not a consistent xml to unmarshal.
Первый параметр должен быть репрезентацией валидного хмл.

JAXBElement
unmarshal(Node node, Class declaredType)

JAXBElement stdElement = unmarshaller.unmarshal(messageElement,classT);