<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:57:10 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-2420] Aggregates.replaceRoot and Aggregates.addFields</title>
                <link>https://jira.mongodb.org/browse/JAVA-2420</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Hi I am trying to use Aggregates.replaceRoot and Aggregates.addFields in MongoDb Java Driver in our application. I have the following codes used to test this function which is failing. Can you please tell me if it is a bug or syntax error in my code.&lt;/p&gt;

&lt;p&gt;public ArrayList&amp;lt;Document&amp;gt; testAggregation5() &lt;/p&gt;
{
        MongoCollection&amp;lt;Document&amp;gt; collection = databasePuttPutt.getCollection(&quot;Merchant&quot;);
        return collection.aggregate(
                Arrays.asList(
                        Aggregates.addFields(new Field(&quot;merchantId&quot;, &quot;testval&quot;)),
                        Aggregates.unwind(&quot;$promotion_list&quot;),
                        Aggregates.sort(orderBy(ascending(&quot;pro_created_date&quot;)))
                        
                )
        ).into(new ArrayList&amp;lt;Document&amp;gt;());
    }

&lt;p&gt;public ArrayList&amp;lt;Document&amp;gt; testAggregation6a() &lt;/p&gt;
{
        MongoCollection&amp;lt;Document&amp;gt; collection = databasePuttPutt.getCollection(&quot;Merchant&quot;);
        return collection.aggregate(
                Arrays.asList(
                        Aggregates.replaceRoot(&quot;$promotion_list&quot;)
                         
                )
        ).into(new ArrayList&amp;lt;Document&amp;gt;());
    }

&lt;p&gt;///////////////////////////////////////////////////////////////////////Error Stack is follwos/////////////&lt;/p&gt;

&lt;p&gt;Caused by: java.lang.NoSuchMethodError: com.mongodb.client.model.Aggregates.replaceRoot(Ljava/lang/Object;)Lorg/bson/conversions/Bson;&lt;br/&gt;
        at dbteam.com.jsf.starter.todo.NativeQuery.testAggregation6a(NativeQuery.java:140)&lt;br/&gt;
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br/&gt;
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)&lt;br/&gt;
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&lt;br/&gt;
        at java.lang.reflect.Method.invoke(Method.java:497)&lt;br/&gt;
        at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)&lt;br/&gt;
        at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82)&lt;br/&gt;
        at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93)&lt;br/&gt;
        at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)&lt;br/&gt;
        at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)&lt;br/&gt;
        at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:437)&lt;br/&gt;
        at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)&lt;br/&gt;
        at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)&lt;br/&gt;
        at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)&lt;br/&gt;
        at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)&lt;br/&gt;
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)&lt;br/&gt;
        at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)&lt;br/&gt;
        at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)&lt;br/&gt;
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)&lt;br/&gt;
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)&lt;br/&gt;
        ... 156 more&lt;/p&gt;

</description>
                <environment>Windows, Java 8</environment>
        <key id="341364">JAVA-2420</key>
            <summary>Aggregates.replaceRoot and Aggregates.addFields</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13202">Works as Designed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="himnaz@gmail.com">himnaz</reporter>
                        <labels>
                    </labels>
                <created>Wed, 28 Dec 2016 15:45:26 +0000</created>
                <updated>Fri, 27 Oct 2023 13:21:14 +0000</updated>
                            <resolved>Wed, 28 Dec 2016 16:48:46 +0000</resolved>
                                    <version>3.4.1</version>
                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1466131" author="himnaz@gmail.com" created="Wed, 28 Dec 2016 21:26:11 +0000"  >&lt;p&gt;Thanks. You are right.&lt;/p&gt;</comment>
                            <comment id="1465958" author="jeff.yemin" created="Wed, 28 Dec 2016 16:48:31 +0000"  >&lt;p&gt;It&apos;s almost certainly the case that in the JBoss environment in which you are running there is an older version of the driver in the classpath that is taking precedence over the 3.4.1 version with which you compiled those tests.   You might try enabling verbose class loading using the &lt;a href=&quot;http://www.oracle.com/technetwork/java/javase/clopts-139448.html#gbmtm&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;-verbose:class&lt;/a&gt; VM options to figure out what&apos;s happening.  For example, when I run your example in a test program with -verbose:class specified on the command line, I see this output:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;...&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;[Loaded com.mongodb.client.model.Aggregates from file:/Users/jeff/.m2/repository/org/mongodb/mongodb-driver-core/3.4.1/mongodb-driver-core-3.4.1.jar]&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;...&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hst873:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>