Results 1 to 10 of 10
  1. #1
    gvanto is offline Member
    Join Date
    Nov 2013
    Posts
    10
    Rep Power
    0

    Question Initializing WeldContainer - HELP PLEASE!

    Hi all,

    I'm currently working my way through the "Beginning Java EE 7 - Antonio Goncalvez" book (which is good, although some simple things are left to one's own research) and I'm a 'little' stuck where the Main class is written for Weld :

    The weld.initialize() method below cannot be found, no idea why :-( Any help would be much appreciated.

    package org.aptovia.javaee7.CDBOOKSTORE;

    import org.glassfish.weld.WeldContainer;
    import org.jboss.weld.Weld;


    /**
    * Enterprise Application Client main class.
    *
    */
    public class Main {

    public static void main( String[] args ) {

    Weld weld = new Weld();
    WeldContainer container = weld.initialize(); //it says here can't find this method! ?! there's an option called 'current()'

    System.out.println( "Hello World Enterprise Application Client!" );
    }
    }

  2. #2
    gvanto is offline Member
    Join Date
    Nov 2013
    Posts
    10
    Rep Power
    0

    Default Re: Initializing WeldContainer - HELP PLEASE!

    No worries, found it: import org.jboss.weld.environment.se.Weld;
    NOT: import org.jboss.weld.Weld;

    arrrrgg ... so we learn eh.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Initializing WeldContainer - HELP PLEASE!

    When in doubt, read the documentation.
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    gvanto is offline Member
    Join Date
    Nov 2013
    Posts
    10
    Rep Power
    0

    Default Re: Initializing WeldContainer - HELP PLEASE!

    Sorry couldn't find that in any documentation :(

    Now getting build error with maven:

    gert@gert-VirtualBox:~/workspace/CDBOOKSTORE$ mvn compile -U
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building CDBOOKSTORE 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    Downloading: http://repo.maven.apache.org/maven2/...d-se-2.1.0.pom
    [WARNING] The POM for org.jboss.weld.se:weld-se:jar:2.1.0 is missing, no dependency information available
    Downloading: http://repo.maven.apache.org/maven2/...d-se-2.1.0.jar
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.689s
    [INFO] Finished at: Fri Nov 08 13:04:41 EST 2013
    [INFO] Final Memory: 7M/17M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project CDBOOKSTORE: Could not resolve dependencies for project org.aptovia.javaee7:CDBOOKSTORE:app-client:0.0.1-SNAPSHOT: Could not find artifact org.jboss.weld.se:weld-se:jar:2.1.0 in central (Directory Browsing Disabled) -> [Help 1]

    I have set my pom.xml file to include following dependency (I've put 2.1.0 as version since it seems its the latest version: Maven Repository: org.jboss.weld)
    so I'm not sure why getting this error?

    <dependency>
    <groupId>org.jboss.weld.se</groupId>
    <artifactId>weld-se</artifactId>
    <version>2.1.0</version>
    </dependency>
    Any help much appreciated
    gvanto

  5. #5
    gvanto is offline Member
    Join Date
    Nov 2013
    Posts
    10
    Rep Power
    0

    Default Re: Initializing WeldContainer - HELP PLEASE!

    OK seems I was missing 'Final' from the end of the version:
    The Central Repository Search Engine

    Now my proj builds fine, but when trying to execute get following error:

    gert@gert-VirtualBox:~/workspace/CDBOOKSTORE$ mvn exec:java
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building CDBOOKSTORE 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) @ CDBOOKSTORE >>>
    [INFO]
    [INFO] --- maven-dependency-plugin:2.6:copy (default) @ CDBOOKSTORE ---
    [INFO]
    [INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) @ CDBOOKSTORE <<<
    [INFO]
    [INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ CDBOOKSTORE ---
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.158s
    [INFO] Finished at: Fri Nov 08 13:49:11 EST 2013
    [INFO] Final Memory: 9M/21M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project CDBOOKSTORE: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java are missing or invalid -> [Help 1]

    I have in my POM.xml file specified the mainClass: (am I missing something somewhere? the pom.xml file seems Ok according to: Exec Maven Plugin - Usage )

    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
    <source>1.7</source>
    <target>1.7</target>
    <compilerArguments>
    <endorseddirs>${endorsed.dir}</endorseddirs>
    </compilerArguments>
    </configuration>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-acr-plugin</artifactId>
    <version>1.0</version>
    <extensions>true</extensions>
    <configuration>
    <archive>
    <manifest>
    <mainClass>org.aptovia.javaee7.CDBOOKSTORE.Main</mainClass>
    </manifest>
    </archive>
    </configuration>
    </plugin>

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.6</version>
    <executions>
    <execution>
    <phase>validate</phase>
    <goals>
    <goal>copy</goal>
    </goals>
    <configuration>
    <outputDirectory>${endorsed.dir}</outputDirectory>
    <silent>true</silent>
    <artifactItems>
    <artifactItem>
    <groupId>javax</groupId>
    <artifactId>javaee-endorsed-api</artifactId>
    <version>7.0</version>
    <type>jar</type>
    </artifactItem>
    </artifactItems>
    </configuration>
    </execution>
    </executions>
    </plugin>

    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
    <execution>
    <goals>
    <goal>java</goal>
    </goals>
    <configuration>
    <mainClass>org.aptovia.javaee7.CDBOOKSTORE.Main</mainClass>
    </configuration>
    </execution>
    </executions>
    </plugin>

    </plugins>
    </build>

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Initializing WeldContainer - HELP PLEASE!

    Quote Originally Posted by gvanto View Post
    Sorry couldn't find that in any documentation :(
    You can't have tried very hard.
    JBoss has lots of documentation, including this section covering the SE implementation you are using.

    If in doubt, go to the source.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: Initializing WeldContainer - HELP PLEASE!

    Weld is indeed one of the better documented technologies out there. I must say that JBoss/Red Hat itself has bettered their practices in recent years; it used to be that you had to scour the forums to get answers as a non-commercial user of their stuff, but nowadays everything is neatly documented.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Initializing WeldContainer - HELP PLEASE!

    Oh yes.
    They seem to have taken a leaf out of the Spring and Hibernate books.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: Initializing WeldContainer - HELP PLEASE!

    well Hibernate is also JBoss/Red Hat ;) In that respect Hibernate documentation is very lengthy, but it doesn't push the envelope; the HQL documentation for example tends to stick to the basic examples and doesn't show most of the things that you would run into in application that actually do mildly exciting things (such as combining different query structures); I still have to regularly ask Google to find the stackoverflow threads that actually do explain how to do it.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Initializing WeldContainer - HELP PLEASE!

    Ah, well, I was thinking JBoss 2003, so pre-Hibernate acquisition.
    I still wake up screaming...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Problem with initializing
    By littlebirdpoo in forum New To Java
    Replies: 3
    Last Post: 12-18-2011, 07:53 PM
  2. Initializing FileWriter
    By loopsnhoops in forum Advanced Java
    Replies: 1
    Last Post: 05-31-2011, 03:28 AM
  3. Help with initializing error
    By GDW in forum New To Java
    Replies: 7
    Last Post: 10-20-2010, 09:10 PM
  4. Initializing SAXParser
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-14-2007, 07:33 PM
  5. Initializing Arrays
    By bugger in forum New To Java
    Replies: 5
    Last Post: 11-09-2007, 10:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •