phax / as2-server

A standalone Java AS2 server - see as2-lib for the generic parts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve the building process so that a single JAR file results from the Maven build

phax opened this issue · comments

Based on issue #9

Currently the JAR file created from the pom.xml is not self-contained but contains all dependencies in a sub-folder of "target".
It would be nice to have a single, self-executable JAR file.

A problem why no simply the maven-assembly-plugin can be used is the following: BouncyCastle is used for S/MIME handling. BouncyCastle ships with its own SecurityProvider and must therefore be available in a signed (!) JAR and cannot be silently unpacked and included in another JAR.

So the available options to me are:

  • Find some kind of tool that creates a wrapper JAR with a custom classloader, so that the original JARs are maintained and not tempered
  • Create a JAR file that is signed so that the resulting file will be accepted by the Java runtime as a valid JAR for SecurityProviders

References: http://docs.oracle.com/javase/7/docs/technotes/guides/security/crypto/HowToImplAProvider.html

The issue explained in more detail: http://side-effects-bang.blogspot.co.at/2015/02/deploying-uberjars-that-use-bouncy.html

Hi Philip,

A single JAR would be great. However, I think having all dependencies in a single folder like we are doing currently is fine. I was just thinking we clean up the folder structure some so that finding things is simpler. Right now the structure to get to the config files is src->main->resources->config. Really, I feel that config should be in the root folder. Your expertise on this subject far exceeds mine, so whatever you feel is best, I just thought I would through this in just in case it simplifies things.

Thanks,
Michael

The output of the standalone build with dependencies is now the "standalone" folder.
Just call mvn clean install -Pwithdep on this project and you have a single folder standalone, where everything ends up - the JAR files and the configuration.

To avoid the problem with the signed JARs, I think this is a suitable, good solution.

Hi Philip,

I think I am missing something here. Here is log info:

mreinigjr@Q6-TEST-EDI:~/as2-server$ java -cp "standalone/*" com.helger.as2.app.MainOpenAS2Server standalone/config.xml
2015-08-24 12:51:53,073 DEBUG Starting configuration XmlConfiguration[location=jar:file:/home/mreinigjr/as2-server/standalone/as2-server.jar!/log4j2.xml]
2015-08-24 12:51:53,075 DEBUG PluginManager 'Core' found 69 plugins
2015-08-24 12:51:53,076 DEBUG PluginManager 'Level' found 0 plugins
2015-08-24 12:51:53,080 DEBUG PluginManager 'Lookup' found 10 plugins
2015-08-24 12:51:53,085 DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout]. Searching for builder factory method...
2015-08-24 12:51:53,099 DEBUG Found builder factory method [newBuilder]: public static org.apache.logging.log4j.core.layout.PatternLayout$Builder org.apache.logging.log4j.core.layout.PatternLayout.newBuilder().
2015-08-24 12:51:53,136 DEBUG TypeConverterRegistry initializing.
2015-08-24 12:51:53,137 DEBUG PluginManager 'TypeConverter' found 21 plugins
2015-08-24 12:51:53,197 DEBUG Calling build() on class class org.apache.logging.log4j.core.layout.PatternLayout$Builder for element PatternLayout with params(name="[%date{ISO8601}] [AS2-SERVER] [%-5level] [%thread] %msg -- %location%n", Configuration(jar:file:/home/mreinigjr/as2-server/standalone/as2-server.jar!/log4j2.xml), null, name="null", name="null", name="null", name="null", name="null")
2015-08-24 12:51:53,206 DEBUG PluginManager 'Converter' found 33 plugins
2015-08-24 12:51:53,213 DEBUG Built Plugin[name=layout] OK from builder factory method.
2015-08-24 12:51:53,214 DEBUG Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.FileAppender]. Searching for builder factory method...
2015-08-24 12:51:53,218 DEBUG No builder factory method found in class org.apache.logging.log4j.core.appender.FileAppender. Going to try finding a factory method instead.
2015-08-24 12:51:53,229 DEBUG Still building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.FileAppender]. Searching for factory method...
2015-08-24 12:51:53,231 DEBUG Found factory method [createAppender]: public static org.apache.logging.log4j.core.appender.FileAppender org.apache.logging.log4j.core.appender.FileAppender.createAppender(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,org.apache.logging.log4j.core.Layout,org.apache.logging.log4j.core.Filter,java.lang.String,java.lang.String,org.apache.logging.log4j.core.config.Configuration).
2015-08-24 12:51:53,277 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.FileAppender for element File with params(name="/home/mreinigjr/as2-server/logs/as2-server.log", name="null", name="null", name="logfile", name="null", name="null", name="null", name="null", PatternLayout([%date{ISO8601}] [AS2-SERVER] [%-5level] [%thread] %msg -- %location%n), null, name="null", name="null", Configuration(jar:file:/home/mreinigjr/as2-server/standalone/as2-server.jar!/log4j2.xml))
2015-08-24 12:51:53,281 DEBUG Starting FileManager /home/mreinigjr/as2-server/logs/as2-server.log
2015-08-24 12:51:53,287 DEBUG Built Plugin[name=appender] OK from factory method.
2015-08-24 12:51:53,294 DEBUG Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin]. Searching for builder factory method...
2015-08-24 12:51:53,295 DEBUG No builder factory method found in class org.apache.logging.log4j.core.config.AppendersPlugin. Going to try finding a factory method instead.
2015-08-24 12:51:53,296 DEBUG Still building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin]. Searching for factory method...
2015-08-24 12:51:53,297 DEBUG Found factory method [createAppenders]: public static java.util.concurrent.ConcurrentMap org.apache.logging.log4j.core.config.AppendersPlugin.createAppenders(org.apache.logging.log4j.core.Appender[]).
2015-08-24 12:51:53,298 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.AppendersPlugin for element Appenders with params(={logfile})
2015-08-24 12:51:53,300 DEBUG Built Plugin[name=appenders] OK from factory method.
2015-08-24 12:51:53,301 DEBUG Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef]. Searching for builder factory method...
2015-08-24 12:51:53,307 DEBUG No builder factory method found in class org.apache.logging.log4j.core.config.AppenderRef. Going to try finding a factory method instead.
2015-08-24 12:51:53,308 DEBUG Still building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef]. Searching for factory method...
2015-08-24 12:51:53,309 DEBUG Found factory method [createAppenderRef]: public static org.apache.logging.log4j.core.config.AppenderRef org.apache.logging.log4j.core.config.AppenderRef.createAppenderRef(java.lang.String,org.apache.logging.log4j.Level,org.apache.logging.log4j.core.Filter).
2015-08-24 12:51:53,313 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element AppenderRef with params(name="logfile", name="null", null)
2015-08-24 12:51:53,315 DEBUG Built Plugin[name=AppenderRef] OK from factory method.
2015-08-24 12:51:53,320 DEBUG Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger]. Searching for builder factory method...
2015-08-24 12:51:53,321 DEBUG No builder factory method found in class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger. Going to try finding a factory method instead.
2015-08-24 12:51:53,323 DEBUG Still building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger]. Searching for factory method...
2015-08-24 12:51:53,325 DEBUG Found factory method [createLogger]: public static org.apache.logging.log4j.core.config.LoggerConfig org.apache.logging.log4j.core.config.LoggerConfig$RootLogger.createLogger(java.lang.String,org.apache.logging.log4j.Level,java.lang.String,org.apache.logging.log4j.core.config.AppenderRef[],org.apache.logging.log4j.core.config.Property[],org.apache.logging.log4j.core.config.Configuration,org.apache.logging.log4j.core.Filter).
2015-08-24 12:51:53,327 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element Root with params(name="null", name="DEBUG", name="null", ={logfile}, ={}, Configuration(jar:file:/home/mreinigjr/as2-server/standalone/as2-server.jar!/log4j2.xml), null)
2015-08-24 12:51:53,332 DEBUG Built Plugin[name=root] OK from factory method.
2015-08-24 12:51:53,333 DEBUG Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin]. Searching for builder factory method...
2015-08-24 12:51:53,336 DEBUG No builder factory method found in class org.apache.logging.log4j.core.config.LoggersPlugin. Going to try finding a factory method instead.
2015-08-24 12:51:53,341 DEBUG Still building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin]. Searching for factory method...
2015-08-24 12:51:53,342 DEBUG Found factory method [createLoggers]: public static org.apache.logging.log4j.core.config.Loggers org.apache.logging.log4j.core.config.LoggersPlugin.createLoggers(org.apache.logging.log4j.core.config.LoggerConfig[]).
2015-08-24 12:51:53,343 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.LoggersPlugin for element Loggers with params(={root})
2015-08-24 12:51:53,344 DEBUG Built Plugin[name=loggers] OK from factory method.
2015-08-24 12:51:53,346 DEBUG Started configuration XmlConfiguration[location=jar:file:/home/mreinigjr/as2-server/standalone/as2-server.jar!/log4j2.xml] OK.
2015-08-24 12:51:53,354 DEBUG Shutting down OutputStreamManager SYSTEM_OUT
2015-08-24 12:51:53,355 DEBUG Stopped org.apache.logging.log4j.core.config.DefaultConfiguration@21bcffb5 OK
2015-08-24 12:51:53,647 DEBUG Registering MBean org.apache.logging.log4j2:type=2101973421
2015-08-24 12:51:53,652 DEBUG Registering MBean org.apache.logging.log4j2:type=2101973421,component=StatusLogger
2015-08-24 12:51:53,654 DEBUG Registering MBean org.apache.logging.log4j2:type=2101973421,component=ContextSelector
2015-08-24 12:51:53,661 DEBUG Registering MBean org.apache.logging.log4j2:type=2101973421,component=Loggers,name=
2015-08-24 12:51:53,671 DEBUG Registering MBean org.apache.logging.log4j2:type=2101973421,component=Appenders,name=logfile
2015-08-24 12:51:53,672 DEBUG Reconfiguration complete for context[name=2101973421] at null (org.apache.logging.log4j.core.LoggerContext@396a51ab) with optional ClassLoader: null
2015-08-24 12:51:53,672 DEBUG Shutdown hook enabled. Registering a new one.
2015-08-24 12:51:53,673 DEBUG LoggerContext[name=2101973421, org.apache.logging.log4j.core.LoggerContext@396a51ab] started OK.
2015-08-24 12:51:53,697 DEBUG Using default SystemClock for timestamps
java.lang.NullPointerException
    at com.helger.as2.app.session.AS2ServerXMLSession.load(AS2ServerXMLSession.java:184)
    at com.helger.as2.app.session.AS2ServerXMLSession.<init>(AS2ServerXMLSession.java:90)
    at com.helger.as2.app.session.AS2ServerXMLSession.<init>(AS2ServerXMLSession.java:84)
    at com.helger.as2.app.MainOpenAS2Server.start(MainOpenAS2Server.java:81)
    at com.helger.as2.app.MainOpenAS2Server.main(MainOpenAS2Server.java:64)
2015-08-24 12:51:53,767 DEBUG Stopping LoggerContext[name=2101973421, org.apache.logging.log4j.core.LoggerContext@396a51ab]
2015-08-24 12:51:53,769 DEBUG Stopping LoggerContext[name=2101973421, org.apache.logging.log4j.core.LoggerContext@396a51ab]...
2015-08-24 12:51:53,770 DEBUG Unregistering MBean org.apache.logging.log4j2:type=2101973421
2015-08-24 12:51:53,770 DEBUG Unregistering MBean org.apache.logging.log4j2:type=2101973421,component=StatusLogger
2015-08-24 12:51:53,771 DEBUG Unregistering MBean org.apache.logging.log4j2:type=2101973421,component=ContextSelector
2015-08-24 12:51:53,771 DEBUG Unregistering MBean org.apache.logging.log4j2:type=2101973421,component=Loggers,name=
2015-08-24 12:51:53,776 DEBUG Unregistering MBean org.apache.logging.log4j2:type=2101973421,component=Appenders,name=logfile
2015-08-24 12:51:53,777 DEBUG Shutting down FileManager /home/mreinigjr/as2-server/logs/as2-server.log
2015-08-24 12:51:53,778 DEBUG Stopped XmlConfiguration[location=jar:file:/home/mreinigjr/as2-server/standalone/as2-server.jar!/log4j2.xml] OK
2015-08-24 12:51:53,778 DEBUG Stopped LoggerContext[name=2101973421, org.apache.logging.log4j.core.LoggerContext@396a51ab]...

In previous builds, log4j2.xml was where we would go to edit logging. I tried copying this file into standalone and no change to running the program. Thoughts?

Thanks,
Michael

UPDATE: Never mind. After doing a fresh clone of the repo, this works well. Something was conflicting before from just doing a pull.

However, before this new release, I altered log4j2.xml so that logging info was being dropped to file so that I could run this server as a daemon. Where do I go now for this?

UPDATE: HAHA! Never mind again. I think I figured this one out. log4j2.xml is still in src, just need to rebuild. Might be a good idea to build this in to the standalone build. What do you think?

Thanks,
Michael