When coding on any platform, you can sometimes run into issues that have no clear resolution. This can be particularly frustrating. If you have issues building, deploying, or running modules, you want to resolve them fast. These frequently asked questions and answers help you troubleshoot problems that arise based on the underlying OSGi platform, and then correct them.

Here are the troubleshooting sections:

Modules

How can I configure dependencies on Liferay Portal artifacts?

See Configuring Dependencies.

What are optional package imports and how can I specify them?

When developing Liferay Portal modules, you can declare optional package imports. An optional package import is one your module can use if it’s available, but can still function without it. Specifying optional package imports is straightforward.

How can I connect to a JNDI data source from my module?

Connecting to an application server’s JNDI data sources from Liferay Portal’s OSGi environment is almost the same as connecting to them from the Java EE environment. In an OSGi environment, the only difference is that you must use Liferay Portal’s class loader to load the application server’s JNDI classes.

My module has an Unresolved requirement. What can I do?

If one of your bundles imports a package that no other bundle in the Liferay OSGi runtime exports, Liferay Portal reports an unresolved requirement:

! could not resolve the bundles: ...
Unresolved requirement: Import-Package: ...
...
Unresolved requirement: Require-Capability ...

To satisfy the requirement, find a module that provides the capability, add it to your build file’s dependencies, and deploy it.

An IllegalContextNameException reports that my bundle’s context name does not follow Bundle-SymbolicName syntax. How can I fix the context name?

Adjust the Bundle-SymbolicName to adhere to the syntax.

Why aren’t my module’s JavaScript and CSS changes showing?

Incorrect component properties or stale browser cache can prevent JavaScript and CSS changes from showing.

Why aren’t my fragment’s JSP overrides showing?

Make sure your Fragment-Host’s bundle version is compatible with the host’s bundle version.

The application server and database started, but Liferay Portal failed to connect to the database. What happened and how can I fix this?

Liferay Portal initialization can fail while attempting to connect to a database server that isn’t ready. Configuring Liferay Portal startup to retry JDBC connections facilitates connecting Liferay Portal to databases.

How can I adjust my module’s logging?

See Adjusting Module Logging.

How can I implement logging in my module or plugin?

Use Simple Logging Facade for Java (SLF4J) to log messages.

Services and Components

How can I detect unresolved OSGi components?

Liferay Portal module components that use Service Builder use Dependency Manager (DM) and most other Liferay Portal module components use Declarative Services (DS). Gogo shell commands and tools help you find and inspect unsatisfied component references for DM and DS components.

What is the safest way to call non-OSGi code that uses OSGi services?

See Calling Non-OSGi Code that Uses OSGi Services.

How can I use files to configure modules?

See Using Files to Configure Liferay Portal Modules.

How can I use OSGi services from Ext Plugins?

The registry API lets Ext Plugins use OSGi services .

Resolving Bundle Requirements

If one of your bundles imports a package that no other bundle in the Liferay OSGi runtime exports, you get a bundle exception. Here’s an example exception: ! could not resolve the bundles:...

Read More

Resolving Bundle-SymbolicName Syntax Issues

An OSGi bundle’s Bundle-SymbolicName and Bundle-Version manifest headers uniquely identify it. You can specify a bundle’s Bundle-SymbolicName in these ways: Bundle-SymbolicName header in a bundle’s...

Read More

Resolving ClassNotFoundException and NoClassDefFoundError in OSGi Bundles

Understanding a ClassNotFoundException or NoClassDefFoundError in non-OSGi environments is straightforward. ClassNotFoundException: thrown when looking up a class that isn’t on the classpath or...

Read More

Identifying Liferay Artifact Versions for Dependencies

When you’re developing a Liferay Portal application, it’s often necessary to use various Liferay Portal APIs or tools. For example, you might want to create a Service Builder application or use...

Read More

Connecting to JNDI Data Sources

Connecting to an application server’s JNDI data sources from Liferay Portal’s OSGi environment is almost the same as connecting to them from the Java EE environment. In an OSGi environment, the...

Read More

Adjusting Module Logging

Liferay Portal uses Log4j logging services. You can configure logs for any module. Here’s how: Create the folder [Liferay_Home]/osgi/log4j if it’s not there. In the log4j folder, create a...

Read More

Implementing Logging

Liferay Portal CE 7.0 uses the Log4j logging framework, but a different one may eventually replace it. It’s a best practice to use Simple Logging Facade for Java (SLF4J) to log messages in your...

Read More

Declaring Optional Import Package Requirements

When developing Liferay Portal modules, you can declare optional dependencies. An optional dependency is one your module can use if it’s available, but can still function without it. Important: Try...

Read More

Why Aren’t my Module’s JavaScript and CSS Changes Showing?

To determine why JavaScript and CSS updates to your module aren’t having an effect in your browser, perform these checks: If you’re developing a portlet module, check that your portlet class has...

Read More

Why Aren’t JSP overrides I Made Using Fragments Showing?

The fragment module must specify the exact version of the host module. A Liferay Portal upgrade might have changed some JSPs in the host module, prompting a version update. If this occurs, check...

Read More

Detecting Unresolved OSGi Components

Liferay Portal includes Gogo shell commands that come in handy when trying to diagnose a problem due to an unresolved OSGi component. The specific tools to use depend on the component framework of...

Read More

Using Files to Configure Liferay Portal Modules

Liferay Portal uses Felix File Install to monitor file system folders for new/updated configuration files, and the Felix OSGi implementation of Configuration Admin to let you use files to configure...

Read More

Calling Non-OSGi Code that Uses OSGi Services

Liferay Portal’s static utility functions (e.g., UserServiceUtil, CompanyServiceUtil, GroupServiceUtil, etc.) are examples of non-OSGi code that use OSGi services. Note that it’s safer to track and...

Read More

Liferay Portal Failed to Initialize Because the Database Wasn’t Ready

If you start your database server and application server at the same time, Liferay Portal might try connecting to the data source before the database is ready. By default, Liferay Portal doesn’t...

Read More

Using OSGi Services from EXT Plugins

Using OSGi services from an Ext plugin is done the same way that Liferay Portal’s core uses OSGi services: via the com.liferay.registry API provided by the registry-api bundle. All usages of this...

Read More
0 (0 Votes)
Using the WAB Generator Previous