Soluzione per un file jar non trovabili in WEB-INF / cartella `` lib` né cartella src / main / resources`?

StackOverflow https://stackoverflow.com/questions/4025629

Domanda

Ho un'applicazione Java in esecuzione sul molo App Engine / / primavera.

Dopo aver rimosso alcuni file jar dal pom e mettendoli nella cartella WEB-INF/lib, non sono più trovabili sono - ricevo numerosi errori "Cannot find symbol" compilazione.

Inoltre ho provato a mettere i barattoli nella cartella src/main/resources -. Ma lo stesso risultato

Come posso fare questi vasi trovabili senza di loro riferimento nel pom

AGGIORNAMENTO PER LA DOMANDA PASCAL:

Ecco il "grado fo risorse ritrovamento" messaggi che ricevevo:

Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/htmlunit/2.8/htmlunit-2.8.pom
[INFO] Unable to find resource 'htmlunit:htmlunit:pom:2.8' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/svn/re
pository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/htmlunit/2.8/htmlunit-2.8.pom
[INFO] Unable to find resource 'htmlunit:htmlunit:pom:2.8' in repository jboss-repo (https://repository.jboss.org/nexus/content/groups
/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/htmlunit/2.8/htmlunit-2.8.pom
[INFO] Unable to find resource 'htmlunit:htmlunit:pom:2.8' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/apache-mime/0.6/apache-mime-0.6.pom
[INFO] Unable to find resource 'htmlunit:apache-mime:pom:0.6' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/svn
/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/apache-mime/0.6/apache-mime-0.6.pom
[INFO] Unable to find resource 'htmlunit:apache-mime:pom:0.6' in repository jboss-repo (https://repository.jboss.org/nexus/content/gro
ups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/apache-mime/0.6/apache-mime-0.6.pom
[INFO] Unable to find resource 'htmlunit:apache-mime:pom:0.6' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/commons-codec/1.4/commons-codec-1.4.pom
[INFO] Unable to find resource 'htmlunit:commons-codec:pom:1.4' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/s
vn/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/commons-codec/1.4/commons-codec-1.4.pom
[INFO] Unable to find resource 'htmlunit:commons-codec:pom:1.4' in repository jboss-repo (https://repository.jboss.org/nexus/content/g
roups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/commons-codec/1.4/commons-codec-1.4.pom
[INFO] Unable to find resource 'htmlunit:commons-codec:pom:1.4' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/commons-collections/3.2.1/commons-collections-3.2.1.pom
[INFO] Unable to find resource 'htmlunit:commons-collections:pom:3.2.1' in repository maven-gae-repo (http://maven-gae-plugin.googleco
de.com/svn/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/commons-collections/3.2.1/commons-collections-3.2.1.pom

[INFO] Unable to find resource 'htmlunit:commons-collections:pom:3.2.1' in repository jboss-repo (https://repository.jboss.org/nexus/c
ontent/groups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/commons-collections/3.2.1/commons-collections-3.2.1.pom
[INFO] Unable to find resource 'htmlunit:commons-collections:pom:3.2.1' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/commons-logging/1.1.1/commons-logging-1.1.1.pom
[INFO] Unable to find resource 'htmlunit:commons-logging:pom:1.1.1' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.c
om/svn/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/commons-logging/1.1.1/commons-logging-1.1.1.pom
[INFO] Unable to find resource 'htmlunit:commons-logging:pom:1.1.1' in repository jboss-repo (https://repository.jboss.org/nexus/conte
nt/groups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/commons-logging/1.1.1/commons-logging-1.1.1.pom
[INFO] Unable to find resource 'htmlunit:commons-logging:pom:1.1.1' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/cssparser/0.9.5/cssparser-0.9.5.pom
[INFO] Unable to find resource 'htmlunit:cssparser:pom:0.9.5' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/svn
/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/cssparser/0.9.5/cssparser-0.9.5.pom
[INFO] Unable to find resource 'htmlunit:cssparser:pom:0.9.5' in repository jboss-repo (https://repository.jboss.org/nexus/content/gro
ups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/cssparser/0.9.5/cssparser-0.9.5.pom
[INFO] Unable to find resource 'htmlunit:cssparser:pom:0.9.5' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/htmlunit-core-js/2.8/htmlunit-core-js-2.8.pom
[INFO] Unable to find resource 'htmlunit:htmlunit-core-js:pom:2.8' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.co
m/svn/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/htmlunit-core-js/2.8/htmlunit-core-js-2.8.pom
[INFO] Unable to find resource 'htmlunit:htmlunit-core-js:pom:2.8' in repository jboss-repo (https://repository.jboss.org/nexus/conten
t/groups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/htmlunit-core-js/2.8/htmlunit-core-js-2.8.pom
[INFO] Unable to find resource 'htmlunit:htmlunit-core-js:pom:2.8' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/httpclient/4.0.1/httpclient-4.0.1.pom
[INFO] Unable to find resource 'htmlunit:httpclient:pom:4.0.1' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/sv
n/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/httpclient/4.0.1/httpclient-4.0.1.pom
[INFO] Unable to find resource 'htmlunit:httpclient:pom:4.0.1' in repository jboss-repo (https://repository.jboss.org/nexus/content/gr
oups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/httpclient/4.0.1/httpclient-4.0.1.pom
[INFO] Unable to find resource 'htmlunit:httpclient:pom:4.0.1' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/httpcore/4.0.1/httpcore-4.0.1.pom
[INFO] Unable to find resource 'htmlunit:httpcore:pom:4.0.1' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/svn/
repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/httpcore/4.0.1/httpcore-4.0.1.pom
[INFO] Unable to find resource 'htmlunit:httpcore:pom:4.0.1' in repository jboss-repo (https://repository.jboss.org/nexus/content/grou
ps/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/httpcore/4.0.1/httpcore-4.0.1.pom
[INFO] Unable to find resource 'htmlunit:httpcore:pom:4.0.1' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/httpmime/4.0.1/httpmime-4.0.1.pom
[INFO] Unable to find resource 'htmlunit:httpmime:pom:4.0.1' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/svn/
repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/httpmime/4.0.1/httpmime-4.0.1.pom
[INFO] Unable to find resource 'htmlunit:httpmime:pom:4.0.1' in repository jboss-repo (https://repository.jboss.org/nexus/content/grou
ps/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/httpmime/4.0.1/httpmime-4.0.1.pom
[INFO] Unable to find resource 'htmlunit:httpmime:pom:4.0.1' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/nekohtml/1.9.14/nekohtml-1.9.14.pom
[INFO] Unable to find resource 'htmlunit:nekohtml:pom:1.9.14' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/svn
/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/nekohtml/1.9.14/nekohtml-1.9.14.pom
[INFO] Unable to find resource 'htmlunit:nekohtml:pom:1.9.14' in repository jboss-repo (https://repository.jboss.org/nexus/content/gro
ups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/nekohtml/1.9.14/nekohtml-1.9.14.pom
[INFO] Unable to find resource 'htmlunit:nekohtml:pom:1.9.14' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/sac/1.3/sac-1.3.pom
[INFO] Unable to find resource 'htmlunit:sac:pom:1.3' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/svn/reposit
ory)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/sac/1.3/sac-1.3.pom
[INFO] Unable to find resource 'htmlunit:sac:pom:1.3' in repository jboss-repo (https://repository.jboss.org/nexus/content/groups/publ
ic)
Downloading: http://repo1.maven.org/maven2/htmlunit/sac/1.3/sac-1.3.pom
[INFO] Unable to find resource 'htmlunit:sac:pom:1.3' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/serializer/2.7.1/serializer-2.7.1.pom
[INFO] Unable to find resource 'htmlunit:serializer:pom:2.7.1' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/sv
n/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/serializer/2.7.1/serializer-2.7.1.pom
[INFO] Unable to find resource 'htmlunit:serializer:pom:2.7.1' in repository jboss-repo (https://repository.jboss.org/nexus/content/gr
oups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/serializer/2.7.1/serializer-2.7.1.pom
[INFO] Unable to find resource 'htmlunit:serializer:pom:2.7.1' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/xalan/2.7.1/xalan-2.7.1.pom
[INFO] Unable to find resource 'htmlunit:xalan:pom:2.7.1' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/svn/rep
ository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/xalan/2.7.1/xalan-2.7.1.pom
[INFO] Unable to find resource 'htmlunit:xalan:pom:2.7.1' in repository jboss-repo (https://repository.jboss.org/nexus/content/groups/
public)
Downloading: http://repo1.maven.org/maven2/htmlunit/xalan/2.7.1/xalan-2.7.1.pom
[INFO] Unable to find resource 'htmlunit:xalan:pom:2.7.1' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/xercesImpl/2.9.1/xercesImpl-2.9.1.pom
[INFO] Unable to find resource 'htmlunit:xercesImpl:pom:2.9.1' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/sv
n/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/xercesImpl/2.9.1/xercesImpl-2.9.1.pom
[INFO] Unable to find resource 'htmlunit:xercesImpl:pom:2.9.1' in repository jboss-repo (https://repository.jboss.org/nexus/content/gr
oups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/xercesImpl/2.9.1/xercesImpl-2.9.1.pom
[INFO] Unable to find resource 'htmlunit:xercesImpl:pom:2.9.1' in repository central (http://repo1.maven.org/maven2)
Downloading: http://maven-gae-plugin.googlecode.com/svn/repository/htmlunit/xml-apis/1.3.04/xml-apis-1.3.04.pom
[INFO] Unable to find resource 'htmlunit:xml-apis:pom:1.3.04' in repository maven-gae-repo (http://maven-gae-plugin.googlecode.com/svn
/repository)
Downloading: https://repository.jboss.org/nexus/content/groups/public/htmlunit/xml-apis/1.3.04/xml-apis-1.3.04.pom
[INFO] Unable to find resource 'htmlunit:xml-apis:pom:1.3.04' in repository jboss-repo (https://repository.jboss.org/nexus/content/gro
ups/public)
Downloading: http://repo1.maven.org/maven2/htmlunit/xml-apis/1.3.04/xml-apis-1.3.04.pom
[INFO] Unable to find resource 'htmlunit:xml-apis:pom:1.3.04' in repository central (http://repo1.maven.org/maven2)

sono tutti legati alla HtmlUnit versione 2.8 piuttosto che la biblioteca GData ho detto in precedenza aveva causato gli errori.

Queste sono le corrispondenti voci HtmlUnit nel file pom per il progetto che sto cercando di costruire:

    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>htmlunit</artifactId>
        <version>2.8</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>apache-mime</artifactId>
        <version>0.6</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.1</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>cssparser</artifactId>
        <version>0.9.5</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>htmlunit-core-js</artifactId>
        <version>2.8</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.0.1</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.0.1</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>httpmime</artifactId>
        <version>4.0.1</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>nekohtml</artifactId>
        <version>1.9.14</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>sac</artifactId>
        <version>1.3</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>serializer</artifactId>
        <version>2.7.1</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>xalan</artifactId>
        <version>2.7.1</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.9.1</version>
    </dependency>
    <dependency>
        <groupId>htmlunit</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.3.04</version>
    </dependency>

Come avete indovinato correttamente, il HtmlUnit che è nel mio repository Maven locale non dispone di file pom. Anche io non riesco a ricordare come l'ho installato. In ogni sottodirectory che contiene un file jar non ci sono file pom - ma invece un file chiamato, per esempio, htmlunit-2.8.pom.lastUpdated che contiene questo testo:

#Last modified on: Tue Oct 26 13:43:29 BST 2010
#Tue Oct 26 13:43:29 BST 2010
http\://maven-gae-plugin.googlecode.com/svn/repository=1288097006231
https\://repository.jboss.org/nexus/content/groups/public=1288097009578
http\://repo1.maven.org/maven2=1288097009912

Si può chiedere perché sto usando la versione 2.8 - beh, contiene alcune patch che sono essenziali per il mio progetto. Versione 2.7 costruisce bene dalla dipendenza Maven:

<dependency>
   <groupId>net.sourceforge.htmlunit</groupId>
   <artifactId>htmlunit</artifactId>
   <version>2.7</version>
</dependency>

ma quando uso questo:

<dependency>
   <groupId>net.sourceforge.htmlunit</groupId>
   <artifactId>htmlunit</artifactId>
   <version>2.8</version>
</dependency>

ottengo un errore durante la compilazione che dice "riga di comando troppo lunga":

10/26/10 9:03:27 PM BST: [ERROR]  Standard error from the DataNucleus tool + org.datanucleus.enhancer.DataNucleusEnhancer :
10/26/10 9:03:27 PM BST: [ERROR] --------------------
10/26/10 9:03:27 PM BST: [ERROR] The command line is too long.
È stato utile?

Soluzione

  

Come ho menzionato in un commento qui sotto, voglio rimuoverli dal pom perché anche se sono nel mio repository Maven locale, mentre Maven sta costruendo il progetto si dice sempre che sta cercando di scaricare ciascuna di queste dipendenze locali, l'aggiunta di tempo in più su ogni ciclo di build.

Non stanno mostrando alcuna traccia che illustra il problema esatto (questa di solito aiuta), ma a meno che le dipendenze locali sono dipendenze istantanea (e che sarebbe una cattiva scelta per i manufatti installati manualmente), non credo che la tua descrizione del comportamento è preciso.

  

speravo di copiare questi vasi in un luogo dove saranno trovati dal processo di generazione, ma senza Maven cercando di scaricare tutte le risorse di volta in volta.

La mia ipotesi è che le dipendenze sono solo manca un file .pom, che è ciò che Maven sta cercando di scaricare. Si può dire Maven per generare questo pom per voi quando si installa un JAR nel repository locale utilizzando:

mvn install:install-file -Dfile=your-artifact-1.0.jar \
                         [-DgroupId=org.some.group] \
                         [-DartifactId=your-artifact] \
                         [-Dversion=1.0] \
                         [-Dpackaging=jar] \
                         [-DgeneratePom=true] 
  

A prescindere da quanto orribile possa sembrare, trovo il comportamento di Maven qui più orribile.

Utilizzando system dipendenze sfera di applicazione non sembrano orribile, E 'un orribile e scoraggiati pratica e deve essere evitato a 99,999% dei casi. Citando il link fornito:

  

sistema: Questa dipendenza è necessario in qualche fase del ciclo di vita del progetto, ma è il sistema-specifica. L'utilizzo di questo campo di applicazione è scoraggiato: Questo è considerato un "avanzata" tipo di funzione e deve essere utilizzato solo quando si capisce veramente tutte le ramificazioni del suo utilizzo, che può essere estremamente difficile se non addirittura impossibile quantificare Questo ambito, per definizione, rende il vostro costruire non portabile. Può essere necessario in alcuni casi limite. L'ambito sistema include l'elemento <systemPath> che indica la posizione fisica di questa dipendenza sulla macchina locale. È quindi usato per riferirsi a qualche artefatto dovrebbero essere presenti sulla macchina locale in un non in un archivio; e il cui percorso può variare da macchina a macchina. L'elemento systemPath può fare riferimento a variabili di ambiente nel suo percorso. ${JAVA_HOME} ad esempio

Basta usare Maven nel modo giusto e non avrete problemi. Con system ambito dipendenze (perché sulla terra persone mantenere suggerendo di abusare di loro ?!), prevedo più problemi in seguito.


  

Come avete indovinato correttamente, il HtmlUnit che è nel mio repository Maven locale non dispone di file pom. Anche io non riesco a ricordare come l'ho installato.

Quindi io non sono pazzo :) Ovviamente, il mio suggerimento è quello di risolvere il problema e per fornire i file .pom mancanti. Se non si desidera reinstallare i manufatti (in modo che Maven potrebbe generare loro), è possibile creare il .pom manualmente. Un file semplice come questo sarebbe sufficiente:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>ze.groupId</groupId>
  <artifactId>some-artifact-id</artifactId>
  <version>X.Y.Z</version>
</project>

Ma per favore, non passare alla system ambito dipendenze, questo farà più male che bene sul lungo periodo.

  

Si può chiedere il motivo per cui io sto usando la versione 2.8 -. Beh, contiene alcune patch che sono essenziali per il mio progetto

Certamente avete buone ragioni e non sarà nemmeno discuterne.

  

(...) ottengo un errore durante la compilazione che dice "riga di comando troppo lunga":

Questo è un peccato, e si dovrebbe riferire a questo problema DataNucleus.

Altri suggerimenti

<dependency>
    <groupId>org.companyname</groupId>
    <artifactId>artifact</artifactId>
    <version>versionNumber</version>
    <scope>system</scope>
    <systemPath>PATH_TO_YOUR_JAR</systemPath>
</dependency>

provare qualcosa di simile

  

dipendenze con il sistema di applicazione sono sempre disponibili e non sono guardato in repository. Essi sono di solito utilizzati per raccontare Maven sulle dipendenze che sono forniti dal JDK o VM. Così, dipendenze del sistema sono particolarmente utili per risolvere le dipendenze su manufatti che sono ora forniti dal JDK, ma dove disponibile come download separati in precedenza. esempio tipico sono le estensioni standard JDBC o l'Autenticazione e autorizzazione Java Service (JAAS).

Un semplice esempio potrebbe essere:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>javax.sql</groupId>
      <artifactId>jdbc-stdext</artifactId>
      <version>2.0</version>
      <scope>system</scope>
      <systemPath>${java.home}/lib/rt.jar</systemPath>
    </dependency>
  </dependencies>
  ...
</project>  
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top