Reputation: 1672
I'm trying to get a JavaEE project to run on Glassfish 4.0 but when I try to flush inserts (persist) to the Sql Server DB it throws this error:
org.omg.CORBA.MARSHAL: WARNING: 00810057: Could not load class com.microsoft.sqlserver.jdbc.SQLServerException vmcid: OMG minor code: 57 completed: Maybe
The connection works in Netbeans for running commands and generating entity classes.
Bean method:
public int addUser(UserDetails u) {
try{
User uP = new User(u.getUserName(), u.isEnabled(), u.isAdmin());
em.persist(uP);
return 0;
}
catch(Exception e)
{
throw new EJBException(e);
}
}
Persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="LibraryBeanPU" transaction-type="JTA">
<jta-data-source>JavaEE_Library</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>
Client:
public static void main(String[] args) {
LibraryClient lc = new LibraryClient();
}
public LibraryClient()
{
LibraryFacadeRemote request = (LibraryFacadeRemote) getEJBBean("LibraryFacade");
request.addUser(new UserDetails("admin", true, true));
}
public Object getEJBBean(String beanName) {
try {
InitialContext ctx = new InitialContext();
return ctx.lookup(beanName);
} catch (Exception ex) {
System.err.println("ERROR: while locating bean from the server " + ex.getMessage());
return null;
}
}
Upvotes: 4
Views: 1256
Reputation: 1672
Fixed the problem, turns out generated entity classes can't handle schemas properly. Generated entity classes do not specify a schema in any queries they make even if you have configured the connection to connect to a specific schema. Also generated classes do not use square brackets around table names which can cause additional issues.
Upvotes: 0
Reputation: 10361
The persist
method probably failed server-side with a com.microsoft.sqlserver.jdbc.SQLServerException
that was caught and wrapped into an EJBException
.
When the client code receives the exception, it cannot unmarshal/deserialize that com.microsoft.sqlserver.jdbc.SQLServerException
instance because it is not present in client ClassPath
.
Adding the MS SqlServer JDBC driver in your client ClassPath
should solve the issue, but I would recommend you to avoid transmitting full server-side exceptions to your client code thanks to this architectural guideline:
EJBException
, do not wrap original exception but create an error message as String
from original getMessage()
and the UUID to refers to the logged full stack-traceUpvotes: 3