Projekt-Dokumentation (Aktueller Stand von juplo.de) hinzugefĆ¼gt
[website] / dist / facebook-utils-2.5.0 / pitfalls.html
1 <!DOCTYPE html>
2 <!-- Generated by Apache Maven Doxia Site Renderer at Nov 10, 2015 -->
3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   <!-- Current: pitfalls.html -->
4 <!-- Active: index.html -->
5 <!-- Path: $path -->
6 <!-- Skiplist: [index.html, getting-started.html] -->
7 <html>
8   <head>
9     <title>juplo - </title>
10     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11     <link rel="canonical" href="http://www.juplo.de/facebook-utils/pitfalls.html"/>
12     <meta name="viewport" content="width=device-width, initial-scale=1" />
13     <link rel="stylesheet" type="text/css" href="/css/base.css" />
14     <style type="text/css">
15       @import '/css/screen.css' screen;
16     </style>
17     <script src="/js/prettify.js"></script>
18     <!--[if lt IE 9]>
19       <script src="/js/html5shiv.js"></script>
20     <![endif]-->
21     <!--[if IE 8]>
22       <link rel="stylesheet" type="text/css" href="/css/ie8.css" />
23     <![endif]-->
24         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
25   </head>
26   <body class="menu" onload="prettyPrint()">
27     <div id="page" class="cf">
28       <header id="header">
29         <h1 id="logo"><a href="/" title="Home" class="l">juplo</a></h1>
30         <span id="slogan"><strong>Java</strong> bits from nerds for nerds</span>
31         <hr class="h" />
32       </header>
33       <div id="breadcrumb">
34         <strong class="b title">You are here:</strong>
35         <ol class="b">
36           <li class="b"><a class="b" href="/">Home</a></li>
37           <li class="b"><a class="b" href="/projects.html">Projects</a></li>
38                       <li class="b"><a class="b" href="./index.html">Juplo - Facebook Utils</a></li>
39                         <li class="b"><strong class="b">$shortTitle</strong></li>
40                   </ol>
41         <a class="hide" href="#navigation">Jump to navigation</a>
42         <hr class="b" />
43       </div>
44       <main class="content cf">
45         <article id="content" class="main">
46           <header><h1>$shortTitle</h1></header>
47           
48  
49  
50   <div class="section"><h2>Annotated classes in dependencies are not found.<a name="Annotated_classes_in_dependencies_are_not_found."></a></h2>
51   <p>
52   hibernate-maven-plugin by default scans dependencies in the scope
53   <tt>compile</tt>. You can configure it to scan dependencies in other
54   scopes as well. But it scans only direct dependencies. Transitive
55   dependencies are not scanned for annotated classes. If some of your
56   annotated classes are hidden in a transitive dependency, you can simply
57   add that dependency explicitly.
58   </p>
59   </div><div class="section"><h2>hibernate-maven-plugin always needs a database-connection<a name="hibernate-maven-plugin_always_needs_a_database-connection"></a></h2>
60   <p>
61   The default-configuration uses the EXPORT-target of the SchemaExport-Tool.
62   If you do not need to create a database with the evaluated schema, you can
63   use the NONE- or the SCRIPT-target.
64   This can be achieved with the command-line parameter
65   <tt>-Dhibernate.export.target=SCRIPT</tt> or with the following configuration:
66   </p>
67   <div class="prettyprint linenums lang-html"><pre>
68 &lt;configuration&gt;
69   &lt;target&gt;SCRIPT&lt;/target&gt;
70 &lt;/configuration&gt;</pre></div>
71   <p>
72   But even when no database is to be created, hibernate always needs to know
73   the dialect. Hence, the plugin will fail if this parameter is missing!
74   </p>
75   </div><div class="section"><h2>Dependency for driver-class XYZ is missing<a name="Dependency_for_driver-class_XYZ_is_missing"></a></h2>
76   <p>
77   One regular problem is the scope of the jdbc-driver-dependency.
78   It is very unlikely, that this dependency is needed at compile-time.
79   So a tidy maven-developer would usually scope it for <tt>runtime</tt>.
80   </p>
81   <p>
82   But this will break the execution of the <tt>hibernate-maven-plugin</tt>.
83   Since it will not be able to see the needed dependency, it will fail with
84   an error-message like:
85   </p>
86   <div class="prettyprint"><pre>
87 [INFO] Gathered hibernate-configuration (turn on debugging for details):
88 [INFO]   hibernate.connection.username = sa
89 [INFO]   hibernate.connection.password = 
90 [INFO]   hibernate.dialect = org.hibernate.dialect.HSQLDialect
91 [INFO]   hibernate.connection.url = jdbc:hsqldb:/home/kai/mmf/target/mmf;shutdown=true
92 [INFO]   hibernate.connection.driver_class = org.hsqldb.jdbcDriver
93 [ERROR] Dependency for driver-class org.hsqldb.jdbcDriver is missing!
94 [INFO] ------------------------------------------------------------------------
95 [ERROR] BUILD ERROR
96 [INFO] ------------------------------------------------------------------------
97 [INFO] org.hsqldb.jdbcDriver
98 [INFO] ------------------------------------------------------------------------
99 [INFO] For more information, run Maven with the -e switch
100 [INFO] ------------------------------------------------------------------------
101 [INFO] Total time: 2 seconds
102 [INFO] Finished at: Thu Nov 29 11:31:14 CET 2012
103 [INFO] Final Memory: 32M/342M
104 [INFO] ------------------------------------------------------------------------</pre></div>
105   <p>
106   A quick workaround for this error would be, to delete the runtime-constraint
107   for the jdbc-driver-dependency.
108   </p>
109   <p>
110   A much cleaner way is, to (additionally) ad the dependency, to the
111   plugin-definition:
112   </p>
113   <div class="prettyprint linenums lang-html"><pre>
114 &lt;plugin&gt;
115   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
116   &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
117   &lt;version&gt;${project.version}&lt;/version&gt;
118   &lt;executions&gt;
119     &lt;execution&gt;
120       &lt;goals&gt;
121         &lt;goal&gt;export&lt;/goal&gt;
122       &lt;/goals&gt;
123     &lt;/execution&gt;
124   &lt;/executions&gt;
125   &lt;dependencies&gt;
126   &lt;dependency&gt;
127     &lt;groupId&gt;org.hsqldb&lt;/groupId&gt;
128     &lt;artifactId&gt;hsqldb&lt;/artifactId&gt;
129     &lt;version&gt;2.2.8&lt;/version&gt;
130   &lt;/dependency&gt;
131   &lt;/dependencies&gt;
132 &lt;/plugin&gt;</pre></div>
133   <p>
134   This is also the best way, if you use a different jdbc-driver for
135   testing, than in production.
136   Because otherwise, this dependency will unnecessarily bloat the
137   runtime-dependencies of your project.
138   </p>
139   </div><div class="section"><h2 id="fails">DBUnit fails after execution of hibernate was skipped because nothing has changed</h2>
140   <p>
141   If hibernate-maven-plugin skips its excecution, this may lead to errors in
142   other plugins.
143   For example, when importing sample-data in the automatically created database
144   with the help of the <a class="externalLink" href="http://mojo.codehaus.org/dbunit-maven-plugin/">dbunit-plugin</a>,
145   the <tt>CLEAN_INSERT</tt>-operation may fail because of foreign-key-constraints,
146   if the database was not recreated, because the hibernate-maven-plugin has
147   skipped its excecution.
148   </p>
149   <p>
150   A quick fix to this problem is, to <a href="./force.html">force</a>
151   hibernate-maven-plugin to export the schema every time it is running.
152   But to recreate the database on every testrun may noticeable slow down your
153   development cycle, if you have to wait for slow IO.
154   </p>
155   <p>
156   To circumvent this problem, hibernate-maven-plugin signals a skipped
157   excecution by setting the  maven property <tt>$\{hibernate.export.skipped\}</tt> to
158   <tt>true</tt>.
159   You can configure other plugins to react on this signal.
160   For example, the dbunit-plugin can be configured to skip its excecution, if
161   hibernate-maven-plugin was skipped like this:
162   </p>
163   <div class="prettyprint linenums lang-html"><pre>
164 &lt;plugin&gt;
165   &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
166   &lt;artifactId&gt;dbunit-maven-plugin&lt;/artifactId&gt;
167   &lt;configuration&gt;
168     &lt;skip&gt;${hibernate.export.skipped}&lt;/skip&gt;
169   &lt;/configuration&gt;
170 &lt;/plugin&gt;</pre></div>
171   </div><div class="section"><h2>The database will not be recreated after a manual drop/clean<a name="The_database_will_not_be_recreated_after_a_manual_dropclean"></a></h2>
172   <p>
173   If one manually drops the database or removes the hsqldb-files, it will not
174   be recreated by the hibernate-maven-plugin, because it cannot detect, that
175   the database needs to be recreated.
176   This happens, because the plugin will not recreate the database if neither
177   the configuration nor the annotated classes have changed, because an
178   unnecessary drop-create-cycle might take a long time. The plugin will
179   report that like this:
180   </p>
181   <div class="prettyprint"><pre>
182 [INFO] No modified annotated classes found and dialect unchanged.
183 [INFO] Skipping schema generation!</pre></div>
184   <p>
185   If one always uses <tt>mvn clean</tt> for cleanup, this will not happen.
186   Otherwise the recreation must be <a href="./force.html">forced</a>:
187   </p>
188   <div class="prettyprint"><pre>
189 mvn hibernate:export -Dhibernate.export.force=true</pre></div>
190   </div><div class="section"><h2>The hibernate:export goal is not executed, when tests are skipped<a name="The_hibernate:export_goal_is_not_executed_when_tests_are_skipped"></a></h2>
191   <p>
192   The hibernate-maven-plugin automatically skips its execution, when
193   <tt>maven.test.skip</tt> is set to <tt>true</tt>. If you need it to be always
194   executed, you can configure that explicitly like this:
195   </p>
196   <div class="prettyprint linenums lang-html"><pre>
197 &lt;plugin&gt;
198   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
199   &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
200   ...
201   &lt;configuration&gt;
202     &lt;skip&gt;false&lt;/skip&gt;
203   &lt;/configuration&gt;
204 &lt;/plugin&gt;</pre></div>
205   <p>
206   Background-information for this design-decission can be found on the extra
207   page <a href="./skip.html">To skip or not to skip: that is the question</a>...
208   </p>
209   </div><div class="section"><h2>I do not want my dependencies to be scanned for hibernate annotations<a name="I_do_not_want_my_dependencies_to_be_scanned_for_hibernate_annotations"></a></h2>
210   <p>
211     If you do not want your dependencies to be scanned for hibernate annotations,
212     you can pass <tt>-Dhibernate.export.scan_dependencies=none</tt> to maven
213     or set <tt>scanDependencies</tt> to <tt>none</tt> in the configuration
214     of the plugin like this:
215   </p>
216   <div class="prettyprint linenums lang-html"><pre>
217 &lt;plugin&gt;
218   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
219   &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
220   ...
221   &lt;configuration&gt;
222     &lt;scanDependencies&gt;none&lt;/scanDependencies&gt;
223   &lt;/configuration&gt;
224 &lt;/plugin&gt;</pre></div>
225   </div><div class="section"><h2>No annotated classes found<a name="No_annotated_classes_found"></a></h2>
226   <p>
227     If you are working under Windows and get the error-message
228     <tt>No annotated classes found in directory C:\projects\X Y Z\path-to-project\target\classes</tt>,
229     but you are really sure, that there are annotated classes in that
230     directory, you are expiriencing a bug, in the scannotation-library, that
231     was closed in version 1.1.0 of the hibernate-maven-plugin.
232   </p>
233   <p>
234     <b>
235       You should consider to upgrade to that version of the plugin.
236     </b>
237   </p>
238  </div>
239
240         </article>
241         <div class="marginal">
242           <nav id="nav">
243             <hr class="n" />
244             <a id="navigation"></a>
245             <a class="hide" href="#top" title="Show Content">Jump back to the top of the page</a>
246             <h2 class="nav menu">Section-Menu</h2>
247             <ul id="menu">
248               <li class="m blog"><a href="/blog/" class="m">Blog</a></li>
249               <li class="m projects"><a href="/projects.html" class="m selected">Projects</a></li>
250               <li class="m about"><a href="/about.html" class="m">About</a></li>
251             </ul>
252             <h2 class="nav submenu">
253               <span class="s">Submenu for section</span>
254               <a class="s selected" href="/projects.html">Projects</a>
255             </h2>
256             <ul id="submenu" class="s">
257                                                               <li class="s sub off"><a class="s" href="/hibernate4-maven-plugin/">Hibernate 4 Maven Plugin</a></li>
258                                           </ul>
259             <hr class="n" />
260           </nav>
261           <aside class="m">
262             <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
263               <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
264             </a>
265           </aside>
266         </div>
267       </main>
268       <footer id="footer">
269         <hr class="f" />
270         <ul id="footerlinks">
271           <li class="f" id="copyright">&#xa9; <strong>mo</strong>             2015
272       </li>
273           <li class="f"><a class="f" href="/impressum.html">Impressum</a></li>
274           <li class="f about"><a class="f" href="/about.html">About</a></li>
275         </ul>
276       </footer>
277     </div>
278         <script type="text/javascript"><!--//--><![CDATA[//><!--
279       var _gaq = _gaq || [];
280       _gaq.push(['_setAccount', 'UA-571104-3']);
281       _gaq.push(['_trackPageview']);
282       (function() {
283         var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
284         ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
285         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
286       })();
287     //--><!]]>
288     </script>
289       </body>
290 </html>