[jira] [Comment Edited] (BSF-45) Error trying to access a MongoDB collection under Apache BSF script

2020-03-04 Thread Kleyson Rios (Jira)


[ 
https://issues.apache.org/jira/browse/BSF-45?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17051131#comment-17051131
 ] 

Kleyson Rios edited comment on BSF-45 at 3/4/20, 11:48 AM:
---

[~b.eckenfels] your suggestion worked fine.

Should I keep this as an issue ?


was (Author: kleysonr):
[~b.eckenfels] your suggestion worked fine.

Should I keep this as a issue ?

> Error trying to access a MongoDB collection under Apache BSF script
> ---
>
> Key: BSF-45
> URL: https://issues.apache.org/jira/browse/BSF-45
> Project: Commons BSF
>  Issue Type: Bug
>  Components: BSF-2.x
>Affects Versions: BSF-2.4
> Environment: Java 8
> BSF 2.4.0
>Reporter: Kleyson Rios
>Priority: Major
> Attachments: exception.txt
>
>
> I'm trying to access a MongoDB collection from a java code to be 'eval' by 
> BSF.
> I tried configure the MongoDB connection in both ways coding the driver 
> connection and following the tutorial 
> [https://mongodb.github.io/mongo-java-driver/3.10/driver/tutorials/jndi/] , 
> but in both cases the same error.
> Below the code to be executed by BSF:
>  
> {code:java}
> import javax.naming.InitialContext;
> import com.mongodb.MongoClient;
> import com.mongodb.client.MongoDatabase;
> import com.mongodb.client.MongoCollection;
> import org.bson.Document;
> InitialContext cxt = new InitialContext();
> if ( cxt == null ) {
>    throw new Exception("Uh oh -- no context!");
> }
> MongoClient ds = (MongoClient) cxt.lookup( 
> "java:/comp/env/mongodb/MongoClient" );
> if ( ds == null ) {
>    throw new Exception("Data source not found!");
> }
> MongoDatabase database = ds.getDatabase("ssp");
> //MongoCollection collection = database.getCollection("customer");
> {code}
>  
> The code above runs fine, but If I uncomment the last line 
> *MongoCollection collection = database.getCollection("customer")* , 
> the BSF throw a exception. See the attached *exception.txt* file.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (BSF-45) Error trying to access a MongoDB collection under Apache BSF script

2020-03-02 Thread Bernd Eckenfels (Jira)


[ 
https://issues.apache.org/jira/browse/BSF-45?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17049622#comment-17049622
 ] 

Bernd Eckenfels edited comment on BSF-45 at 3/2/20 8:22 PM:


I think BeanShell does not support generics (<...>) you need to stick to Java 
1.4 syntax.

{{MongoCollection collection = database.getCollection("customer");}}


was (Author: b.eckenfels):
I think BSF does not support generics (<...>) you need to stick to Java 1.4 
syntax.

{{MongoCollection collection = database.getCollection("customer");}}

> Error trying to access a MongoDB collection under Apache BSF script
> ---
>
> Key: BSF-45
> URL: https://issues.apache.org/jira/browse/BSF-45
> Project: Commons BSF
>  Issue Type: Bug
>  Components: BSF-2.x
>Affects Versions: BSF-2.4
> Environment: Java 8
> BSF 2.4.0
>Reporter: Kleyson Rios
>Priority: Major
> Attachments: exception.txt
>
>
> I'm trying to access a MongoDB collection from a java code to be 'eval' by 
> BSF.
> I tried configure the MongoDB connection in both ways coding the driver 
> connection and following the tutorial 
> [https://mongodb.github.io/mongo-java-driver/3.10/driver/tutorials/jndi/] , 
> but in both cases the same error.
> Below the code to be executed by BSF:
>  
> {code:java}
> import javax.naming.InitialContext;
> import com.mongodb.MongoClient;
> import com.mongodb.client.MongoDatabase;
> import com.mongodb.client.MongoCollection;
> import org.bson.Document;
> InitialContext cxt = new InitialContext();
> if ( cxt == null ) {
>    throw new Exception("Uh oh -- no context!");
> }
> MongoClient ds = (MongoClient) cxt.lookup( 
> "java:/comp/env/mongodb/MongoClient" );
> if ( ds == null ) {
>    throw new Exception("Data source not found!");
> }
> MongoDatabase database = ds.getDatabase("ssp");
> //MongoCollection collection = database.getCollection("customer");
> {code}
>  
> The code above runs fine, but If I uncomment the last line 
> *MongoCollection collection = database.getCollection("customer")* , 
> the BSF throw a exception. See the attached *exception.txt* file.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (BSF-45) Error trying to access a MongoDB collection under Apache BSF script

2020-03-02 Thread Bernd Eckenfels (Jira)


[ 
https://issues.apache.org/jira/browse/BSF-45?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17049622#comment-17049622
 ] 

Bernd Eckenfels edited comment on BSF-45 at 3/2/20 8:21 PM:


I think BSF does not support generics (<...>) you need to stick to Java 1.4 
syntax.

{{MongoCollection collection = database.getCollection("customer");}}


was (Author: b.eckenfels):
I think BSF does not support generics (`<...>`) you need to stick to Java 1.4 
syntax.



> Error trying to access a MongoDB collection under Apache BSF script
> ---
>
> Key: BSF-45
> URL: https://issues.apache.org/jira/browse/BSF-45
> Project: Commons BSF
>  Issue Type: Bug
>  Components: BSF-2.x
>Affects Versions: BSF-2.4
> Environment: Java 8
> BSF 2.4.0
>Reporter: Kleyson Rios
>Priority: Major
> Attachments: exception.txt
>
>
> I'm trying to access a MongoDB collection from a java code to be 'eval' by 
> BSF.
> I tried configure the MongoDB connection in both ways coding the driver 
> connection and following the tutorial 
> [https://mongodb.github.io/mongo-java-driver/3.10/driver/tutorials/jndi/] , 
> but in both cases the same error.
> Below the code to be executed by BSF:
>  
> {code:java}
> import javax.naming.InitialContext;
> import com.mongodb.MongoClient;
> import com.mongodb.client.MongoDatabase;
> import com.mongodb.client.MongoCollection;
> import org.bson.Document;
> InitialContext cxt = new InitialContext();
> if ( cxt == null ) {
>    throw new Exception("Uh oh -- no context!");
> }
> MongoClient ds = (MongoClient) cxt.lookup( 
> "java:/comp/env/mongodb/MongoClient" );
> if ( ds == null ) {
>    throw new Exception("Data source not found!");
> }
> MongoDatabase database = ds.getDatabase("ssp");
> //MongoCollection collection = database.getCollection("customer");
> {code}
>  
> The code above runs fine, but If I uncomment the last line 
> *MongoCollection collection = database.getCollection("customer")* , 
> the BSF throw a exception. See the attached *exception.txt* file.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (BSF-45) Error trying to access a MongoDB collection under Apache BSF script

2020-03-02 Thread Bernd Eckenfels (Jira)


[ 
https://issues.apache.org/jira/browse/BSF-45?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17049622#comment-17049622
 ] 

Bernd Eckenfels edited comment on BSF-45 at 3/2/20 8:20 PM:


I think BSF does not support generics (`<...>`) you need to stick to Java 1.4 
syntax.




was (Author: b.eckenfels):
I think BSF does not support generics (`<...>` you need to stick to Java 1.4 
syntax.

> Error trying to access a MongoDB collection under Apache BSF script
> ---
>
> Key: BSF-45
> URL: https://issues.apache.org/jira/browse/BSF-45
> Project: Commons BSF
>  Issue Type: Bug
>  Components: BSF-2.x
>Affects Versions: BSF-2.4
> Environment: Java 8
> BSF 2.4.0
>Reporter: Kleyson Rios
>Priority: Major
> Attachments: exception.txt
>
>
> I'm trying to access a MongoDB collection from a java code to be 'eval' by 
> BSF.
> I tried configure the MongoDB connection in both ways coding the driver 
> connection and following the tutorial 
> [https://mongodb.github.io/mongo-java-driver/3.10/driver/tutorials/jndi/] , 
> but in both cases the same error.
> Below the code to be executed by BSF:
>  
> {code:java}
> import javax.naming.InitialContext;
> import com.mongodb.MongoClient;
> import com.mongodb.client.MongoDatabase;
> import com.mongodb.client.MongoCollection;
> import org.bson.Document;
> InitialContext cxt = new InitialContext();
> if ( cxt == null ) {
>    throw new Exception("Uh oh -- no context!");
> }
> MongoClient ds = (MongoClient) cxt.lookup( 
> "java:/comp/env/mongodb/MongoClient" );
> if ( ds == null ) {
>    throw new Exception("Data source not found!");
> }
> MongoDatabase database = ds.getDatabase("ssp");
> //MongoCollection collection = database.getCollection("customer");
> {code}
>  
> The code above runs fine, but If I uncomment the last line 
> *MongoCollection collection = database.getCollection("customer")* , 
> the BSF throw a exception. See the attached *exception.txt* file.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)