use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class JaxWsUtils method getName.
public static String getName(final Class<?> clazz) {
final WebService webService = clazz.getAnnotation(WebService.class);
if (webService != null) {
final String sei = webService.endpointInterface();
if (sei != null && sei.trim().length() != 0) {
try {
final Class seiClass = clazz.getClassLoader().loadClass(sei.trim());
return getNameFromInterface(seiClass);
} catch (final ClassNotFoundException e) {
throw new OpenEJBRuntimeException("Unable to load SEI class: " + sei, e);
}
}
return getName(clazz, webService.name());
}
final WebServiceProvider webServiceProvider = clazz.getAnnotation(WebServiceProvider.class);
if (webServiceProvider != null) {
return clazz.getName();
}
throw new IllegalArgumentException("The " + clazz.getName() + " is not annotated");
}
use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class UrlCache method createCacheDir.
private static File createCacheDir() {
try {
final FileUtils openejbBase = SystemInstance.get().getBase();
File dir = null;
// if we are not embedded, cache (temp) dir is under base dir
if (SystemInstance.get().getConf(null).exists()) {
try {
dir = openejbBase.getDirectory("temp");
} catch (final IOException e) {
// Ignore
}
}
// if we are embedded, tmp dir is in the system tmp dir
if (dir == null) {
dir = Files.tmpdir();
}
// If the cache dir already exists then empty its contents
if (dir.exists()) {
final File[] files = dir.listFiles();
if (null != files) {
for (final File f : files) {
deleteDir(f);
}
}
} else {
dir = createCacheDir(new File(dir.getAbsolutePath()));
}
return dir;
} catch (final IOException e) {
throw new OpenEJBRuntimeException(e);
}
}
use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class DynamicProxyImplFactory method newProxy.
public static Object newProxy(final BeanContext context, final InvocationHandler invocationHandler) {
if (QueryProxy.class.isInstance(invocationHandler)) {
EntityManager em = null;
for (final Injection injection : context.getInjections()) {
if (QueryProxy.class.equals(injection.getTarget())) {
try {
em = (EntityManager) context.getJndiEnc().lookup(injection.getJndiName());
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("a dynamic bean should reference at least one correct PersistenceContext", e);
}
}
}
if (em == null) {
throw new OpenEJBRuntimeException("can't find the entity manager to use for the dynamic bean " + context.getEjbName());
}
QueryProxy.class.cast(invocationHandler).setEntityManager(em);
}
return newProxy(context.getBeanClass(), invocationHandler);
}
use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class AbstractTomEEMojo method addJavaagents.
private void addJavaagents(final List<String> strings) {
final String existingJavaagent = "\\\"-javaagent:$CATALINA_HOME/lib/openejb-javaagent.jar\\\"";
final StringBuilder javaagentString = new StringBuilder(existingJavaagent);
for (final String rawJavaagent : javaagents) {
final String javaagent;
final String args;
int argsIdx = rawJavaagent.indexOf('=');
if (argsIdx < 0) {
argsIdx = rawJavaagent.indexOf('?');
}
if (argsIdx > 0) {
javaagent = rawJavaagent.substring(0, argsIdx);
args = rawJavaagent.substring(argsIdx);
} else {
javaagent = rawJavaagent;
args = "";
}
String path = javaagent;
if (!new File(javaagent).isFile()) {
try {
final FileWithMavenMeta jar = mvnToFile(javaagent, "jar");
if (persistJavaagents) {
final File javaagentFolder = new File(catalinaBase, "javaagent");
Files.mkdirs(javaagentFolder);
String name = jar.resolved.getName();
if (stripVersion) {
name = jar.stripVersion(true);
}
path = "$CATALINA_HOME/javaagent/" + name;
IO.copy(jar.resolved, new File(javaagentFolder, name));
}
strings.add("-javaagent:" + jar.resolved.getAbsolutePath() + args);
} catch (final Exception e) {
getLog().warn("Can't find " + javaagent);
strings.add("-javaagent:" + javaagent + args);
}
} else {
strings.add("-javaagent:" + javaagent + args);
}
if (persistJavaagents) {
javaagentString.append(" -javaagent:").append(path).append(args);
}
}
if (persistJavaagents) {
try {
{
final File catalinaSh = new File(catalinaBase, "bin/catalina.sh");
final String content = IO.slurp(catalinaSh).replace(existingJavaagent, javaagentString.toString());
doWrite(catalinaSh, content);
}
{
final File catalinaBat = new File(catalinaBase, "bin/catalina.bat");
final String content = IO.slurp(catalinaBat).replace("\"-javaagent:%CATALINA_HOME%\\lib\\openejb-javaagent.jar\"", javaagentString.toString().replace('\'', '"').replace('/', '\\').replace("$CATALINA_HOME", "%CATALINA_HOME%"));
doWrite(catalinaBat, content);
}
} catch (final IOException ioe) {
throw new OpenEJBRuntimeException(ioe);
}
}
}
use of org.apache.openejb.OpenEJBRuntimeException in project tomee by apache.
the class UpdatableTomEEMojo method deployer.
private Deployer deployer() {
if (removeTomeeWebapp && !ejbRemote) {
throw new OpenEJBRuntimeException("Can't use reload feature without TomEE Webapp, please set removeTomeeWebapp to false or ejbRemote to true");
}
final Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
properties.setProperty(Context.PROVIDER_URL, "http://" + tomeeHost + ":" + tomeeHttpPort + "/tomee/ejb");
try {
final Context context = new InitialContext(properties);
return (Deployer) context.lookup("openejb/DeployerBusinessRemote");
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("Can't lookup Deployer", e);
}
}
Aggregations