[JBoss Seam] - Using EntityManager out of EJBs components
by maykellff
Hi all, i need to use EntityManagerFactory y EntityManager outside of an EJB, in fact i need to use them inside of a simple Pojo. The below class is a simple pojo that load a collection from the DB and return that collection in form of StecItem[] array. Now when i run this code i get the following error:
java.sql.SQLException: You cannot set autocommit during a managed transaction!
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:482)
....
....
.......
Any help will be appreciated.
public class CargaNomencladores {
public static SelectItem[] cargaNomenclador(String nomencladorClassName)
{
EntityManagerFactory emf = Persistence.createEntityManagerFactory("jsfTest");
EntityManager em = emf.createEntityManager();
Query query = em.createQuery("select n from " + nomencladorClassName + "n");
List tempNomencladorRl = query.getResultList();
int size = tempNomencladorRl.size();
SelectItem[] nomencladorSelectItem = new SelectItem[size];
for (int i=0; i<size;i++){
SelectItem si = new SelectItem(tempNomencladorRl.get(i),tempNomencladorRl.get(i).getValor());
nomencladorSelectItem= si;
}
em.close();
emf.close();
return nomencladorSelectItem;
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4108688#4108688
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4108688
18 years, 5 months
[JBossWS] - Java Client Application using Stub with WS-Security
by method_ben
I have some problems to call methods from my web service. I use WS-Security to secure my web service. All necessary files (jboss-wsse-server.xml,jboss-wsse-client.xml, wsse.keystore, wsse.truststore) are in my WAR file.
My stubs are generated by wsconsume.
I have made a java application where I put my stub generated stub. This application is not deployed in JBoss. It's a simple java application with a "main".
Main.java :
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.naming.NamingException;
import javax.xml.namespace.QName;
import org.jboss.ws.core.StubExt;
import com.client.*;
public static void main(String[] args) throws MalformedURLException, NamingException
{
URL url = new URL("http://localhost:8080/test/Test?wsdl");
QName qName = new QName("rrr", "TestService");
TestService service = new TestService(url,qName);
Test ws = service.getPort(Test.class);
((StubExt) ws).setSecurityConfig(new File("etc/jboss-wsse-client.xml").toURI().toURL().toExternalForm());
((StubExt) ws).setConfigName("Standard WSSecurity Client");
ws.hello("Benoit"); // doesnt work !
}
When I execute it, I get that :
Exception in thread "main" javax.xml.ws.WebServiceException: org.jboss.ws.core.CommonSOAPFaultException: An internal WS-Security error occurred. See log for details
at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.processHandlerFailure(HandlerChainExecutor.java:276)
at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:155)
at org.jboss.ws.core.jaxws.client.ClientImpl.callRequestHandlerChain(ClientImpl.java:160)
at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:297)
at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:243)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:164)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:150)
at $Proxy14.hello(Unknown Source)
at com.main.MainTest.main(MainTest.java:51)
Caused by: org.jboss.ws.core.CommonSOAPFaultException: An internal WS-Security error occurred. See log for details
at org.jboss.ws.extensions.security.WSSecurityDispatcher.convertToFault(WSSecurityDispatcher.java:105)
at org.jboss.ws.extensions.security.WSSecurityDispatcher.handleOutbound(WSSecurityDispatcher.java:314)
at org.jboss.ws.extensions.security.jaxws.WSSecurityHandler.handleOutboundSecurity(WSSecurityHandler.java:95)
at org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerClient.handleOutbound(WSSecurityHandlerClient.java:45)
at org.jboss.ws.core.jaxws.handler.GenericHandler.handleMessage(GenericHandler.java:55)
at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:295)
at org.jboss.ws.core.jaxws.handler.HandlerChainExecutor.handleMessage(HandlerChainExecutor.java:140)
... 7 more
Anyone knows how I can resolve my problem ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4108685#4108685
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4108685
18 years, 5 months