AnsweredAssumed Answered

Problem loading users in extension

Question asked by Alberto Ruiz on Mar 8, 2017
Latest reply on Mar 21, 2017 by cf26721

Hello,

I have developed a RenderingHook B2 and I have found that I get error when trying to load some users using their user Ids from their course memberships.

 

I've found a thread from Heitor Silva Temp where he faces a related issue but in an application, and the solution applies to the application manifest : Failed to create SimpleApplicationTool due to invalid arguments

 

Mine has not <application-defs> so I can't try that solution.

 

The B2 offers a series of endpoints for the ajax calls from the injected javascript using spring mvc. Here is the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns="http://www.blackboard.com/bb-manifest-plugin"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.blackboard.com/bb-manifest-plugin https://maven.blackboard.com/content/repositories/releases/blackboard/platform/bb-manifest-plugin/9.1.201410.160373/bb-manifest-plugin-9.1.201410.160373.xsd">
  <plugin>

  <name value="b2.name" />
  <handle value="custom-messaging" />
  <description value="b2.description" />
  <default-locale value="en_US" />
  <webapp-type value="javaext" />

  <version value="1.0" />
  <requires>
  <bbversion value="9.1.201410.160373" />
  </requires>

  <vendor>
  <id value="elea" />
  <name value="eLearning Media" />
  <url value="http://www.elearningmedia.es/" />
  <description value="eLearning Media" />
  </vendor>

  <extension-defs>
  <definition namespace="es.elearningmedia">
  <extension id="mensajeriaRenderingHook" point="blackboard.platform.renderingHook"
  class="es.elearningmedia.mensajeria.service.MensajeriaRenderingHook"
  singleton="true" />
  </definition>
  </extension-defs>

  <permissions>
  <permission type="attribute" name="user.authinfo" actions="get" />
  <permission type="attribute" name="user.personalinfo"
  actions="get,set" />
  <permission type="java.io.FilePermission" name="&lt;&lt;ALL FILES&gt;&gt;"
  actions="read,write,delete,execute" />
  <permission type="socket" name="*" actions="connect,resolve" />

  <permission type="java.lang.RuntimePermission" name="getenv.windir" />

  <permission type="java.util.logging.LoggingPermission"
  name="control" actions="" />

  <permission type="java.lang.RuntimePermission" name="injectRenderingHook" />

  <permission type="java.lang.RuntimePermission" name="setFactory" />

  <permission type="javax.net.ssl.SSLPermission" name="setHostnameVerifier" />

  <permission type="java.lang.reflect.ReflectPermission"
  name="suppressAccessChecks" />
  <permission type="java.lang.RuntimePermission" name="accessDeclaredMembers" />
  <permission type="java.lang.RuntimePermission" name="createClassLoader" />
  <permission type="java.lang.RuntimePermission" name="setContextClassLoader" />
  <permission type="java.lang.RuntimePermission" name="getProtectionDomain" />
  <permission type="java.io.FilePermission" name="${java.home}/lib/*"
  actions="read" />
  </permissions>

  <requires-bean-introspection value="true" />

  </plugin>
</manifest>








 

And this is the code that causes the exception to rise:

for(CourseMembership courseStudent:courseStudents) {
  if(courseStudent.getIsAvailable()) {
  String userId = courseStudent.getUserId().getExternalString();
  if(!recipientsCourse.containsKey(userId)) {
  try {
  User user = UserDbLoader.Default.getInstance().loadById(courseStudent.getUserId());
  if(user.getIsAvailable() && userEligible(user)) {
  recipientsCourse.put(userId, user);
  recipientsCoord.put(userId, user);
  }
  } catch (Exception e) {
  e.printStackTrace();
  }

  }
  }

  }



And this is the relevant part of the exception:

blackboard.persist.KeyNotFoundException: No se ha encontrado el objeto especificado.
at blackboard.persist.impl.NewBaseDbLoader.loadObject(NewBaseDbLoader.java:127)
at blackboard.persist.user.impl.UserDbLoaderImpl.loadById(UserDbLoaderImpl.java:87)

Outcomes